DeCOMtaminate nsIFrame::GetView and SetView, and add HasView, GetClosestView, and AreAncestorViewsVisible to consolidate common patterns. b=208004 r+sr=roc

git-svn-id: svn://10.0.0.236/trunk@143960 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
dbaron%dbaron.org 2003-06-19 23:44:01 +00:00
parent 10062c06df
commit 519cf3b3d3
102 changed files with 698 additions and 1530 deletions

View File

@ -464,10 +464,9 @@ PRBool nsAccessible::IsPartiallyVisible(PRBool *aIsOffscreen)
// and the STATE_OFFSCREEN flag that this is used for only needs to be a rough indicator
nsRect relFrameRect;
nsIView *containingView = nsnull;
nsPoint frameOffset;
frame->GetRect(relFrameRect);
frame->GetView(presContext, &containingView);
nsIView *containingView = frame->GetViewExternal(presContext);
if (!containingView) {
frame->GetOffsetFromView(presContext, frameOffset, &containingView);
if (!containingView)
@ -659,8 +658,7 @@ void nsAccessible::GetScreenOrigin(nsIPresContext *aPresContext, nsIFrame *aFram
while (aFrame) {
// Look for a widget so we can get screen coordinates
nsIView* view = nsnull;
aFrame->GetView(aPresContext, &view);
nsIView* view = aFrame->GetViewExternal(aPresContext);
nsPoint origin;
if (view) {
view->GetWidget(*getter_AddRefs(widget));

View File

@ -2718,8 +2718,7 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO, PRBool aDoCalcShrink)
}
if (frame) {
nsIView* view = nsnull;
frame->GetView(aPO->mParent->mPresContext, &view);
nsIView* view = frame->GetView(aPO->mParent->mPresContext);
if (view) {
nsCOMPtr<nsIWidget> w2;
view->GetWidget(*getter_AddRefs(w2));
@ -2871,8 +2870,7 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO, PRBool aDoCalcShrink)
//DumpFrames(fd, aPO->mPresContext, renderingContext, theRootFrame, 0);
fprintf(fd, "---------------------------------------\n\n");
fprintf(fd, "--------------- Views From Root Frame----------------\n");
nsIView * v;
theRootFrame->GetView(aPO->mPresContext, &v);
nsIView* v = theRootFrame->GetView(aPO->mPresContext);
if (v) {
v->List(fd);
} else {
@ -4799,8 +4797,7 @@ static void DumpFrames(FILE* out,
nsRect rect;
child->GetRect(rect);
fprintf(out, "[%d,%d,%d,%d] ", rect.x, rect.y, rect.width, rect.height);
nsIView * view;
child->GetView(aPresContext, &view);
nsIView* view = child->GetView(aPresContext);
fprintf(out, "v: %p ", view);
fprintf(out, "\n");
DumpFrames(out, aPresContext, aRendContext, child, aLevel+1);
@ -4895,8 +4892,7 @@ void DumpLayoutData(char* aTitleStr,
//DumpFrames(fd, aPresContext, renderingContext, aRootFrame, 0);
fprintf(fd, "---------------------------------------\n\n");
fprintf(fd, "--------------- Views From Root Frame----------------\n");
nsIView * v;
aRootFrame->GetView(aPresContext, &v);
nsIView* v = aRootFrame->GetView(aPresContext);
if (v) {
v->List(fd);
} else {

View File

@ -1175,7 +1175,6 @@ nsSelection::GetGlobalViewOffsetsFromFrame(nsIPresContext *aPresContext, nsIFram
nsresult result;
nsIFrame *frame = aFrame;
nsIView *view;
while (frame)
{
@ -1185,12 +1184,7 @@ nsSelection::GetGlobalViewOffsetsFromFrame(nsIPresContext *aPresContext, nsIFram
return result;
if (frame) {
view = 0;
result = frame->GetView(aPresContext, &view);
if (NS_FAILED(result))
return result;
nsIView *view = frame->GetView(aPresContext);
if (view)
{
@ -5890,53 +5884,14 @@ nsTypedSelection::DoAutoScrollView(nsIPresContext *aPresContext, nsIView *aView,
nsresult
nsTypedSelection::DoAutoScroll(nsIPresContext *aPresContext, nsIFrame *aFrame, nsPoint& aPoint)
{
nsresult result;
if (!aPresContext || !aFrame)
return NS_ERROR_NULL_POINTER;
//
// Find the closest view to the frame!
//
nsIView *closestView = 0;
result = aFrame->GetView(aPresContext, &closestView);
if (NS_FAILED(result))
return result;
nsIView *closestView = aFrame->GetClosestView(aPresContext);
if (!closestView)
{
//
// aFrame doesn't contain a view, so walk aFrame's parent hierarchy
// till you find a parent with a view.
//
nsIFrame *parentFrame = aFrame;
result = aFrame->GetParent(&parentFrame);
if (NS_FAILED(result))
return result;
if (!parentFrame)
return NS_ERROR_FAILURE;
while (!closestView && parentFrame)
{
result = parentFrame->GetView(aPresContext, &closestView);
if (NS_FAILED(result))
return result;
if (!closestView)
result = parentFrame->GetParent(&parentFrame);
}
if (!closestView)
return NS_ERROR_FAILURE;
}
return NS_ERROR_FAILURE;
return DoAutoScrollView(aPresContext, closestView, aPoint, PR_TRUE);
}
@ -7331,13 +7286,7 @@ nsTypedSelection::GetSelectionRegionRectAndScrollableView(SelectionRegion aRegio
if (!parentWithView)
return NS_ERROR_FAILURE;
result = parentWithView->GetView(presContext, &view);
if (NS_FAILED(result))
return result;
if (!view)
return NS_ERROR_FAILURE;
view = parentWithView->GetView(presContext);
result = GetClosestScrollableView(view, aScrollableView);

View File

@ -947,30 +947,7 @@ nsEventStateManager::HandleAccessKey(nsIPresContext* aPresContext,
if (frame) {
const nsStyleVisibility* vis = frame->GetStyleVisibility();
PRBool viewShown = PR_TRUE;
nsIView* frameView = nsnull;
frame->GetView(mPresContext, &frameView);
if (!frameView) {
nsIFrame* parentWithView = nsnull;
frame->GetParentWithView(mPresContext, &parentWithView);
if (parentWithView)
parentWithView->GetView(mPresContext, &frameView);
}
while (frameView) {
nsViewVisibility visib;
frameView->GetVisibility(visib);
if (visib == nsViewVisibility_kHide) {
viewShown = PR_FALSE;
break;
}
frameView->GetParent(frameView);
}
PRBool viewShown = frame->AreAncestorViewsVisible(mPresContext);
// get the XUL element
nsCOMPtr<nsIDOMXULElement> element = do_QueryInterface(content);
@ -1702,15 +1679,9 @@ nsEventStateManager::DoWheelScroll(nsIPresContext* aPresContext,
if (sv)
CallQueryInterface(sv, &focusView);
} else {
focusFrame->GetView(aPresContext, &focusView);
if (!focusView) {
nsIFrame* frameWithView;
focusFrame->GetParentWithView(aPresContext, &frameWithView);
if (frameWithView)
frameWithView->GetView(aPresContext, &focusView);
else
return NS_ERROR_FAILURE;
}
focusView = focusFrame->GetClosestView(aPresContext);
if (!focusView)
return NS_ERROR_FAILURE;
sv = GetNearestScrollingView(focusView);
}
@ -3494,25 +3465,7 @@ nsEventStateManager::GetNextTabbableContent(nsIContent* aRootContent,
const nsStyleVisibility* vis = currentFrame->GetStyleVisibility();
const nsStyleUserInterface* ui = currentFrame->GetStyleUserInterface();
PRBool viewShown = PR_TRUE;
nsIView* frameView = nsnull;
currentFrame->GetView(mPresContext, &frameView);
if (!frameView) {
nsIFrame* parentWithView = nsnull;
currentFrame->GetParentWithView(mPresContext, &parentWithView);
if (parentWithView)
parentWithView->GetView(mPresContext, &frameView);
}
while (frameView) {
nsViewVisibility visib;
frameView->GetVisibility(visib);
if (visib == nsViewVisibility_kHide) {
viewShown = PR_FALSE;
break;
}
frameView->GetParent(frameView);
}
PRBool viewShown = currentFrame->AreAncestorViewsVisible(mPresContext);
nsCOMPtr<nsIDOMElement> element(do_QueryInterface(child));

View File

@ -2990,30 +2990,29 @@ nsHTMLDocument::GetPixelDimensions(nsIPresShell* aShell,
nsCOMPtr<nsIPresContext> presContext;
aShell->GetPresContext(getter_AddRefs(presContext));
rv = frame->GetView(presContext, &view);
if (NS_SUCCEEDED(rv)) {
// If we have a view check if it's scrollable. If not,
// just use the view size itself
if (view) {
nsIScrollableView* scrollableView = nsnull;
CallQueryInterface(view, &scrollableView);
view = frame->GetView(presContext);
if (scrollableView) {
scrollableView->GetScrolledView(view);
}
// If we have a view check if it's scrollable. If not,
// just use the view size itself
if (view) {
nsIScrollableView* scrollableView = nsnull;
CallQueryInterface(view, &scrollableView);
nsRect r;
rv = view->GetBounds(r);
if (NS_SUCCEEDED(rv)) {
size.height = r.height;
size.width = r.width;
}
if (scrollableView) {
scrollableView->GetScrolledView(view);
}
// If we don't have a view, use the frame size
else {
rv = frame->GetSize(size);
nsRect r;
rv = view->GetBounds(r);
if (NS_SUCCEEDED(rv)) {
size.height = r.height;
size.width = r.width;
}
}
// If we don't have a view, use the frame size
else {
rv = frame->GetSize(size);
}
// Convert from twips to pixels
if (NS_SUCCEEDED(rv)) {

View File

@ -980,7 +980,7 @@ void nsSVGSVGElement::GetScreenPosition(PRInt32 &x, PRInt32 &y)
presShell->FlushPendingNotifications(PR_FALSE);
nsIFrame* frame;
nsresult rv = presShell->GetPrimaryFrameFor(this, &frame);
presShell->GetPrimaryFrameFor(this, &frame);
float t2p;
context->GetTwipsToPixels(&t2p);
@ -990,8 +990,7 @@ void nsSVGSVGElement::GetScreenPosition(PRInt32 &x, PRInt32 &y)
while (frame) {
// Look for a widget so we can get screen coordinates
nsIView* view;
rv = frame->GetView(context, &view);
nsIView* view = frame->GetView(context);
if (view) {
// handle scrolled views along the way:
nsIScrollableView* scrollableView = nsnull;
@ -1004,7 +1003,7 @@ void nsSVGSVGElement::GetScreenPosition(PRInt32 &x, PRInt32 &y)
}
// if this is a widget we break and get screen coords from it:
rv = view->GetWidget(*getter_AddRefs(widget));
view->GetWidget(*getter_AddRefs(widget));
if (widget)
break;
}

View File

@ -4626,19 +4626,13 @@ nsXULElement::HideWindowChrome(PRBool aShouldHide)
shell->GetPresContext(getter_AddRefs(presContext));
if (frame && presContext) {
nsIView* view = nsnull;
frame->GetView(presContext, &view);
if (!view) {
frame->GetParentWithView(presContext, &frame);
if (frame)
frame->GetView(presContext, &view);
}
nsIView* view = frame->GetClosestView(presContext);
if (view) {
nsCOMPtr<nsIWidget> widget;
view->GetWidget(*getter_AddRefs(widget));
// XXXldb Um, not all views have widgets...
widget->HideWindowChrome(aShouldHide);
}
}

View File

@ -1684,33 +1684,30 @@ nsXULDocument::GetPixelDimensions(nsIPresShell* aShell, PRInt32* aWidth,
result = aShell->GetPrimaryFrameFor(mRootContent, &frame);
if (NS_SUCCEEDED(result) && frame) {
nsIView* view;
nsCOMPtr<nsIPresContext> presContext;
aShell->GetPresContext(getter_AddRefs(presContext));
result = frame->GetView(presContext, &view);
if (NS_SUCCEEDED(result)) {
// If we have a view check if it's scrollable. If not,
// just use the view size itself
if (view) {
nsIScrollableView* scrollableView;
nsIView* view = frame->GetView(presContext);
// If we have a view check if it's scrollable. If not,
// just use the view size itself
if (view) {
nsIScrollableView* scrollableView;
if (NS_SUCCEEDED(CallQueryInterface(view, &scrollableView))) {
scrollableView->GetScrolledView(view);
}
if (NS_SUCCEEDED(CallQueryInterface(view, &scrollableView))) {
scrollableView->GetScrolledView(view);
}
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 {
result = frame->GetSize(size);
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 {
result = frame->GetSize(size);
}
// Convert from twips to pixels
if (NS_SUCCEEDED(result)) {

View File

@ -3269,20 +3269,10 @@ nsDocShell::GetVisibility(PRBool * aVisibility)
if (frame) {
nsCOMPtr<nsIPresContext> pc;
pPresShell->GetPresContext(getter_AddRefs(pc));
frame->GetView(pc, &view);
if (!view) {
nsIFrame* parentWithView;
frame->GetParentWithView(pc, &parentWithView);
parentWithView->GetView(pc, &view);
}
while (view) {
view->GetVisibility(vis);
if (vis == nsViewVisibility_kHide) {
*aVisibility = PR_FALSE;
return NS_OK;
}
view->GetParent(view);
if (!frame->AreAncestorViewsVisible(pc)) {
*aVisibility = PR_FALSE;
return NS_OK;
}
}
@ -6888,8 +6878,7 @@ nsDocShell::SetCanvasHasFocus(PRBool aCanvasHasFocus)
nsCOMPtr<nsIPresContext> presContext;
GetPresContext(getter_AddRefs(presContext));
nsIView* canvasView = nsnull;
frame->GetView(presContext, &canvasView);
nsIView* canvasView = frame->GetViewExternal(presContext);
nsCOMPtr<nsIViewManager> viewManager;
canvasView->GetViewManager(*getter_AddRefs(viewManager));

View File

@ -2045,12 +2045,7 @@ GetEditorContentWindow(nsIPresShell *aPresShell, nsIDOMElement *aRoot, nsIWidget
// Check first to see if this frame contains a view with a native widget.
nsIView *view = 0; // Not ref counted
result = frame->GetView(presContext, &view);
if (NS_FAILED(result))
return result;
nsIView *view = frame->GetViewExternal(presContext);
if (view)
{

View File

@ -6133,9 +6133,8 @@ nsHTMLEditor::GetElementOrigin(nsIDOMElement * aElement, PRInt32 & aX, PRInt32 &
nsresult rv;
while (frame) {
// Look for a widget so we can get screen coordinates
nsIView* view = nsnull;
rv = frame->GetView(pcontext, &view);
if (NS_SUCCEEDED(rv) && view) {
nsIView* view = frame->GetViewExternal(pcontext);
if (view) {
rv = view->GetWidget(*getter_AddRefs(widget));
if (widget)
break;

View File

@ -151,9 +151,8 @@ inFlasher::RepaintElement(nsIDOMElement* aElement)
nsIFrame* parentWithView = nsnull;
frame->GetParentWithView(pcontext, &parentWithView);
if (parentWithView) {
nsIView* view = nsnull;
nsresult rv= parentWithView->GetView(pcontext, &view);
if (NS_SUCCEEDED(rv) && view) {
nsIView* view = parentWithView->GetViewExternal(pcontext);
if (view) {
nsCOMPtr<nsIViewManager> viewManager;
view->GetViewManager(*getter_AddRefs(viewManager));
if (viewManager) {

View File

@ -199,9 +199,8 @@ inLayoutUtils::GetScreenOrigin(nsIDOMElement* aElement)
while (frame) {
// Look for a widget so we can get screen coordinates
nsIView* view = nsnull;
rv = frame->GetView(presContext, &view);
if (NS_SUCCEEDED(rv) && view) {
nsIView* view = frame->GetViewExternal(presContext);
if (view) {
rv = view->GetWidget(*getter_AddRefs(widget));
if (widget)
break;

View File

@ -3750,16 +3750,11 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell,
}
}
if (aPresContext) {
PRBool isPaginated = PR_FALSE;
if (NS_SUCCEEDED(aPresContext->IsPaginated(&isPaginated))) {
if (isPaginated) {
if (printPreviewContext) { // print preview
aPresContext->GetPaginatedScrolling(&isScrollable);
} else {
isScrollable = PR_FALSE; // we are printing
}
}
if (isPaginated) {
if (printPreviewContext) { // print preview
aPresContext->GetPaginatedScrolling(&isScrollable);
} else {
isScrollable = PR_FALSE; // we are printing
}
}
@ -3869,8 +3864,7 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell,
newScrollableFrame);
// Inform the view manager about the root scrollable view
nsIView* view = nsnull;
newScrollableFrame->GetView(aPresContext, &view);
nsIView* view = newScrollableFrame->GetView(aPresContext);
NS_ENSURE_TRUE(view, NS_ERROR_FAILURE);
nsIScrollableView* scrollableView = nsnull;
@ -3910,8 +3904,7 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell,
scrollPseudoStyle);
// Inform the view manager about the root scrollable view
nsIView* view = nsnull;
scrollFrame->GetView(aPresContext, &view);
nsIView* view = scrollFrame->GetView(aPresContext);
NS_ENSURE_TRUE(view, NS_ERROR_FAILURE);
nsIScrollableView* scrollableView = nsnull;
@ -4221,8 +4214,7 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsIPresShell* aPresShell,
newFrame = listFrame;
// XXX Temporary for Bug 19416
{
nsIView * lstView;
scrolledFrame->GetView(aPresContext, &lstView);
nsIView* lstView = scrolledFrame->GetView(aPresContext);
if (lstView) {
lstView->IgnoreSetPosition(PR_TRUE);
}
@ -4231,8 +4223,7 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsIPresShell* aPresShell,
// Set flag so the events go to the listFrame not child frames.
// XXX: We should replace this with a real widget manager similar
// to how the nsFormControlFrame works. Re-directing events is a temporary Kludge.
nsIView *listView;
listFrame->GetView(aPresContext, &listView);
nsIView *listView = listFrame->GetView(aPresContext);
NS_ASSERTION(nsnull != listView,"ListFrame's view is nsnull");
nsIWidget * viewWidget;
listView->GetWidget(viewWidget);
@ -4335,8 +4326,7 @@ nsCSSFrameConstructor::InitializeSelectFrame(nsIPresShell* aPresShell,
aStyleContext, aParentFrame, aBuildCombobox);
if (aBuildCombobox) {
// Give the drop-down list a popup widget
nsIView * view;
scrollFrame->GetView(aPresContext, &view);
nsIView* view = scrollFrame->GetView(aPresContext);
NS_ASSERTION(view, "We asked for a view but didn't get one");
if (view) {
nsCOMPtr<nsIViewManager> vm;
@ -4461,9 +4451,6 @@ nsCSSFrameConstructor::ConstructFieldSetFrame(nsIPresShell* aPresShel
nsHTMLContainerFrame::CreateViewForFrame(aPresContext, newFrame,
aStyleContext, aParentFrame, PR_FALSE);
// cache our display type
const nsStyleDisplay* styleDisplay = newFrame->GetStyleDisplay();
nsIFrame* areaFrame;
NS_NewAreaFrame(shell, &areaFrame, NS_BLOCK_SPACE_MGR | NS_BLOCK_SHRINK_WRAP);
@ -9840,9 +9827,7 @@ UpdateViewsForTree(nsIPresContext* aPresContext, nsIFrame* aFrame,
NS_PRECONDITION(gInApplyRenderingChangeToTree,
"should only be called within ApplyRenderingChangeToTree");
nsIView* view;
aFrame->GetView(aPresContext, &view);
nsIView* view = aFrame->GetView(aPresContext);
if (view) {
if (aChange & nsChangeHint_RepaintFrame) {
aViewManager->UpdateView(view, NS_VMREFRESH_NO_SYNC);
@ -9916,8 +9901,7 @@ DoApplyRenderingChangeToTree(nsIPresContext* aPresContext,
// frame doesn't have a view, find the nearest containing view
// (adjusting r's coordinate system to reflect the nesting) and
// update there.
nsIView* view = nsnull;
aFrame->GetView(aPresContext, &view);
nsIView* view = aFrame->GetView(aPresContext);
nsIView* parentView;
if (! view) { // XXX can view have children outside it?
aFrame->GetOffsetFromView(aPresContext, viewOffset, &parentView);
@ -9977,14 +9961,7 @@ ApplyRenderingChangeToTree(nsIPresContext* aPresContext,
nsCOMPtr<nsIViewManager> viewManager(aViewManager);
if (!viewManager) {
nsIView* view = nsnull;
aFrame->GetView(aPresContext, &view);
if (! view) {
nsPoint offset;
aFrame->GetOffsetFromView(aPresContext, offset, &view);
}
NS_ASSERTION(view, "no view");
view->GetViewManager(*getter_AddRefs(viewManager));
shell->GetViewManager(getter_AddRefs(viewManager));
}
// Trigger rendering updates by damaging this frame and any
@ -11020,8 +10997,9 @@ nsCSSFrameConstructor::CreateContinuingOuterTableFrame(nsIPresShell* aPresShell,
nsStyleContext* captionStyle = childFrame->GetStyleContext();
nsIContent* caption;
childFrame->GetContent(&caption);
const nsStyleDisplay* display = captionStyle->GetStyleDisplay();
NS_ASSERTION(NS_STYLE_DISPLAY_TABLE_CAPTION == display->mDisplay, "expected caption");
NS_ASSERTION(NS_STYLE_DISPLAY_TABLE_CAPTION ==
captionStyle->GetStyleDisplay()->mDisplay,
"expected caption");
// Replicate the caption frame
// XXX We have to do it this way instead of calling ConstructFrameByDisplayType(),
@ -13378,16 +13356,14 @@ nsCSSFrameConstructor::ConstructInline(nsIPresShell* aPresShell,
InitAndRestoreFrame(aPresContext, aState, aContent,
aParentFrame, blockSC, nsnull, blockFrame);
nsIView* originalInlineFrameView;
aNewFrame->GetView(aPresContext, &originalInlineFrameView);
nsIView* originalInlineFrameView = aNewFrame->GetView(aPresContext);
// Any inline frame could have a view (e.g., opacity)
// XXXbz should we be passing in a non-null aContentParentFrame?
nsHTMLContainerFrame::CreateViewForFrame(aPresContext, blockFrame,
aStyleContext, nsnull, PR_FALSE);
nsIView* view;
blockFrame->GetView(aPresContext, &view);
nsIView* view = blockFrame->GetView(aPresContext);
if (view || originalInlineFrameView) {
// Move list2's frames into the new view
nsIFrame* oldParent;
@ -13422,8 +13398,7 @@ nsCSSFrameConstructor::ConstructInline(nsIPresShell* aPresShell,
nsHTMLContainerFrame::CreateViewForFrame(aPresContext, inlineFrame,
aStyleContext, nsnull, PR_FALSE);
nsIView* inlineView;
inlineFrame->GetView(aPresContext, &inlineView);
nsIView* inlineView = inlineFrame->GetView(aPresContext);
if (inlineView || originalInlineFrameView) {
// Move list3's frames into the new view
nsIFrame* oldParent;

View File

@ -2879,8 +2879,7 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext,
// attachment (root or BODY) or the stylesheet specifying that
// attachment, set the BitBlt flag here as well.
if (canvasColor.mBackgroundAttachment == NS_STYLE_BG_ATTACHMENT_FIXED) {
nsIView *view;
aForFrame->GetView(aPresContext, &view);
nsIView *view = aForFrame->GetView(aPresContext);
if (view)
vm->SetViewBitBltEnabled(view, PR_FALSE);
}
@ -3112,7 +3111,7 @@ nsCSSRendering::PaintBackgroundWithSC(nsIPresContext* aPresContext,
if (scrolledFrame) {
scrolledFrame->GetRect(viewportArea);
scrolledFrame->GetView(aPresContext, &viewportView);
viewportView = scrolledFrame->GetView(aPresContext);
}
else {
// The viewport isn't scrollable, so use the root frame's view
@ -3132,7 +3131,7 @@ nsCSSRendering::PaintBackgroundWithSC(nsIPresContext* aPresContext,
rootFrame = page;
}
rootFrame->GetView(aPresContext, &viewportView);
viewportView = rootFrame->GetView(aPresContext);
NS_ASSERTION(viewportView, "no viewport view");
viewportView->GetBounds(viewportArea);
viewportArea.x = 0;
@ -3168,8 +3167,7 @@ nsCSSRendering::PaintBackgroundWithSC(nsIPresContext* aPresContext,
ComputeBackgroundAnchorPoint(aColor, viewportArea, viewportArea, tileWidth, tileHeight, anchor);
// Convert the anchor point to aForFrame's coordinate space
nsIView* view;
aForFrame->GetView(aPresContext, &view);
nsIView* view = aForFrame->GetView(aPresContext);
if (!view) {
nsPoint offset;
aForFrame->GetOffsetFromView(aPresContext, offset, &view);

View File

@ -2346,6 +2346,8 @@ FrameManager::SetFrameProperty(nsIFrame* aFrame,
nsresult result = NS_OK;
PropertyListMapEntry *entry = NS_STATIC_CAST(PropertyListMapEntry*,
PL_DHashTableOperate(&propertyList->mFrameValueMap, aFrame, PL_DHASH_ADD));
if (!entry)
return NS_ERROR_OUT_OF_MEMORY;
// A NULL entry->key is the sign that the entry has just been allocated
// for us. If it's non-NULL then we have an existing entry.
if (entry->key && propertyList->mDtorFunc) {

View File

@ -276,8 +276,9 @@ nsImageLoader::RedrawDirtyFrame(const nsRect* aDamageRect)
// XXX We should tell the frame the damage area and let it invalidate
// itself. Add some API calls to nsIFrame to allow a caller to invalidate
// parts of the frame...
mFrame->GetView(mPresContext, &view);
if (!view) {
if (mFrame->HasView()) {
view = mFrame->GetView(mPresContext);
} else {
mFrame->GetOffsetFromView(mPresContext, offset, &view);
bounds.x += offset.x;
bounds.y += offset.y;

View File

@ -918,8 +918,7 @@ IncrementalReflow::Dispatch(nsIPresContext *aPresContext,
first->SizeTo(aPresContext, aDesiredSize.width, aDesiredSize.height);
nsIView* view;
first->GetView(aPresContext, &view);
nsIView* view = first->GetView(aPresContext);
if (view)
nsContainerFrame::SyncFrameViewAfterReflow(aPresContext, first, view, nsnull);
@ -2850,8 +2849,7 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight)
rootFrame->SizeTo(mPresContext, desiredSize.width, desiredSize.height);
mPresContext->SetVisibleArea(nsRect(0,0,desiredSize.width,desiredSize.height));
nsIView* view;
rootFrame->GetView(mPresContext, &view);
nsIView* view = rootFrame->GetView(mPresContext);
if (view) {
nsContainerFrame::SyncFrameViewAfterReflow(mPresContext, rootFrame, view,
nsnull);
@ -2993,8 +2991,7 @@ PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight)
rootFrame->SizeTo(mPresContext, desiredSize.width, desiredSize.height);
mPresContext->SetVisibleArea(nsRect(0,0,desiredSize.width,desiredSize.height));
nsIView* view;
rootFrame->GetView(mPresContext, &view);
nsIView* view = rootFrame->GetView(mPresContext);
if (view) {
nsContainerFrame::SyncFrameViewAfterReflow(mPresContext, rootFrame, view,
nsnull);
@ -3536,8 +3533,7 @@ PresShell::StyleChangeReflow()
rootFrame->Reflow(mPresContext, desiredSize, reflowState, status);
rootFrame->SizeTo(mPresContext, desiredSize.width, desiredSize.height);
mPresContext->SetVisibleArea(nsRect(0,0,desiredSize.width,desiredSize.height));
nsIView* view;
rootFrame->GetView(mPresContext, &view);
nsIView* view = rootFrame->GetView(mPresContext);
if (view) {
nsContainerFrame::SyncFrameViewAfterReflow(mPresContext, rootFrame, view,
nsnull);
@ -3959,14 +3955,10 @@ PresShell::CreateRenderingContext(nsIFrame *aFrame,
return NS_ERROR_NULL_POINTER;
}
nsIView *view = nsnull;
nsPoint pt;
nsresult rv;
aFrame->GetView(mPresContext, &view);
if (nsnull == view)
aFrame->GetOffsetFromView(mPresContext, pt, &view);
nsIView *view = aFrame->GetClosestView(mPresContext);
nsCOMPtr<nsIWidget> widget;
if (nsnull != view) {
@ -6261,7 +6253,7 @@ PresShell::HandleEvent(nsIView *aView,
nsPoint offset(0,0);
nsRect oldTargetRect(mCurrentTargetRect);
mCurrentEventFrame->GetRect(mCurrentTargetRect);
mCurrentEventFrame->GetView(mPresContext, &mCurrentTargetView);
mCurrentTargetView = mCurrentEventFrame->GetView(mPresContext);
if (!mCurrentTargetView ) {
mCurrentEventFrame->GetOffsetFromView(mPresContext, offset,
&mCurrentTargetView);
@ -7007,8 +6999,8 @@ CompareTrees(nsIPresContext* aFirstPresContext, nsIFrame* aFirstFrame,
// do have views, make sure the views are the same size. If the
// views have widgets, make sure they both do or neither does. If
// they do, make sure the widgets are the same size.
k1->GetView(aFirstPresContext, &v1);
k2->GetView(aSecondPresContext, &v2);
v1 = k1->GetView(aFirstPresContext);
v2 = k2->GetView(aSecondPresContext);
if (((nsnull == v1) && (nsnull != v2)) ||
((nsnull != v1) && (nsnull == v2))) {
ok = PR_FALSE;

View File

@ -991,14 +991,21 @@ public:
/**
* Accessor functions to get/set the associated view object
*
* GetView returns non-null if and only if |HasView| returns true.
*/
NS_IMETHOD GetView(nsIPresContext* aPresContext,
nsIView** aView) const = 0; // may be null
NS_IMETHOD SetView(nsIPresContext* aPresContext,
nsIView* aView) = 0;
PRBool HasView() const { return mState & NS_FRAME_HAS_VIEW; }
nsIView* GetView(nsIPresContext* aPresContext) const;
virtual nsIView* GetViewExternal(nsIPresContext* aPresContext) const;
nsresult SetView(nsIPresContext* aPresContext, nsIView* aView);
/**
* Find the first geometric parent that has a view
* Find the closest view (on |this| or an ancestor).
*/
nsIView* GetClosestView(nsIPresContext* aPresContext) const;
/**
* Find the closest ancestor (excluding |this| !) that has a view
*/
NS_IMETHOD GetParentWithView(nsIPresContext* aPresContext,
nsIFrame** aParent) const = 0;
@ -1023,6 +1030,12 @@ public:
nsPoint& aOffset,
nsIView** aView) const = 0;
/**
* Returns true if and only if all views, from |GetClosestView| up to
* the top of the view hierarchy are visible.
*/
virtual PRBool AreAncestorViewsVisible(nsIPresContext* aPresContext);
/**
* Returns the window that contains this frame. If this frame has a
* view and the view has a window, then this frames window is

View File

@ -276,8 +276,9 @@ nsImageLoader::RedrawDirtyFrame(const nsRect* aDamageRect)
// XXX We should tell the frame the damage area and let it invalidate
// itself. Add some API calls to nsIFrame to allow a caller to invalidate
// parts of the frame...
mFrame->GetView(mPresContext, &view);
if (!view) {
if (mFrame->HasView()) {
view = mFrame->GetView(mPresContext);
} else {
mFrame->GetOffsetFromView(mPresContext, offset, &view);
bounds.x += offset.x;
bounds.y += offset.y;

View File

@ -568,8 +568,7 @@ nsComboboxControlFrame::ScrollIntoView(nsIPresContext* aPresContext)
void
nsComboboxControlFrame::ShowPopup(PRBool aShowPopup)
{
nsIView* view = nsnull;
mDropdownFrame->GetView(mPresContext, &view);
nsIView* view = mDropdownFrame->GetView(mPresContext);
nsCOMPtr<nsIViewManager> viewManager;
view->GetViewManager(*getter_AddRefs(viewManager));
@ -617,8 +616,7 @@ nsComboboxControlFrame::ShowList(nsIPresContext* aPresContext, PRBool aShowList)
// Get parent view
nsIFrame * listFrame;
if (NS_OK == mListControlFrame->QueryInterface(NS_GET_IID(nsIFrame), (void **)&listFrame)) {
nsIView * view = nsnull;
listFrame->GetView(aPresContext, &view);
nsIView* view = listFrame->GetView(aPresContext);
NS_ASSERTION(view != nsnull, "nsComboboxControlFrame view is null");
if (view) {
view->GetWidget(*getter_AddRefs(widget));
@ -677,8 +675,7 @@ nsComboboxControlFrame::ReflowComboChildFrame(nsIFrame* aFrame,
// ensure we start off hidden
if (aReflowState.reason == eReflowReason_Initial) {
nsIView* view = nsnull;
mDropdownFrame->GetView(mPresContext, &view);
nsIView* view = mDropdownFrame->GetView(mPresContext);
nsCOMPtr<nsIViewManager> viewManager;
view->GetViewManager(*getter_AddRefs(viewManager));
viewManager->SetViewVisibility(view, nsViewVisibility_kHide);
@ -1810,8 +1807,7 @@ nsComboboxControlFrame::ShowDropDown(PRBool aDoDropDown)
if (!mDroppedDown && aDoDropDown) {
// XXX Temporary for Bug 19416
nsIView * lstView;
mDropdownFrame->GetView(mPresContext, &lstView);
nsIView* lstView = mDropdownFrame->GetView(mPresContext);
if (lstView) {
lstView->IgnoreSetPosition(PR_FALSE);
}
@ -2359,8 +2355,7 @@ nsComboboxControlFrame::Destroy(nsIPresContext* aPresContext)
// Get parent view
nsIFrame * listFrame;
if (NS_OK == mListControlFrame->QueryInterface(NS_GET_IID(nsIFrame), (void **)&listFrame)) {
nsIView * view = nsnull;
listFrame->GetView(aPresContext, &view);
nsIView* view = listFrame->GetView(aPresContext);
NS_ASSERTION(view != nsnull, "nsComboboxControlFrame view is null");
if (view) {
view->GetWidget(*getter_AddRefs(widget));

View File

@ -277,9 +277,7 @@ nsFieldSetFrame::Paint(nsIPresContext* aPresContext,
#ifdef DEBUG
if ((NS_FRAME_PAINT_LAYER_DEBUG == aWhichLayer) && GetShowFrameBorders()) {
nsIView* view;
GetView(aPresContext, &view);
if (nsnull != view) {
if (HasView()) {
aRenderingContext.SetColor(NS_RGB(0,0,255));
}
else {

View File

@ -496,8 +496,7 @@ nsFormControlFrame::DidReflow(nsIPresContext* aPresContext,
// The view is created hidden; once we have reflowed it and it has been
// positioned then we show it.
if (NS_FRAME_REFLOW_FINISHED == aStatus) {
nsIView* view = nsnull;
GetView(aPresContext, &view);
nsIView* view = GetView(aPresContext);
if (view) {
nsViewVisibility newVis = GetStyleVisibility()->IsVisible()
? nsViewVisibility_kShow

View File

@ -268,19 +268,17 @@ nsImageControlFrame::Init(nsIPresContext* aPresContext,
aContext, aPrevInFlow);
// create our view, we need a view to grab the mouse
nsIView* view;
GetView(aPresContext, &view);
if (!view) {
nsresult result = nsComponentManager::CreateInstance(kViewCID, nsnull, NS_GET_IID(nsIView), (void **)&view);
if (!HasView()) {
nsIView* view;
nsresult result = CallCreateInstance(kViewCID, &view);
nsCOMPtr<nsIPresShell> presShell;
aPresContext->GetShell(getter_AddRefs(presShell));
nsCOMPtr<nsIViewManager> viewMan;
presShell->GetViewManager(getter_AddRefs(viewMan));
nsIFrame* parWithView;
nsIView *parView;
GetParentWithView(aPresContext, &parWithView);
parWithView->GetView(aPresContext, &parView);
nsIView *parView = parWithView->GetView(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 File

@ -1666,7 +1666,7 @@ nsListControlFrame::CaptureMouseEvents(nsIPresContext* aPresContext, PRBool aGra
{
nsIView* view = nsnull;
if (IsInDropDownMode()) {
GetView(aPresContext, &view);
view = GetView(aPresContext);
} else {
nsIFrame* scrolledFrame = nsnull;
GetScrolledFrame(aPresContext, scrolledFrame);
@ -1678,7 +1678,7 @@ nsListControlFrame::CaptureMouseEvents(nsIPresContext* aPresContext, PRBool aGra
NS_ASSERTION(scrollport, "No scrollport found");
NS_ENSURE_TRUE(scrollport, NS_ERROR_FAILURE);
scrollport->GetView(aPresContext, &view);
view = scrollport->GetView(aPresContext);
}
NS_ASSERTION(view, "no view???");

View File

@ -3108,13 +3108,11 @@ nsTextControlFrame::SetInitialChildList(nsIPresContext* aPresContext,
while(first)
{
nsIScrollableView *scrollView;
nsIView *view;
first->GetView(aPresContext,&view);
nsIView *view = first->GetView(aPresContext);
if (view)
{
view->QueryInterface(NS_GET_IID(nsIScrollableView),(void **)&scrollView);
if (scrollView)
nsIScrollableView *scrollView;
if (NS_SUCCEEDED(CallQueryInterface(view, &scrollView)))
{
mScrollableView = scrollView; // Note: views are not addref'd
mTextSelImpl->SetScrollableView(scrollView);

View File

@ -492,9 +492,8 @@ nsAbsoluteContainingBlock::ReflowAbsoluteFrame(nsIFrame* aDelegat
// Size and position the view and set its opacity, visibility, content
// transparency, and clip
nsIView* kidView;
aKidFrame->GetView(aPresContext, &kidView);
nsContainerFrame::SyncFrameViewAfterReflow(aPresContext, aKidFrame, kidView,
nsContainerFrame::SyncFrameViewAfterReflow(aPresContext, aKidFrame,
aKidFrame->GetView(aPresContext),
&kidDesiredSize.mOverflowArea);
aKidFrame->DidReflow(aPresContext, &kidReflowState, NS_FRAME_REFLOW_FINISHED);

View File

@ -384,10 +384,8 @@ nsBlockFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) con
#ifdef DEBUG_waterson
fprintf(out, " [parent=%p]", mParent);
#endif
nsIView* view;
GetView(aPresContext, &view);
if (nsnull != view) {
fprintf(out, " [view=%p]", NS_STATIC_CAST(void*, view));
if (HasView()) {
fprintf(out, " [view=%p]", NS_STATIC_CAST(void*, GetView(aPresContext)));
}
if (nsnull != mNextSibling) {
fprintf(out, " next=%p", NS_STATIC_CAST(void*, mNextSibling));
@ -2722,10 +2720,9 @@ static void
PlaceFrameView(nsIPresContext* aPresContext,
nsIFrame* aFrame)
{
nsIView* view;
aFrame->GetView(aPresContext, &view);
if (view)
nsContainerFrame::SyncFrameViewAfterReflow(aPresContext, aFrame, view,
if (aFrame->HasView())
nsContainerFrame::SyncFrameViewAfterReflow(aPresContext, aFrame,
aFrame->GetView(aPresContext),
aFrame->GetOverflowAreaProperty(aPresContext));
nsContainerFrame::PositionChildViews(aPresContext, aFrame);
@ -5244,10 +5241,9 @@ nsBlockFrame::ReflowFloater(nsBlockReflowState& aState,
// we've positioned the floater, and shouldn't we be doing the equivalent
// of |::PlaceFrameView| here?
floater->SizeTo(aState.mPresContext, metrics.width, metrics.height);
nsIView* view;
floater->GetView(aState.mPresContext, &view);
if (view) {
nsContainerFrame::SyncFrameViewAfterReflow(aState.mPresContext, floater, view,
if (floater->HasView()) {
nsContainerFrame::SyncFrameViewAfterReflow(aState.mPresContext, floater,
floater->GetView(aState.mPresContext),
&metrics.mOverflowArea,
NS_FRAME_NO_MOVE_VIEW);
}

View File

@ -130,10 +130,8 @@ NS_IMETHODIMP
nsContainerFrame::Destroy(nsIPresContext* aPresContext)
{
// Prevent event dispatch during destruction
nsIView* view;
GetView(aPresContext, &view);
if (nsnull != view) {
view->SetClientData(nsnull);
if (HasView()) {
GetView(aPresContext)->SetClientData(nsnull);
}
// Delete the primary child list
@ -229,10 +227,7 @@ nsContainerFrame::PaintChild(nsIPresContext* aPresContext,
PRUint32 aFlags)
{
NS_ASSERTION(aFrame, "no frame to paint!");
if (!aFrame) return;
nsIView *pView;
aFrame->GetView(aPresContext, &pView);
if (!pView) {
if (!aFrame->HasView()) {
nsRect kidRect;
aFrame->GetRect(kidRect);
nsFrameState state;
@ -439,9 +434,8 @@ void
nsContainerFrame::PositionFrameView(nsIPresContext* aPresContext,
nsIFrame* aKidFrame)
{
nsIView* view;
aKidFrame->GetView(aPresContext, &view);
if (view) {
if (aKidFrame->HasView()) {
nsIView* view = aKidFrame->GetView(aPresContext);
// Position view relative to its parent, not relative to aKidFrame's
// frame which may not have a view
nsIView* parentView;
@ -1061,9 +1055,8 @@ nsContainerFrame::FinishReflowChild(nsIFrame* aKidFrame,
aKidFrame->GetOrigin(curOrigin);
aKidFrame->SetRect(aPresContext, bounds);
nsIView* view;
aKidFrame->GetView(aPresContext, &view);
if (view) {
if (aKidFrame->HasView()) {
nsIView* view = aKidFrame->GetView(aPresContext);
// Make sure the frame's view is properly sized and positioned and has
// things like opacity correct
SyncFrameViewAfterReflow(aPresContext, aKidFrame, view,
@ -1308,10 +1301,8 @@ nsContainerFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent)
#ifdef DEBUG_waterson
fprintf(out, " [parent=%p]", NS_STATIC_CAST(void*, mParent));
#endif
nsIView* view;
GetView(aPresContext, &view);
if (nsnull != view) {
fprintf(out, " [view=%p]", NS_STATIC_CAST(void*, view));
if (HasView()) {
fprintf(out, " [view=%p]", NS_STATIC_CAST(void*, GetView(aPresContext)));
}
if (nsnull != mNextSibling) {
fprintf(out, " next=%p", NS_STATIC_CAST(void*, mNextSibling));

View File

@ -618,8 +618,7 @@ nsFrame::Destroy(nsIPresContext* aPresContext)
// Get the view pointer now before the frame properties disappear
// when we call NotifyDestroyingFrame()
nsIView* view;
GetView(aPresContext, &view);
nsIView* view = GetView(aPresContext);
// XXX Rather than always doing this it would be better if it was part of
// a frame observer mechanism and the pres shell could register as an
@ -1999,14 +1998,10 @@ nsresult nsFrame::GetContentAndOffsetsFromPoint(nsIPresContext* aCX,
// Traverse through children and look for the best one to give this
// to if it fails the getposition call, make it yourself also only
// look at primary list
nsIView *view = nsnull;
nsIFrame *kid = nsnull;
nsIFrame *closestFrame = nsnull;
result = GetClosestViewForFrame(aCX, this, &view);
if (NS_FAILED(result))
return result;
nsIView *view = GetClosestView(aCX);
result = FirstChild(aCX, nsnull, &kid);
@ -2135,12 +2130,7 @@ nsresult nsFrame::GetContentAndOffsetsFromPoint(nsIPresContext* aCX,
// them to be relative to the closest view.
nsPoint newPoint = aPoint;
nsIView *closestView = nsnull;
result = GetClosestViewForFrame(aCX, closestFrame, &closestView);
if (NS_FAILED(result))
return result;
nsIView *closestView = closestFrame->GetClosestView(aCX);
if (closestView && view != closestView)
{
@ -2395,37 +2385,38 @@ NS_IMETHODIMP nsFrame::SetNextInFlow(nsIFrame*)
}
// Associated view object
NS_IMETHODIMP nsFrame::GetView(nsIPresContext* aPresContext, nsIView** aView) const
nsIView*
nsIFrame::GetView(nsIPresContext* aPresContext) const
{
NS_ENSURE_ARG_POINTER(aView);
// Initialize OUT parameter
*aView = nsnull;
// Check the frame state bit and see if the frame has a view
if (mState & NS_FRAME_HAS_VIEW) {
// Check for a property on the frame
nsCOMPtr<nsIPresShell> presShell;
aPresContext->GetShell(getter_AddRefs(presShell));
if (presShell) {
nsCOMPtr<nsIFrameManager> frameManager;
presShell->GetFrameManager(getter_AddRefs(frameManager));
if (frameManager) {
void* value;
if (NS_SUCCEEDED(frameManager->GetFrameProperty((nsIFrame*)this, nsLayoutAtoms::viewProperty, 0, &value))) {
*aView = (nsIView*)value;
NS_ASSERTION(value != 0, "frame state bit was set but frame has no view");
}
}
}
}
if (!(mState & NS_FRAME_HAS_VIEW))
return nsnull;
return NS_OK;
// Check for a property on the frame
nsCOMPtr<nsIPresShell> presShell;
aPresContext->GetShell(getter_AddRefs(presShell));
nsCOMPtr<nsIFrameManager> frameManager;
presShell->GetFrameManager(getter_AddRefs(frameManager));
void* value;
nsresult rv =
frameManager->GetFrameProperty(NS_CONST_CAST(nsIFrame*, this),
nsLayoutAtoms::viewProperty,
0, &value);
NS_ENSURE_SUCCESS(rv, nsnull);
NS_ASSERTION(value, "frame state bit was set but frame has no view");
return NS_STATIC_CAST(nsIView*, value);
}
NS_IMETHODIMP nsFrame::SetView(nsIPresContext* aPresContext, nsIView* aView)
/* virtual */ nsIView*
nsIFrame::GetViewExternal(nsIPresContext* aPresContext) const
{
return GetView(aPresContext);
}
nsresult
nsIFrame::SetView(nsIPresContext* aPresContext, nsIView* aView)
{
if (aView) {
aView->SetClientData(this);
@ -2434,15 +2425,13 @@ NS_IMETHODIMP nsFrame::SetView(nsIPresContext* aPresContext, nsIView* aView)
nsCOMPtr<nsIPresShell> presShell;
aPresContext->GetShell(getter_AddRefs(presShell));
if (presShell) {
nsCOMPtr<nsIFrameManager> frameManager;
presShell->GetFrameManager(getter_AddRefs(frameManager));
if (frameManager) {
frameManager->SetFrameProperty(this, nsLayoutAtoms::viewProperty,
aView, nsnull);
}
}
nsCOMPtr<nsIFrameManager> frameManager;
presShell->GetFrameManager(getter_AddRefs(frameManager));
nsresult rv =
frameManager->SetFrameProperty(this, nsLayoutAtoms::viewProperty,
aView, nsnull);
NS_ENSURE_SUCCESS(rv, rv);
// Set the frame state bit that says the frame has a view
mState |= NS_FRAME_HAS_VIEW;
@ -2479,10 +2468,7 @@ NS_IMETHODIMP nsFrame::GetParentWithView(nsIPresContext* aPresContext,
nsIFrame* parent;
for (parent = mParent; nsnull != parent; parent->GetParent(&parent)) {
nsIView* parView;
parent->GetView(aPresContext, &parView);
if (nsnull != parView) {
if (parent->HasView()) {
break;
}
}
@ -2508,10 +2494,9 @@ NS_IMETHODIMP nsFrame::GetOffsetFromView(nsIPresContext* aPresContext,
frame->GetOrigin(origin);
aOffset += origin;
frame->GetParent(&frame);
if (nsnull != frame) {
frame->GetView(aPresContext, aView);
}
} while ((nsnull != frame) && (nsnull == *aView));
} while (frame && !frame->HasView());
if (frame)
*aView = frame->GetView(aPresContext);
return NS_OK;
}
@ -2541,16 +2526,15 @@ NS_IMETHODIMP nsFrame::GetOriginToViewOffset(nsIPresContext* aPresContext,
nsIView** aView) const
{
NS_ENSURE_ARG_POINTER(aPresContext);
nsresult rv = NS_OK;
aOffset.MoveTo(0,0);
if (aView)
*aView = nsnull;
nsIView *view = nsnull;
nsresult rv = GetView(aPresContext, &view);
if (NS_SUCCEEDED(rv) && view) {
if (HasView()) {
nsIView *view = GetView(aPresContext);
nsIView *parentView = nsnull;
nsPoint offsetToParentView;
rv = GetOffsetFromView(aPresContext, offsetToParentView, &parentView);
@ -2625,6 +2609,19 @@ NS_IMETHODIMP nsFrame::GetOriginToViewOffset(nsIPresContext* aPresContext,
return rv;
}
/* virtual */ PRBool
nsIFrame::AreAncestorViewsVisible(nsIPresContext* aPresContext)
{
for (nsIView* view = GetClosestView(aPresContext);
view; view->GetParent(view)) {
nsViewVisibility vis;
view->GetVisibility(vis);
if (vis == nsViewVisibility_kHide) {
return PR_FALSE;
}
}
return PR_TRUE;
}
NS_IMETHODIMP nsFrame::GetWindow(nsIPresContext* aPresContext,
nsIWidget** aWindow) const
@ -2634,11 +2631,8 @@ NS_IMETHODIMP nsFrame::GetWindow(nsIPresContext* aPresContext,
nsIFrame* frame;
nsIWidget* window = nsnull;
for (frame = (nsIFrame*)this; nsnull != frame; frame->GetParentWithView(aPresContext, &frame)) {
nsIView* view;
frame->GetView(aPresContext, &view);
if (nsnull != view) {
view->GetWidget(window);
if (frame->HasView()) {
frame->GetView(aPresContext)->GetWidget(window);
if (nsnull != window) {
break;
}
@ -2647,22 +2641,12 @@ NS_IMETHODIMP nsFrame::GetWindow(nsIPresContext* aPresContext,
if (nsnull == window) {
// Ask the view manager for the widget
// First we have to get to a frame with a view
nsIView* view;
GetView(aPresContext, &view);
if (nsnull == view) {
GetParentWithView(aPresContext, &frame);
if (nsnull != frame) {
GetView(aPresContext, &view);
}
}
// From the view get the view manager
if (nsnull != view) {
nsCOMPtr<nsIViewManager> vm;
view->GetViewManager(*getter_AddRefs(vm));
vm->GetWidget(&window);
}
NS_NOTREACHED("this shouldn't happen, should it?");
nsCOMPtr<nsIPresShell> shell;
aPresContext->GetShell(getter_AddRefs(shell));
nsCOMPtr<nsIViewManager> vm;
shell->GetViewManager(getter_AddRefs(vm));
vm->GetWidget(&window);
}
NS_POSTCONDITION(nsnull != window, "no window in frame tree");
@ -2723,17 +2707,15 @@ nsFrame::Invalidate(nsIPresContext* aPresContext,
#endif
PRUint32 flags = aImmediate ? NS_VMREFRESH_IMMEDIATE : NS_VMREFRESH_NO_SYNC;
nsIView* view;
GetView(aPresContext, &view);
if (view) {
if (HasView()) {
nsIView* view = GetView(aPresContext);
view->GetViewManager(viewManager);
viewManager->UpdateView(view, damageRect, flags);
} else {
nsRect rect(damageRect);
nsPoint offset;
nsIView *view;
GetOffsetFromView(aPresContext, offset, &view);
NS_ASSERTION(nsnull != view, "no view");
rect += offset;
@ -2843,10 +2825,8 @@ nsFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) const
#ifdef DEBUG_waterson
fprintf(out, " [parent=%p]", NS_STATIC_CAST(void*, mParent));
#endif
nsIView* view;
GetView(aPresContext, &view);
if (view) {
fprintf(out, " [view=%p]", NS_STATIC_CAST(void*, view));
if (HasView()) {
fprintf(out, " [view=%p]", NS_STATIC_CAST(void*, GetView(aPresContext)));
}
fprintf(out, " {%d,%d,%d,%d}", mRect.x, mRect.y, mRect.width, mRect.height);
if (0 != mState) {
@ -3081,11 +3061,9 @@ nsFrame::DumpBaseRegressionData(nsIPresContext* aPresContext, FILE* out, PRInt32
fprintf(out, "<next-sibling va=\"%ld\"/>\n", PRUptrdiff(mNextSibling));
}
nsIView* view;
GetView(aPresContext, &view);
if (view) {
if (HasView()) {
IndentBy(out, aIndent);
fprintf(out, "<view va=\"%ld\">\n", PRUptrdiff(view));
fprintf(out, "<view va=\"%ld\">\n", PRUptrdiff(GetView(aPresContext)));
aIndent++;
// XXX add in code to dump out view state too...
aIndent--;
@ -3490,7 +3468,7 @@ nsFrame::GetNextPrevLineFromeBlockFrame(nsIPresContext* aPresContext,
}
}
if (NS_FAILED(resultFrame->GetView(aPresContext, &view)) || !view)
if (!resultFrame->HasView())
{
resultFrame->GetRect(rect);
if (!rect.width || !rect.height)
@ -4432,36 +4410,13 @@ nsFrame::GetFrameFromDirection(nsIPresContext* aPresContext, nsPeekOffsetStruct
return NS_OK;
}
nsresult nsFrame::GetClosestViewForFrame(nsIPresContext* aPresContext,
nsIFrame *aFrame,
nsIView **aView)
nsIView* nsIFrame::GetClosestView(nsIPresContext* aPresContext) const
{
if (!aView)
return NS_ERROR_NULL_POINTER;
for (const nsIFrame *f = this; f; f->GetParent(NS_CONST_CAST(nsIFrame**, &f)))
if (f->HasView())
return f->GetView(aPresContext);
nsresult result = NS_OK;
*aView = 0;
nsIFrame *parent = aFrame;
while (parent && !*aView)
{
result = parent->GetView(aPresContext, aView);
if (NS_FAILED(result))
return result;
if (!*aView)
{
result = parent->GetParent(&parent);
if (NS_FAILED(result))
return result;
}
}
return result;
return nsnull;
}
@ -4811,23 +4766,12 @@ NS_IMETHODIMP
nsFrame::CaptureMouse(nsIPresContext* aPresContext, PRBool aGrabMouseEvents)
{
// get its view
nsIView* view = nsnull;
nsIFrame *parent;//might be THIS frame thats ok
GetView(aPresContext, & view);
if (!view)
{
nsresult rv = GetParentWithView(aPresContext, &parent);
if (NS_FAILED(rv))
return rv;
if (!parent)
return NS_ERROR_FAILURE;
parent->GetView(aPresContext, &view);
}
nsIView* view = GetClosestView(aPresContext);
nsCOMPtr<nsIViewManager> viewMan;
PRBool result;
if (view) {
nsCOMPtr<nsIViewManager> viewMan;
view->GetViewManager(*getter_AddRefs(viewMan));
if (viewMan) {
if (aGrabMouseEvents) {
@ -4845,22 +4789,10 @@ PRBool
nsFrame::IsMouseCaptured(nsIPresContext* aPresContext)
{
// get its view
nsIView* view = nsnull;
GetView(aPresContext, &view);
if (!view)
{
nsIFrame *parent;//might be THIS frame thats ok
nsresult rv = GetParentWithView(aPresContext, &parent);
if (NS_FAILED(rv))
return rv;
if (!parent)
return NS_ERROR_FAILURE;
parent->GetView(aPresContext, &view);
}
nsCOMPtr<nsIViewManager> viewMan;
nsIView* view = GetClosestView(aPresContext);
if (view) {
nsCOMPtr<nsIViewManager> viewMan;
view->GetViewManager(*getter_AddRefs(viewMan));
if (viewMan) {

View File

@ -239,8 +239,6 @@ public:
NS_IMETHOD SetPrevInFlow(nsIFrame*);
NS_IMETHOD GetNextInFlow(nsIFrame** aNextInFlow) const;
NS_IMETHOD SetNextInFlow(nsIFrame*);
NS_IMETHOD GetView(nsIPresContext* aPresContext, nsIView** aView) const;
NS_IMETHOD SetView(nsIPresContext* aPresContext, nsIView* aView);
NS_IMETHOD GetParentWithView(nsIPresContext* aPresContext, nsIFrame** aParent) const;
NS_IMETHOD GetOffsetFromView(nsIPresContext* aPresContext, nsPoint& aOffset, nsIView** aView) const;
NS_IMETHOD GetOriginToViewOffset(nsIPresContext *aPresContext, nsPoint& aOffset, nsIView **aView) const;
@ -354,10 +352,6 @@ public:
PRBool IsFrameTreeTooDeep(const nsHTMLReflowState& aReflowState,
nsHTMLReflowMetrics& aMetrics);
virtual nsresult GetClosestViewForFrame(nsIPresContext* aPresContext,
nsIFrame *aFrame,
nsIView **aView);
static nsresult CreateAndPostReflowCommand(nsIPresShell* aPresShell,
nsIFrame* aTargetFrame,
nsReflowType aReflowType,

View File

@ -368,9 +368,7 @@ nsHTMLFrameOuterFrame::Init(nsIPresContext* aPresContext,
// (e.g., the canvas) when it really needs to have the OuterFrame's
// view as its parent. So, create the OuterFrame's view right away
// if we need it, and the InnerFrame's view will get it as the parent.
nsIView* view = nsnull;
GetView(aPresContext, &view);
if (!view) {
if (!HasView()) {
// To properly initialize the view we need to know the frame for the content
// that is the parent of content for this frame. This might not be our actual
// frame parent if we are out of flow (e.g., positioned) so our parent frame
@ -399,8 +397,8 @@ nsHTMLFrameOuterFrame::Init(nsIPresContext* aPresContext,
}
nsHTMLContainerFrame::CreateViewForFrame(aPresContext,this,mStyleContext,contentParent,PR_TRUE);
GetView(aPresContext, &view);
}
nsIView* view = GetView(aPresContext);
if (aParent->GetStyleDisplay()->mDisplay == NS_STYLE_DISPLAY_DECK) {
nsCOMPtr<nsIWidget> widget;
@ -1027,8 +1025,7 @@ nsHTMLFrameInnerFrame::DidReflow(nsIPresContext* aPresContext,
// The view is created hidden; once we have reflowed it and it has been
// positioned then we show it.
if (NS_FRAME_REFLOW_FINISHED == aStatus) {
nsIView* view = nsnull;
GetView(aPresContext, &view);
nsIView* view = GetView(aPresContext);
if (view) {
nsViewVisibility newVis = GetStyleVisibility()->IsVisible()
? nsViewVisibility_kShow

View File

@ -349,9 +349,8 @@ nsHTMLFramesetFrame::Init(nsIPresContext* aPresContext,
presShell->GetViewManager(getter_AddRefs(viewMan));
nsIFrame* parWithView;
nsIView *parView;
GetParentWithView(aPresContext, &parWithView);
parWithView->GetView(aPresContext, &parView);
nsIView *parView = parWithView->GetView(aPresContext);
nsRect boundBox(0, 0, 0, 0);
result = view->Init(viewMan, boundBox, parView);
// XXX Put it last in document order until we can do better
@ -1457,8 +1456,7 @@ nsHTMLFramesetFrame::StartMouseDrag(nsIPresContext* aPresContext,
IndexOf(aBorder, index);
NS_ASSERTION((nsnull != aBorder) && (index >= 0), "invalid dragger");
#endif
nsIView* view;
GetView(aPresContext, &view);
nsIView* view = GetView(aPresContext);
if (view) {
nsCOMPtr<nsIViewManager> viewMan;
view->GetViewManager(*getter_AddRefs(viewMan));
@ -1572,8 +1570,7 @@ nsHTMLFramesetFrame::MouseDrag(nsIPresContext* aPresContext,
void
nsHTMLFramesetFrame::EndMouseDrag(nsIPresContext* aPresContext)
{
nsIView* view;
GetView(aPresContext, &view);
nsIView* view = GetView(aPresContext);
if (view) {
nsCOMPtr<nsIViewManager> viewMan;
view->GetViewManager(*getter_AddRefs(viewMan));

View File

@ -615,20 +615,14 @@ nsGfxScrollFrame::GetContentAndOffsetsFromPoint(nsIPresContext* aCX,
nsIFrame* frame = nsnull;
mInner->mScrollAreaBox->GetFrame(&frame);
nsIView *view;
nsPoint point(aPoint);
nsPoint currentPoint;
//we need to translate the coordinates to the inner
nsresult result = GetClosestViewForFrame(aCX, this, &view);
if (NS_FAILED(result))
return result;
nsIView *view = GetClosestView(aCX);
if (!view)
return NS_ERROR_FAILURE;
nsIView *innerView;
result = GetClosestViewForFrame(aCX, frame, &innerView);
if (NS_FAILED(result))
return result;
nsIView *innerView = GetClosestView(aCX);
while (view != innerView && innerView)
{
innerView->GetPosition(&currentPoint.x, &currentPoint.y);
@ -1079,14 +1073,13 @@ nsGfxScrollFrameInner::CurPosAttributeChanged(nsIPresContext* aPresContext,
nsIScrollableView*
nsGfxScrollFrameInner::GetScrollableView(nsIPresContext* aPresContext)
{
nsIView* view;
nsIFrame* frame = nsnull;
mScrollAreaBox->GetFrame(&frame);
frame->GetView(aPresContext, &view);
nsIView* view = frame->GetView(aPresContext);
if (!view) return nsnull;
nsIScrollableView* scrollingView;
nsresult result = view->QueryInterface(NS_GET_IID(nsIScrollableView), (void**)&scrollingView);
nsresult result = CallQueryInterface(view, &scrollingView);
NS_ASSERTION(NS_SUCCEEDED(result), "assertion gfx scrollframe does not contain a scrollframe");
return scrollingView;
}
@ -1660,8 +1653,7 @@ nsGfxScrollFrameInner::GetScrolledSize(nsIPresContext* aPresContext,
mScrollAreaBox->GetChildBox(&child);
nsIFrame* frame;
child->GetFrame(&frame);
nsIView* view;
frame->GetView(aPresContext, &view);
nsIView* view = frame->GetView(aPresContext);
NS_ASSERTION(view,"Scrolled frame must have a view!!!");
nsRect rect(0,0,0,0);

View File

@ -352,14 +352,13 @@ ReparentFrameViewTo(nsIPresContext* aPresContext,
nsIView* aNewParentView,
nsIView* aOldParentView)
{
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) {
if (aFrame->HasView()) {
nsIView* view = aFrame->GetView(aPresContext);
// Verify that the current parent view is what we think it is
//nsIView* parentView;
//NS_ASSERTION(parentView == aOldParentView, "unexpected parent view");
@ -392,26 +391,6 @@ ReparentFrameViewTo(nsIPresContext* aPresContext,
return NS_OK;
}
// Helper function that returns the nearest view to this frame. Checks
// this frame, its parent frame, its parent frame, ...
static nsIView*
GetClosestViewFor(nsIPresContext* aPresContext, nsIFrame* aFrame)
{
NS_PRECONDITION(aFrame, "null frame pointer");
nsIView* view;
do {
aFrame->GetView(aPresContext, &view);
if (view) {
break;
}
aFrame->GetParent(&aFrame);
} while (aFrame);
NS_POSTCONDITION(view, "no containing view");
return view;
}
nsresult
nsHTMLContainerFrame::ReparentFrameView(nsIPresContext* aPresContext,
nsIFrame* aChildFrame,
@ -423,14 +402,9 @@ nsHTMLContainerFrame::ReparentFrameView(nsIPresContext* aPresContext,
NS_PRECONDITION(aNewParentFrame, "null new parent frame pointer");
NS_PRECONDITION(aOldParentFrame != aNewParentFrame, "same old and new parent frame");
nsIView* childView;
nsIView* oldParentView;
nsIView* newParentView;
// This code is called often and we need it to be as fast as possible, so
// see if we can trivially detect that no work needs to be done
aChildFrame->GetView(aPresContext, &childView);
if (!childView) {
if (!aChildFrame->HasView()) {
// Child frame doesn't have a view. See if it has any child frames
nsIFrame* firstChild;
aChildFrame->FirstChild(aPresContext, nsnull, &firstChild);
@ -440,10 +414,8 @@ nsHTMLContainerFrame::ReparentFrameView(nsIPresContext* aPresContext,
}
// See if either the old parent frame or the new parent frame have a view
aOldParentFrame->GetView(aPresContext, &oldParentView);
aNewParentFrame->GetView(aPresContext, &newParentView);
if (!oldParentView && !newParentView) {
while (!aOldParentFrame->HasView() && !aNewParentFrame->HasView()) {
// Walk up both the old parent frame and the new parent frame nodes
// stopping when we either find a common parent or views for one
// or both of the frames.
@ -451,26 +423,19 @@ nsHTMLContainerFrame::ReparentFrameView(nsIPresContext* aPresContext,
// This works well in the common case where we push/pull and the old parent
// frame and the new parent frame are part of the same flow. They will
// typically be the same distance (height wise) from the
do {
aOldParentFrame->GetParent(&aOldParentFrame);
aNewParentFrame->GetParent(&aNewParentFrame);
// We should never walk all the way to the root frame without finding
// a view
NS_ASSERTION(aOldParentFrame && aNewParentFrame, "didn't find view");
aOldParentFrame->GetParent(&aOldParentFrame);
aNewParentFrame->GetParent(&aNewParentFrame);
// We should never walk all the way to the root frame without finding
// a view
NS_ASSERTION(aOldParentFrame && aNewParentFrame, "didn't find view");
// See if we reached a common parent
if (aOldParentFrame == aNewParentFrame) {
break;
}
// Get the views
aOldParentFrame->GetView(aPresContext, &oldParentView);
aNewParentFrame->GetView(aPresContext, &newParentView);
} while (!(oldParentView || newParentView));
// See if we reached a common ancestor
if (aOldParentFrame == aNewParentFrame) {
break;
}
}
// See if we found a common parent frame
if (aOldParentFrame == aNewParentFrame) {
// We found a common parent and there are no views between the old parent
@ -480,15 +445,10 @@ nsHTMLContainerFrame::ReparentFrameView(nsIPresContext* aPresContext,
return NS_OK;
}
// We found views for one or both of the parent frames before we found a
// common parent
NS_ASSERTION(oldParentView || newParentView, "internal error");
if (!oldParentView) {
oldParentView = GetClosestViewFor(aPresContext, aOldParentFrame);
}
if (!newParentView) {
newParentView = GetClosestViewFor(aPresContext, aNewParentFrame);
}
// We found views for one or both of the ancestor frames before we
// found a common ancestor.
nsIView* oldParentView = aOldParentFrame->GetClosestView(aPresContext);
nsIView* newParentView = aNewParentFrame->GetClosestView(aPresContext);
// See if the old parent frame and the new parent frame are in the
// same view sub-hierarchy. If they are then we don't have to do
@ -516,14 +476,8 @@ nsHTMLContainerFrame::ReparentFrameViewList(nsIPresContext* aPresContext,
NS_PRECONDITION(aNewParentFrame, "null new parent frame pointer");
NS_PRECONDITION(aOldParentFrame != aNewParentFrame, "same old and new parent frame");
nsIView* oldParentView;
nsIView* newParentView;
// See if either the old parent frame or the new parent frame have a view
aOldParentFrame->GetView(aPresContext, &oldParentView);
aNewParentFrame->GetView(aPresContext, &newParentView);
if (!oldParentView && !newParentView) {
while (!aOldParentFrame->HasView() && !aNewParentFrame->HasView()) {
// Walk up both the old parent frame and the new parent frame nodes
// stopping when we either find a common parent or views for one
// or both of the frames.
@ -531,23 +485,17 @@ nsHTMLContainerFrame::ReparentFrameViewList(nsIPresContext* aPresContext,
// This works well in the common case where we push/pull and the old parent
// frame and the new parent frame are part of the same flow. They will
// typically be the same distance (height wise) from the
do {
aOldParentFrame->GetParent(&aOldParentFrame);
aNewParentFrame->GetParent(&aNewParentFrame);
// We should never walk all the way to the root frame without finding
// a view
NS_ASSERTION(aOldParentFrame && aNewParentFrame, "didn't find view");
aOldParentFrame->GetParent(&aOldParentFrame);
aNewParentFrame->GetParent(&aNewParentFrame);
// We should never walk all the way to the root frame without finding
// a view
NS_ASSERTION(aOldParentFrame && aNewParentFrame, "didn't find view");
// See if we reached a common parent
if (aOldParentFrame == aNewParentFrame) {
break;
}
// Get the views
aOldParentFrame->GetView(aPresContext, &oldParentView);
aNewParentFrame->GetView(aPresContext, &newParentView);
} while (!(oldParentView || newParentView));
// See if we reached a common ancestor
if (aOldParentFrame == aNewParentFrame) {
break;
}
}
@ -560,15 +508,10 @@ nsHTMLContainerFrame::ReparentFrameViewList(nsIPresContext* aPresContext,
return NS_OK;
}
// We found views for one or both of the parent frames before we found a
// common parent
NS_ASSERTION(oldParentView || newParentView, "internal error");
if (!oldParentView) {
oldParentView = GetClosestViewFor(aPresContext, aOldParentFrame);
}
if (!newParentView) {
newParentView = GetClosestViewFor(aPresContext, aNewParentFrame);
}
// We found views for one or both of the ancestor frames before we
// found a common ancestor.
nsIView* oldParentView = aOldParentFrame->GetClosestView(aPresContext);
nsIView* newParentView = aNewParentFrame->GetClosestView(aPresContext);
// See if the old parent frame and the new parent frame are in the
// same view sub-hierarchy. If they are then we don't have to do
@ -594,9 +537,7 @@ nsHTMLContainerFrame::CreateViewForFrame(nsIPresContext* aPresContext,
nsIFrame* aContentParentFrame,
PRBool aForce)
{
nsIView* view;
aFrame->GetView(aPresContext, &view);
if (nsnull != view) {
if (aFrame->HasView()) {
return NS_OK;
}
@ -611,12 +552,12 @@ nsHTMLContainerFrame::CreateViewForFrame(nsIPresContext* aPresContext,
aFrame->GetParentWithView(aPresContext, &parent);
NS_ASSERTION(parent, "GetParentWithView failed");
nsIView* parentView = nsnull;
parent->GetView(aPresContext, &parentView);
nsIView* parentView = parent->GetView(aPresContext);
NS_ASSERTION(parentView, "no parent with view");
// Create a view
static NS_DEFINE_CID(kViewCID, NS_VIEW_CID);
nsIView* view;
nsresult result = CallCreateInstance(kViewCID, &view);
if (NS_FAILED(result)) {
return result;
@ -643,23 +584,7 @@ nsHTMLContainerFrame::CreateViewForFrame(nsIPresContext* aPresContext,
viewManager->InsertChild(parentView, view, nsnull, PR_TRUE);
if (nsnull != aContentParentFrame) {
// If, for some reason, GetView below fails to initialize zParentView,
// then ensure that we completely bypass InsertZPlaceholder below.
// The effect will be as if we never knew about aContentParentFrame
// in the first place, so at least this code won't be doing any damage.
nsIView* zParentView = parentView;
aContentParentFrame->GetView(aPresContext, &zParentView);
if (nsnull == zParentView) {
nsIFrame* zParentFrame = nsnull;
aContentParentFrame->GetParentWithView(aPresContext, &zParentFrame);
NS_ASSERTION(zParentFrame, "GetParentWithView failed");
zParentFrame->GetView(aPresContext, &zParentView);
NS_ASSERTION(zParentView, "no parent with view");
}
nsIView* zParentView = aContentParentFrame->GetClosestView(aPresContext);
if (zParentView != parentView) {
viewManager->InsertZPlaceholder(zParentView, view, nsnull, PR_TRUE);
}

View File

@ -448,11 +448,10 @@ CanvasFrame::Paint(nsIPresContext* aPresContext,
nscoord width, height;
scrollableFrame->GetClipSize(aPresContext, &width, &height);
}
nsIView* parentView;
parentFrame->GetView(aPresContext, &parentView);
nsIView* parentView = parentFrame->GetView(aPresContext);
nsIScrollableView* scrollableView;
if (NS_SUCCEEDED(parentView->QueryInterface(NS_GET_IID(nsIScrollableView), (void**)&scrollableView))) {
if (NS_SUCCEEDED(CallQueryInterface(parentView, &scrollableView))) {
nscoord width, height;
scrollableView->GetContainerSize(&width, &height);
const nsIView* clippedView;

View File

@ -991,14 +991,21 @@ public:
/**
* Accessor functions to get/set the associated view object
*
* GetView returns non-null if and only if |HasView| returns true.
*/
NS_IMETHOD GetView(nsIPresContext* aPresContext,
nsIView** aView) const = 0; // may be null
NS_IMETHOD SetView(nsIPresContext* aPresContext,
nsIView* aView) = 0;
PRBool HasView() const { return mState & NS_FRAME_HAS_VIEW; }
nsIView* GetView(nsIPresContext* aPresContext) const;
virtual nsIView* GetViewExternal(nsIPresContext* aPresContext) const;
nsresult SetView(nsIPresContext* aPresContext, nsIView* aView);
/**
* Find the first geometric parent that has a view
* Find the closest view (on |this| or an ancestor).
*/
nsIView* GetClosestView(nsIPresContext* aPresContext) const;
/**
* Find the closest ancestor (excluding |this| !) that has a view
*/
NS_IMETHOD GetParentWithView(nsIPresContext* aPresContext,
nsIFrame** aParent) const = 0;
@ -1023,6 +1030,12 @@ public:
nsPoint& aOffset,
nsIView** aView) const = 0;
/**
* Returns true if and only if all views, from |GetClosestView| up to
* the top of the view hierarchy are visible.
*/
virtual PRBool AreAncestorViewsVisible(nsIPresContext* aPresContext);
/**
* Returns the window that contains this frame. If this frame has a
* view and the view has a window, then this frames window is

View File

@ -1571,10 +1571,9 @@ nsImageFrame::TranslateEventCoords(nsIPresContext* aPresContext,
// If we have a view then the event coordinates are already relative
// to this frame; otherwise we have to adjust the coordinates
// appropriately.
nsIView* view;
GetView(aPresContext, &view);
if (nsnull == view) {
if (!HasView()) {
nsPoint offset;
nsIView *view;
GetOffsetFromView(aPresContext, offset, &view);
if (nsnull != view) {
x -= offset.x;
@ -1820,10 +1819,8 @@ nsImageFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) con
#ifdef DEBUG_waterson
fprintf(out, " [parent=%p]", mParent);
#endif
nsIView* view;
GetView(aPresContext, &view);
if (view) {
fprintf(out, " [view=%p]", view);
if (HasView()) {
fprintf(out, " [view=%p]", GetView(aPresContext));
}
fprintf(out, " {%d,%d,%d,%d}", mRect.x, mRect.y, mRect.width,
mRect.height);

View File

@ -1194,20 +1194,18 @@ nsImageMap::Invalidate(nsIPresContext* aPresContext, nsIFrame* aFrame, nsRect& a
nsIView* view;
nsRect damageRect(aRect);
aFrame->GetView(aPresContext, &view);
if (view) {
view->GetViewManager(*getter_AddRefs(viewManager));
viewManager->UpdateView(view, damageRect, flags);
if (aFrame->HasView()) {
view = aFrame->GetView(aPresContext);
}
else {
nsPoint offset;
nsPoint offset;
aFrame->GetOffsetFromView(aPresContext, offset, &view);
NS_ASSERTION(nsnull != view, "no view");
damageRect += offset;
view->GetViewManager(*getter_AddRefs(viewManager));
viewManager->UpdateView(view, damageRect, flags);
}
view->GetViewManager(*getter_AddRefs(viewManager));
viewManager->UpdateView(view, damageRect, flags);
return NS_OK;
}

View File

@ -1228,9 +1228,8 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame,
// Size the frame and size its view (if it has one)
aFrame->SizeTo(mPresContext, metrics.width, metrics.height);
nsIView* view;
aFrame->GetView(mPresContext, &view);
if (view) {
if (aFrame->HasView()) {
nsIView* view = aFrame->GetView(mPresContext);
nsIViewManager *vm;
view->GetViewManager(vm);

View File

@ -797,10 +797,9 @@ nsObjectFrame::CreateWidget(nsIPresContext* aPresContext,
nsRect boundBox(0, 0, aWidth, aHeight);
nsIFrame* parWithView;
nsIView *parView;
GetParentWithView(aPresContext, &parWithView);
parWithView->GetView(aPresContext, &parView);
nsIView *parView = parWithView->GetView(aPresContext);
if (NS_SUCCEEDED(parView->GetViewManager(*getter_AddRefs(viewMan))))
{
@ -1533,9 +1532,8 @@ nsObjectFrame::DidReflow(nsIPresContext* aPresContext,
PRBool bHidden = IsHidden();
nsIView* view = nsnull;
GetView(aPresContext, &view);
if (view) {
if (HasView()) {
nsIView* view = GetView(aPresContext);
nsCOMPtr<nsIViewManager> vm;
view->GetViewManager(*getter_AddRefs(vm));
if (vm)
@ -2427,10 +2425,9 @@ NS_IMETHODIMP nsPluginInstanceOwner::InvalidateRect(nsPluginRect *invalidRect)
if(invalidRect)
{
//no reference count on view
nsIView* view;
rv = mOwner->GetView(mContext, &view);
nsIView* view = mOwner->GetView(mContext);
if((rv == NS_OK) && view)
if (view)
{
float ptot;
mContext->GetPixelsToTwips(&ptot);
@ -2462,11 +2459,11 @@ NS_IMETHODIMP nsPluginInstanceOwner::InvalidateRegion(nsPluginRegion invalidRegi
NS_IMETHODIMP nsPluginInstanceOwner::ForceRedraw()
{
nsresult rv = NS_OK;
//no reference count on view
nsIView* view;
nsresult rv = mOwner->GetView(mContext, &view);
nsIView* view = mOwner->GetView(mContext);
if((rv == NS_OK) && view)
if (view)
{
nsIViewManager* manager;
rv = view->GetViewManager(manager);
@ -3740,7 +3737,7 @@ nsPluginInstanceOwner::Destroy()
nsIView* curView = nsnull;
if (parentWithView)
parentWithView->GetView(mContext, &curView);
curView = parentWithView->GetView(mContext);
while (curView)
{
nsIScrollableView* scrollingView;
@ -3967,7 +3964,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::Init(nsIPresContext* aPresContext, nsObject
mOwner->GetParentWithView(mContext, &parentWithView);
nsIView* curView = nsnull;
if (parentWithView)
parentWithView->GetView(mContext, &curView);
curView = parentWithView->GetView(mContext);
while (curView)
{
nsIScrollableView* scrollingView;
@ -4020,7 +4017,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void)
{
// Create view if necessary
mOwner->GetView(mContext, &view);
view = mOwner->GetView(mContext);
if (!view || !mWidget)
{
@ -4036,7 +4033,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void)
windowless);
if (NS_OK == rv)
{
mOwner->GetView(mContext, &view);
view = mOwner->GetView(mContext);
if (view)
{
view->GetWidget(*getter_AddRefs(mWidget));
@ -4109,9 +4106,8 @@ aContainerWidget)
aAbs.x = 0;
aAbs.y = 0;
nsIView *view = nsnull;
// See if this frame has a view
aFrame->GetView(aPresContext, &view);
nsIView *view = aFrame->GetView(aPresContext);
if (nsnull == view) {
// Calculate frames offset from its nearest view
aFrame->GetOffsetFromView(aPresContext,
@ -4167,8 +4163,7 @@ nsPluginPort* nsPluginInstanceOwner::FixUpPluginWindow(PRInt32 inPaintState)
return nsnull;
// first, check our view for CSS visibility style
nsIView *view;
mOwner->GetView(mContext, &view);
nsIView *view = mOwner->GetView(mContext);
nsViewVisibility vis;
view->GetVisibility(vis);
PRBool isVisible = (vis == nsViewVisibility_kShow) ? PR_TRUE : PR_FALSE;
@ -4226,12 +4221,11 @@ nsPluginPort* nsPluginInstanceOwner::FixUpPluginWindow(PRInt32 inPaintState)
void nsPluginInstanceOwner::Composite()
{
//no reference count on view
nsIView* view;
nsresult rv = mOwner->GetView(mContext, &view);
nsIView* view = mOwner->GetView(mContext);
if (NS_SUCCEEDED(rv) && view) {
if (view) {
nsIViewManager* manager;
rv = view->GetViewManager(manager);
nsresult rv = view->GetViewManager(manager);
//set flags to not do a synchronous update, force update does the redraw
if (NS_SUCCEEDED(rv) && manager) {

View File

@ -136,8 +136,7 @@ NS_IMETHODIMP nsPageContentFrame::Reflow(nsIPresContext* aPresContext,
nsRect r;
frame->GetRect(r);
printf("PCF: Area Frame %p Bounds: %5d,%5d,%5d,%5d\n", frame, r.x, r.y, r.width, r.height);
nsIView* view;
frame->GetView(aPresContext, &view);
nsIView* view = frame->GetView(aPresContext);
if (view) {
view->GetBounds(r);
printf("PCF: Area Frame View Bounds: %5d,%5d,%5d,%5d\n", r.x, r.y, r.width, r.height);

View File

@ -125,8 +125,7 @@ nsPageFrame::SetInitialChildList(nsIPresContext* aPresContext,
nsIAtom* aListName,
nsIFrame* aChildList)
{
nsIView * view;
aChildList->GetView(aPresContext, &view);
nsIView* view = aChildList->GetView(aPresContext);
if (view != nsnull && mDoCreateWidget) {
nscoord dx, dy;
nsCOMPtr<nsIWidget> widget;
@ -228,8 +227,7 @@ NS_IMETHODIMP nsPageFrame::Reflow(nsIPresContext* aPresContext,
aDesiredSize.height = aReflowState.availableHeight;
}
nsIView * view;
frame->GetView(aPresContext, &view);
nsIView* view = frame->GetView(aPresContext);
if (view) {
nsCOMPtr<nsIViewManager> vm;
view->GetViewManager(*getter_AddRefs(vm));

View File

@ -141,10 +141,8 @@ nsPlaceholderFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aInden
#ifdef DEBUG_waterson
fprintf(out, " [parent=%p]", NS_STATIC_CAST(void*, mParent));
#endif
nsIView* view;
GetView(aPresContext, &view);
if (nsnull != view) {
fprintf(out, " [view=%p]", (void*)view);
if (HasView()) {
fprintf(out, " [view=%p]", (void*)GetView(aPresContext));
}
fprintf(out, " {%d,%d,%d,%d}", mRect.x, mRect.y, mRect.width, mRect.height);
if (0 != mState) {

View File

@ -1175,7 +1175,6 @@ nsSelection::GetGlobalViewOffsetsFromFrame(nsIPresContext *aPresContext, nsIFram
nsresult result;
nsIFrame *frame = aFrame;
nsIView *view;
while (frame)
{
@ -1185,12 +1184,7 @@ nsSelection::GetGlobalViewOffsetsFromFrame(nsIPresContext *aPresContext, nsIFram
return result;
if (frame) {
view = 0;
result = frame->GetView(aPresContext, &view);
if (NS_FAILED(result))
return result;
nsIView *view = frame->GetView(aPresContext);
if (view)
{
@ -5890,53 +5884,14 @@ nsTypedSelection::DoAutoScrollView(nsIPresContext *aPresContext, nsIView *aView,
nsresult
nsTypedSelection::DoAutoScroll(nsIPresContext *aPresContext, nsIFrame *aFrame, nsPoint& aPoint)
{
nsresult result;
if (!aPresContext || !aFrame)
return NS_ERROR_NULL_POINTER;
//
// Find the closest view to the frame!
//
nsIView *closestView = 0;
result = aFrame->GetView(aPresContext, &closestView);
if (NS_FAILED(result))
return result;
nsIView *closestView = aFrame->GetClosestView(aPresContext);
if (!closestView)
{
//
// aFrame doesn't contain a view, so walk aFrame's parent hierarchy
// till you find a parent with a view.
//
nsIFrame *parentFrame = aFrame;
result = aFrame->GetParent(&parentFrame);
if (NS_FAILED(result))
return result;
if (!parentFrame)
return NS_ERROR_FAILURE;
while (!closestView && parentFrame)
{
result = parentFrame->GetView(aPresContext, &closestView);
if (NS_FAILED(result))
return result;
if (!closestView)
result = parentFrame->GetParent(&parentFrame);
}
if (!closestView)
return NS_ERROR_FAILURE;
}
return NS_ERROR_FAILURE;
return DoAutoScrollView(aPresContext, closestView, aPoint, PR_TRUE);
}
@ -7331,13 +7286,7 @@ nsTypedSelection::GetSelectionRegionRectAndScrollableView(SelectionRegion aRegio
if (!parentWithView)
return NS_ERROR_FAILURE;
result = parentWithView->GetView(presContext, &view);
if (NS_FAILED(result))
return result;
if (!view)
return NS_ERROR_FAILURE;
view = parentWithView->GetView(presContext);
result = GetClosestScrollableView(view, aScrollableView);

View File

@ -674,8 +674,7 @@ nsSimplePageSequenceFrame::StartPrint(nsIPresContext* aPresContext,
#if defined(DEBUG_rods) || defined(DEBUG_dcone)
{
nsIView * seqView;
GetView(aPresContext, &seqView);
nsIView* seqView = GetView(aPresContext);
nsRect rect;
GetRect(rect);
PR_PL(("Seq Frame: %p - [%5d,%5d,%5d,%5d] ", this, rect.x, rect.y, rect.width, rect.height));
@ -691,8 +690,7 @@ nsSimplePageSequenceFrame::StartPrint(nsIPresContext* aPresContext,
{
PRInt32 pageNum = 1;
for (nsIFrame* page = mFrames.FirstChild(); nsnull != page; page->GetNextSibling(&page)) {
nsIView* view;
page->GetView(aPresContext, &view);
nsIView* view = page->GetView(aPresContext);
NS_ASSERTION(nsnull != view, "no page view");
nsRect rect;
page->GetRect(rect);
@ -720,8 +718,7 @@ nsSimplePageSequenceFrame::StartPrint(nsIPresContext* aPresContext,
nscoord y = 0;//mMargin.top;
for (nsIFrame* page = mFrames.FirstChild(); nsnull != page; page->GetNextSibling(&page)) {
nsIView* view = nsnull;
page->GetView(aPresContext, &view);
nsIView* view = page->GetView(aPresContext);
NS_ASSERTION(nsnull != view, "no page view");
nsCOMPtr<nsIViewManager> vm;
@ -889,7 +886,7 @@ nsSimplePageSequenceFrame::PrintNextPage(nsIPresContext* aPresContext)
nsIFrame* childFrame = mFrames.FirstChild();
nsIFrame* conFrame;
childFrame->FirstChild(aPresContext, nsnull, &conFrame);
conFrame->GetView(aPresContext, &containerView);
containerView = conFrame->GetView(aPresContext);
NS_ASSERTION(containerView != nsnull, "Container view can't be null!");
containerView->GetBounds(containerRect);
containerRect.y -= mYSelOffset;
@ -922,8 +919,7 @@ nsSimplePageSequenceFrame::PrintNextPage(nsIPresContext* aPresContext)
}
// Print the page
nsIView* view;
mCurrentPageFrame->GetView(aPresContext, &view);
nsIView* view = mCurrentPageFrame->GetView(aPresContext);
NS_ASSERTION(nsnull != view, "no page view");

View File

@ -6009,10 +6009,8 @@ nsTextFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) cons
#ifdef DEBUG_waterson
fprintf(out, " [parent=%p]", mParent);
#endif
nsIView* view;
GetView(aPresContext, &view);
if (nsnull != view) {
fprintf(out, " [view=%p]", NS_STATIC_CAST(void*, view));
if (HasView()) {
fprintf(out, " [view=%p]", NS_STATIC_CAST(void*, GetView(aPresContext)));
}
PRInt32 totalContentLength;

View File

@ -492,9 +492,8 @@ nsAbsoluteContainingBlock::ReflowAbsoluteFrame(nsIFrame* aDelegat
// Size and position the view and set its opacity, visibility, content
// transparency, and clip
nsIView* kidView;
aKidFrame->GetView(aPresContext, &kidView);
nsContainerFrame::SyncFrameViewAfterReflow(aPresContext, aKidFrame, kidView,
nsContainerFrame::SyncFrameViewAfterReflow(aPresContext, aKidFrame,
aKidFrame->GetView(aPresContext),
&kidDesiredSize.mOverflowArea);
aKidFrame->DidReflow(aPresContext, &kidReflowState, NS_FRAME_REFLOW_FINISHED);

View File

@ -384,10 +384,8 @@ nsBlockFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) con
#ifdef DEBUG_waterson
fprintf(out, " [parent=%p]", mParent);
#endif
nsIView* view;
GetView(aPresContext, &view);
if (nsnull != view) {
fprintf(out, " [view=%p]", NS_STATIC_CAST(void*, view));
if (HasView()) {
fprintf(out, " [view=%p]", NS_STATIC_CAST(void*, GetView(aPresContext)));
}
if (nsnull != mNextSibling) {
fprintf(out, " next=%p", NS_STATIC_CAST(void*, mNextSibling));
@ -2722,10 +2720,9 @@ static void
PlaceFrameView(nsIPresContext* aPresContext,
nsIFrame* aFrame)
{
nsIView* view;
aFrame->GetView(aPresContext, &view);
if (view)
nsContainerFrame::SyncFrameViewAfterReflow(aPresContext, aFrame, view,
if (aFrame->HasView())
nsContainerFrame::SyncFrameViewAfterReflow(aPresContext, aFrame,
aFrame->GetView(aPresContext),
aFrame->GetOverflowAreaProperty(aPresContext));
nsContainerFrame::PositionChildViews(aPresContext, aFrame);
@ -5244,10 +5241,9 @@ nsBlockFrame::ReflowFloater(nsBlockReflowState& aState,
// we've positioned the floater, and shouldn't we be doing the equivalent
// of |::PlaceFrameView| here?
floater->SizeTo(aState.mPresContext, metrics.width, metrics.height);
nsIView* view;
floater->GetView(aState.mPresContext, &view);
if (view) {
nsContainerFrame::SyncFrameViewAfterReflow(aState.mPresContext, floater, view,
if (floater->HasView()) {
nsContainerFrame::SyncFrameViewAfterReflow(aState.mPresContext, floater,
floater->GetView(aState.mPresContext),
&metrics.mOverflowArea,
NS_FRAME_NO_MOVE_VIEW);
}

View File

@ -130,10 +130,8 @@ NS_IMETHODIMP
nsContainerFrame::Destroy(nsIPresContext* aPresContext)
{
// Prevent event dispatch during destruction
nsIView* view;
GetView(aPresContext, &view);
if (nsnull != view) {
view->SetClientData(nsnull);
if (HasView()) {
GetView(aPresContext)->SetClientData(nsnull);
}
// Delete the primary child list
@ -229,10 +227,7 @@ nsContainerFrame::PaintChild(nsIPresContext* aPresContext,
PRUint32 aFlags)
{
NS_ASSERTION(aFrame, "no frame to paint!");
if (!aFrame) return;
nsIView *pView;
aFrame->GetView(aPresContext, &pView);
if (!pView) {
if (!aFrame->HasView()) {
nsRect kidRect;
aFrame->GetRect(kidRect);
nsFrameState state;
@ -439,9 +434,8 @@ void
nsContainerFrame::PositionFrameView(nsIPresContext* aPresContext,
nsIFrame* aKidFrame)
{
nsIView* view;
aKidFrame->GetView(aPresContext, &view);
if (view) {
if (aKidFrame->HasView()) {
nsIView* view = aKidFrame->GetView(aPresContext);
// Position view relative to its parent, not relative to aKidFrame's
// frame which may not have a view
nsIView* parentView;
@ -1061,9 +1055,8 @@ nsContainerFrame::FinishReflowChild(nsIFrame* aKidFrame,
aKidFrame->GetOrigin(curOrigin);
aKidFrame->SetRect(aPresContext, bounds);
nsIView* view;
aKidFrame->GetView(aPresContext, &view);
if (view) {
if (aKidFrame->HasView()) {
nsIView* view = aKidFrame->GetView(aPresContext);
// Make sure the frame's view is properly sized and positioned and has
// things like opacity correct
SyncFrameViewAfterReflow(aPresContext, aKidFrame, view,
@ -1308,10 +1301,8 @@ nsContainerFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent)
#ifdef DEBUG_waterson
fprintf(out, " [parent=%p]", NS_STATIC_CAST(void*, mParent));
#endif
nsIView* view;
GetView(aPresContext, &view);
if (nsnull != view) {
fprintf(out, " [view=%p]", NS_STATIC_CAST(void*, view));
if (HasView()) {
fprintf(out, " [view=%p]", NS_STATIC_CAST(void*, GetView(aPresContext)));
}
if (nsnull != mNextSibling) {
fprintf(out, " next=%p", NS_STATIC_CAST(void*, mNextSibling));

View File

@ -618,8 +618,7 @@ nsFrame::Destroy(nsIPresContext* aPresContext)
// Get the view pointer now before the frame properties disappear
// when we call NotifyDestroyingFrame()
nsIView* view;
GetView(aPresContext, &view);
nsIView* view = GetView(aPresContext);
// XXX Rather than always doing this it would be better if it was part of
// a frame observer mechanism and the pres shell could register as an
@ -1999,14 +1998,10 @@ nsresult nsFrame::GetContentAndOffsetsFromPoint(nsIPresContext* aCX,
// Traverse through children and look for the best one to give this
// to if it fails the getposition call, make it yourself also only
// look at primary list
nsIView *view = nsnull;
nsIFrame *kid = nsnull;
nsIFrame *closestFrame = nsnull;
result = GetClosestViewForFrame(aCX, this, &view);
if (NS_FAILED(result))
return result;
nsIView *view = GetClosestView(aCX);
result = FirstChild(aCX, nsnull, &kid);
@ -2135,12 +2130,7 @@ nsresult nsFrame::GetContentAndOffsetsFromPoint(nsIPresContext* aCX,
// them to be relative to the closest view.
nsPoint newPoint = aPoint;
nsIView *closestView = nsnull;
result = GetClosestViewForFrame(aCX, closestFrame, &closestView);
if (NS_FAILED(result))
return result;
nsIView *closestView = closestFrame->GetClosestView(aCX);
if (closestView && view != closestView)
{
@ -2395,37 +2385,38 @@ NS_IMETHODIMP nsFrame::SetNextInFlow(nsIFrame*)
}
// Associated view object
NS_IMETHODIMP nsFrame::GetView(nsIPresContext* aPresContext, nsIView** aView) const
nsIView*
nsIFrame::GetView(nsIPresContext* aPresContext) const
{
NS_ENSURE_ARG_POINTER(aView);
// Initialize OUT parameter
*aView = nsnull;
// Check the frame state bit and see if the frame has a view
if (mState & NS_FRAME_HAS_VIEW) {
// Check for a property on the frame
nsCOMPtr<nsIPresShell> presShell;
aPresContext->GetShell(getter_AddRefs(presShell));
if (presShell) {
nsCOMPtr<nsIFrameManager> frameManager;
presShell->GetFrameManager(getter_AddRefs(frameManager));
if (frameManager) {
void* value;
if (NS_SUCCEEDED(frameManager->GetFrameProperty((nsIFrame*)this, nsLayoutAtoms::viewProperty, 0, &value))) {
*aView = (nsIView*)value;
NS_ASSERTION(value != 0, "frame state bit was set but frame has no view");
}
}
}
}
if (!(mState & NS_FRAME_HAS_VIEW))
return nsnull;
return NS_OK;
// Check for a property on the frame
nsCOMPtr<nsIPresShell> presShell;
aPresContext->GetShell(getter_AddRefs(presShell));
nsCOMPtr<nsIFrameManager> frameManager;
presShell->GetFrameManager(getter_AddRefs(frameManager));
void* value;
nsresult rv =
frameManager->GetFrameProperty(NS_CONST_CAST(nsIFrame*, this),
nsLayoutAtoms::viewProperty,
0, &value);
NS_ENSURE_SUCCESS(rv, nsnull);
NS_ASSERTION(value, "frame state bit was set but frame has no view");
return NS_STATIC_CAST(nsIView*, value);
}
NS_IMETHODIMP nsFrame::SetView(nsIPresContext* aPresContext, nsIView* aView)
/* virtual */ nsIView*
nsIFrame::GetViewExternal(nsIPresContext* aPresContext) const
{
return GetView(aPresContext);
}
nsresult
nsIFrame::SetView(nsIPresContext* aPresContext, nsIView* aView)
{
if (aView) {
aView->SetClientData(this);
@ -2434,15 +2425,13 @@ NS_IMETHODIMP nsFrame::SetView(nsIPresContext* aPresContext, nsIView* aView)
nsCOMPtr<nsIPresShell> presShell;
aPresContext->GetShell(getter_AddRefs(presShell));
if (presShell) {
nsCOMPtr<nsIFrameManager> frameManager;
presShell->GetFrameManager(getter_AddRefs(frameManager));
if (frameManager) {
frameManager->SetFrameProperty(this, nsLayoutAtoms::viewProperty,
aView, nsnull);
}
}
nsCOMPtr<nsIFrameManager> frameManager;
presShell->GetFrameManager(getter_AddRefs(frameManager));
nsresult rv =
frameManager->SetFrameProperty(this, nsLayoutAtoms::viewProperty,
aView, nsnull);
NS_ENSURE_SUCCESS(rv, rv);
// Set the frame state bit that says the frame has a view
mState |= NS_FRAME_HAS_VIEW;
@ -2479,10 +2468,7 @@ NS_IMETHODIMP nsFrame::GetParentWithView(nsIPresContext* aPresContext,
nsIFrame* parent;
for (parent = mParent; nsnull != parent; parent->GetParent(&parent)) {
nsIView* parView;
parent->GetView(aPresContext, &parView);
if (nsnull != parView) {
if (parent->HasView()) {
break;
}
}
@ -2508,10 +2494,9 @@ NS_IMETHODIMP nsFrame::GetOffsetFromView(nsIPresContext* aPresContext,
frame->GetOrigin(origin);
aOffset += origin;
frame->GetParent(&frame);
if (nsnull != frame) {
frame->GetView(aPresContext, aView);
}
} while ((nsnull != frame) && (nsnull == *aView));
} while (frame && !frame->HasView());
if (frame)
*aView = frame->GetView(aPresContext);
return NS_OK;
}
@ -2541,16 +2526,15 @@ NS_IMETHODIMP nsFrame::GetOriginToViewOffset(nsIPresContext* aPresContext,
nsIView** aView) const
{
NS_ENSURE_ARG_POINTER(aPresContext);
nsresult rv = NS_OK;
aOffset.MoveTo(0,0);
if (aView)
*aView = nsnull;
nsIView *view = nsnull;
nsresult rv = GetView(aPresContext, &view);
if (NS_SUCCEEDED(rv) && view) {
if (HasView()) {
nsIView *view = GetView(aPresContext);
nsIView *parentView = nsnull;
nsPoint offsetToParentView;
rv = GetOffsetFromView(aPresContext, offsetToParentView, &parentView);
@ -2625,6 +2609,19 @@ NS_IMETHODIMP nsFrame::GetOriginToViewOffset(nsIPresContext* aPresContext,
return rv;
}
/* virtual */ PRBool
nsIFrame::AreAncestorViewsVisible(nsIPresContext* aPresContext)
{
for (nsIView* view = GetClosestView(aPresContext);
view; view->GetParent(view)) {
nsViewVisibility vis;
view->GetVisibility(vis);
if (vis == nsViewVisibility_kHide) {
return PR_FALSE;
}
}
return PR_TRUE;
}
NS_IMETHODIMP nsFrame::GetWindow(nsIPresContext* aPresContext,
nsIWidget** aWindow) const
@ -2634,11 +2631,8 @@ NS_IMETHODIMP nsFrame::GetWindow(nsIPresContext* aPresContext,
nsIFrame* frame;
nsIWidget* window = nsnull;
for (frame = (nsIFrame*)this; nsnull != frame; frame->GetParentWithView(aPresContext, &frame)) {
nsIView* view;
frame->GetView(aPresContext, &view);
if (nsnull != view) {
view->GetWidget(window);
if (frame->HasView()) {
frame->GetView(aPresContext)->GetWidget(window);
if (nsnull != window) {
break;
}
@ -2647,22 +2641,12 @@ NS_IMETHODIMP nsFrame::GetWindow(nsIPresContext* aPresContext,
if (nsnull == window) {
// Ask the view manager for the widget
// First we have to get to a frame with a view
nsIView* view;
GetView(aPresContext, &view);
if (nsnull == view) {
GetParentWithView(aPresContext, &frame);
if (nsnull != frame) {
GetView(aPresContext, &view);
}
}
// From the view get the view manager
if (nsnull != view) {
nsCOMPtr<nsIViewManager> vm;
view->GetViewManager(*getter_AddRefs(vm));
vm->GetWidget(&window);
}
NS_NOTREACHED("this shouldn't happen, should it?");
nsCOMPtr<nsIPresShell> shell;
aPresContext->GetShell(getter_AddRefs(shell));
nsCOMPtr<nsIViewManager> vm;
shell->GetViewManager(getter_AddRefs(vm));
vm->GetWidget(&window);
}
NS_POSTCONDITION(nsnull != window, "no window in frame tree");
@ -2723,17 +2707,15 @@ nsFrame::Invalidate(nsIPresContext* aPresContext,
#endif
PRUint32 flags = aImmediate ? NS_VMREFRESH_IMMEDIATE : NS_VMREFRESH_NO_SYNC;
nsIView* view;
GetView(aPresContext, &view);
if (view) {
if (HasView()) {
nsIView* view = GetView(aPresContext);
view->GetViewManager(viewManager);
viewManager->UpdateView(view, damageRect, flags);
} else {
nsRect rect(damageRect);
nsPoint offset;
nsIView *view;
GetOffsetFromView(aPresContext, offset, &view);
NS_ASSERTION(nsnull != view, "no view");
rect += offset;
@ -2843,10 +2825,8 @@ nsFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) const
#ifdef DEBUG_waterson
fprintf(out, " [parent=%p]", NS_STATIC_CAST(void*, mParent));
#endif
nsIView* view;
GetView(aPresContext, &view);
if (view) {
fprintf(out, " [view=%p]", NS_STATIC_CAST(void*, view));
if (HasView()) {
fprintf(out, " [view=%p]", NS_STATIC_CAST(void*, GetView(aPresContext)));
}
fprintf(out, " {%d,%d,%d,%d}", mRect.x, mRect.y, mRect.width, mRect.height);
if (0 != mState) {
@ -3081,11 +3061,9 @@ nsFrame::DumpBaseRegressionData(nsIPresContext* aPresContext, FILE* out, PRInt32
fprintf(out, "<next-sibling va=\"%ld\"/>\n", PRUptrdiff(mNextSibling));
}
nsIView* view;
GetView(aPresContext, &view);
if (view) {
if (HasView()) {
IndentBy(out, aIndent);
fprintf(out, "<view va=\"%ld\">\n", PRUptrdiff(view));
fprintf(out, "<view va=\"%ld\">\n", PRUptrdiff(GetView(aPresContext)));
aIndent++;
// XXX add in code to dump out view state too...
aIndent--;
@ -3490,7 +3468,7 @@ nsFrame::GetNextPrevLineFromeBlockFrame(nsIPresContext* aPresContext,
}
}
if (NS_FAILED(resultFrame->GetView(aPresContext, &view)) || !view)
if (!resultFrame->HasView())
{
resultFrame->GetRect(rect);
if (!rect.width || !rect.height)
@ -4432,36 +4410,13 @@ nsFrame::GetFrameFromDirection(nsIPresContext* aPresContext, nsPeekOffsetStruct
return NS_OK;
}
nsresult nsFrame::GetClosestViewForFrame(nsIPresContext* aPresContext,
nsIFrame *aFrame,
nsIView **aView)
nsIView* nsIFrame::GetClosestView(nsIPresContext* aPresContext) const
{
if (!aView)
return NS_ERROR_NULL_POINTER;
for (const nsIFrame *f = this; f; f->GetParent(NS_CONST_CAST(nsIFrame**, &f)))
if (f->HasView())
return f->GetView(aPresContext);
nsresult result = NS_OK;
*aView = 0;
nsIFrame *parent = aFrame;
while (parent && !*aView)
{
result = parent->GetView(aPresContext, aView);
if (NS_FAILED(result))
return result;
if (!*aView)
{
result = parent->GetParent(&parent);
if (NS_FAILED(result))
return result;
}
}
return result;
return nsnull;
}
@ -4811,23 +4766,12 @@ NS_IMETHODIMP
nsFrame::CaptureMouse(nsIPresContext* aPresContext, PRBool aGrabMouseEvents)
{
// get its view
nsIView* view = nsnull;
nsIFrame *parent;//might be THIS frame thats ok
GetView(aPresContext, & view);
if (!view)
{
nsresult rv = GetParentWithView(aPresContext, &parent);
if (NS_FAILED(rv))
return rv;
if (!parent)
return NS_ERROR_FAILURE;
parent->GetView(aPresContext, &view);
}
nsIView* view = GetClosestView(aPresContext);
nsCOMPtr<nsIViewManager> viewMan;
PRBool result;
if (view) {
nsCOMPtr<nsIViewManager> viewMan;
view->GetViewManager(*getter_AddRefs(viewMan));
if (viewMan) {
if (aGrabMouseEvents) {
@ -4845,22 +4789,10 @@ PRBool
nsFrame::IsMouseCaptured(nsIPresContext* aPresContext)
{
// get its view
nsIView* view = nsnull;
GetView(aPresContext, &view);
if (!view)
{
nsIFrame *parent;//might be THIS frame thats ok
nsresult rv = GetParentWithView(aPresContext, &parent);
if (NS_FAILED(rv))
return rv;
if (!parent)
return NS_ERROR_FAILURE;
parent->GetView(aPresContext, &view);
}
nsCOMPtr<nsIViewManager> viewMan;
nsIView* view = GetClosestView(aPresContext);
if (view) {
nsCOMPtr<nsIViewManager> viewMan;
view->GetViewManager(*getter_AddRefs(viewMan));
if (viewMan) {

View File

@ -239,8 +239,6 @@ public:
NS_IMETHOD SetPrevInFlow(nsIFrame*);
NS_IMETHOD GetNextInFlow(nsIFrame** aNextInFlow) const;
NS_IMETHOD SetNextInFlow(nsIFrame*);
NS_IMETHOD GetView(nsIPresContext* aPresContext, nsIView** aView) const;
NS_IMETHOD SetView(nsIPresContext* aPresContext, nsIView* aView);
NS_IMETHOD GetParentWithView(nsIPresContext* aPresContext, nsIFrame** aParent) const;
NS_IMETHOD GetOffsetFromView(nsIPresContext* aPresContext, nsPoint& aOffset, nsIView** aView) const;
NS_IMETHOD GetOriginToViewOffset(nsIPresContext *aPresContext, nsPoint& aOffset, nsIView **aView) const;
@ -354,10 +352,6 @@ public:
PRBool IsFrameTreeTooDeep(const nsHTMLReflowState& aReflowState,
nsHTMLReflowMetrics& aMetrics);
virtual nsresult GetClosestViewForFrame(nsIPresContext* aPresContext,
nsIFrame *aFrame,
nsIView **aView);
static nsresult CreateAndPostReflowCommand(nsIPresShell* aPresShell,
nsIFrame* aTargetFrame,
nsReflowType aReflowType,

View File

@ -2346,6 +2346,8 @@ FrameManager::SetFrameProperty(nsIFrame* aFrame,
nsresult result = NS_OK;
PropertyListMapEntry *entry = NS_STATIC_CAST(PropertyListMapEntry*,
PL_DHashTableOperate(&propertyList->mFrameValueMap, aFrame, PL_DHASH_ADD));
if (!entry)
return NS_ERROR_OUT_OF_MEMORY;
// A NULL entry->key is the sign that the entry has just been allocated
// for us. If it's non-NULL then we have an existing entry.
if (entry->key && propertyList->mDtorFunc) {

View File

@ -615,20 +615,14 @@ nsGfxScrollFrame::GetContentAndOffsetsFromPoint(nsIPresContext* aCX,
nsIFrame* frame = nsnull;
mInner->mScrollAreaBox->GetFrame(&frame);
nsIView *view;
nsPoint point(aPoint);
nsPoint currentPoint;
//we need to translate the coordinates to the inner
nsresult result = GetClosestViewForFrame(aCX, this, &view);
if (NS_FAILED(result))
return result;
nsIView *view = GetClosestView(aCX);
if (!view)
return NS_ERROR_FAILURE;
nsIView *innerView;
result = GetClosestViewForFrame(aCX, frame, &innerView);
if (NS_FAILED(result))
return result;
nsIView *innerView = GetClosestView(aCX);
while (view != innerView && innerView)
{
innerView->GetPosition(&currentPoint.x, &currentPoint.y);
@ -1079,14 +1073,13 @@ nsGfxScrollFrameInner::CurPosAttributeChanged(nsIPresContext* aPresContext,
nsIScrollableView*
nsGfxScrollFrameInner::GetScrollableView(nsIPresContext* aPresContext)
{
nsIView* view;
nsIFrame* frame = nsnull;
mScrollAreaBox->GetFrame(&frame);
frame->GetView(aPresContext, &view);
nsIView* view = frame->GetView(aPresContext);
if (!view) return nsnull;
nsIScrollableView* scrollingView;
nsresult result = view->QueryInterface(NS_GET_IID(nsIScrollableView), (void**)&scrollingView);
nsresult result = CallQueryInterface(view, &scrollingView);
NS_ASSERTION(NS_SUCCEEDED(result), "assertion gfx scrollframe does not contain a scrollframe");
return scrollingView;
}
@ -1660,8 +1653,7 @@ nsGfxScrollFrameInner::GetScrolledSize(nsIPresContext* aPresContext,
mScrollAreaBox->GetChildBox(&child);
nsIFrame* frame;
child->GetFrame(&frame);
nsIView* view;
frame->GetView(aPresContext, &view);
nsIView* view = frame->GetView(aPresContext);
NS_ASSERTION(view,"Scrolled frame must have a view!!!");
nsRect rect(0,0,0,0);

View File

@ -379,14 +379,11 @@ HRuleFrame::GetContentAndOffsetsFromPoint(nsIPresContext* aPresContext,
if (!aNewContent) return NS_ERROR_NULL_POINTER;
if (!mContent) return NS_ERROR_NULL_POINTER;
nsIView *view = nsnull;
rv = GetClosestViewForFrame(aPresContext, this, &view);
if (NS_FAILED(rv)) return rv;
nsRect thisRect;
rv = GetRect(thisRect);
if (NS_FAILED(rv)) return rv;
nsPoint offsetPoint;
nsIView *view;
GetOffsetFromView(aPresContext, offsetPoint, &view);
thisRect.x = offsetPoint.x;
thisRect.y = offsetPoint.y;

View File

@ -352,14 +352,13 @@ ReparentFrameViewTo(nsIPresContext* aPresContext,
nsIView* aNewParentView,
nsIView* aOldParentView)
{
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) {
if (aFrame->HasView()) {
nsIView* view = aFrame->GetView(aPresContext);
// Verify that the current parent view is what we think it is
//nsIView* parentView;
//NS_ASSERTION(parentView == aOldParentView, "unexpected parent view");
@ -392,26 +391,6 @@ ReparentFrameViewTo(nsIPresContext* aPresContext,
return NS_OK;
}
// Helper function that returns the nearest view to this frame. Checks
// this frame, its parent frame, its parent frame, ...
static nsIView*
GetClosestViewFor(nsIPresContext* aPresContext, nsIFrame* aFrame)
{
NS_PRECONDITION(aFrame, "null frame pointer");
nsIView* view;
do {
aFrame->GetView(aPresContext, &view);
if (view) {
break;
}
aFrame->GetParent(&aFrame);
} while (aFrame);
NS_POSTCONDITION(view, "no containing view");
return view;
}
nsresult
nsHTMLContainerFrame::ReparentFrameView(nsIPresContext* aPresContext,
nsIFrame* aChildFrame,
@ -423,14 +402,9 @@ nsHTMLContainerFrame::ReparentFrameView(nsIPresContext* aPresContext,
NS_PRECONDITION(aNewParentFrame, "null new parent frame pointer");
NS_PRECONDITION(aOldParentFrame != aNewParentFrame, "same old and new parent frame");
nsIView* childView;
nsIView* oldParentView;
nsIView* newParentView;
// This code is called often and we need it to be as fast as possible, so
// see if we can trivially detect that no work needs to be done
aChildFrame->GetView(aPresContext, &childView);
if (!childView) {
if (!aChildFrame->HasView()) {
// Child frame doesn't have a view. See if it has any child frames
nsIFrame* firstChild;
aChildFrame->FirstChild(aPresContext, nsnull, &firstChild);
@ -440,10 +414,8 @@ nsHTMLContainerFrame::ReparentFrameView(nsIPresContext* aPresContext,
}
// See if either the old parent frame or the new parent frame have a view
aOldParentFrame->GetView(aPresContext, &oldParentView);
aNewParentFrame->GetView(aPresContext, &newParentView);
if (!oldParentView && !newParentView) {
while (!aOldParentFrame->HasView() && !aNewParentFrame->HasView()) {
// Walk up both the old parent frame and the new parent frame nodes
// stopping when we either find a common parent or views for one
// or both of the frames.
@ -451,26 +423,19 @@ nsHTMLContainerFrame::ReparentFrameView(nsIPresContext* aPresContext,
// This works well in the common case where we push/pull and the old parent
// frame and the new parent frame are part of the same flow. They will
// typically be the same distance (height wise) from the
do {
aOldParentFrame->GetParent(&aOldParentFrame);
aNewParentFrame->GetParent(&aNewParentFrame);
// We should never walk all the way to the root frame without finding
// a view
NS_ASSERTION(aOldParentFrame && aNewParentFrame, "didn't find view");
aOldParentFrame->GetParent(&aOldParentFrame);
aNewParentFrame->GetParent(&aNewParentFrame);
// We should never walk all the way to the root frame without finding
// a view
NS_ASSERTION(aOldParentFrame && aNewParentFrame, "didn't find view");
// See if we reached a common parent
if (aOldParentFrame == aNewParentFrame) {
break;
}
// Get the views
aOldParentFrame->GetView(aPresContext, &oldParentView);
aNewParentFrame->GetView(aPresContext, &newParentView);
} while (!(oldParentView || newParentView));
// See if we reached a common ancestor
if (aOldParentFrame == aNewParentFrame) {
break;
}
}
// See if we found a common parent frame
if (aOldParentFrame == aNewParentFrame) {
// We found a common parent and there are no views between the old parent
@ -480,15 +445,10 @@ nsHTMLContainerFrame::ReparentFrameView(nsIPresContext* aPresContext,
return NS_OK;
}
// We found views for one or both of the parent frames before we found a
// common parent
NS_ASSERTION(oldParentView || newParentView, "internal error");
if (!oldParentView) {
oldParentView = GetClosestViewFor(aPresContext, aOldParentFrame);
}
if (!newParentView) {
newParentView = GetClosestViewFor(aPresContext, aNewParentFrame);
}
// We found views for one or both of the ancestor frames before we
// found a common ancestor.
nsIView* oldParentView = aOldParentFrame->GetClosestView(aPresContext);
nsIView* newParentView = aNewParentFrame->GetClosestView(aPresContext);
// See if the old parent frame and the new parent frame are in the
// same view sub-hierarchy. If they are then we don't have to do
@ -516,14 +476,8 @@ nsHTMLContainerFrame::ReparentFrameViewList(nsIPresContext* aPresContext,
NS_PRECONDITION(aNewParentFrame, "null new parent frame pointer");
NS_PRECONDITION(aOldParentFrame != aNewParentFrame, "same old and new parent frame");
nsIView* oldParentView;
nsIView* newParentView;
// See if either the old parent frame or the new parent frame have a view
aOldParentFrame->GetView(aPresContext, &oldParentView);
aNewParentFrame->GetView(aPresContext, &newParentView);
if (!oldParentView && !newParentView) {
while (!aOldParentFrame->HasView() && !aNewParentFrame->HasView()) {
// Walk up both the old parent frame and the new parent frame nodes
// stopping when we either find a common parent or views for one
// or both of the frames.
@ -531,23 +485,17 @@ nsHTMLContainerFrame::ReparentFrameViewList(nsIPresContext* aPresContext,
// This works well in the common case where we push/pull and the old parent
// frame and the new parent frame are part of the same flow. They will
// typically be the same distance (height wise) from the
do {
aOldParentFrame->GetParent(&aOldParentFrame);
aNewParentFrame->GetParent(&aNewParentFrame);
// We should never walk all the way to the root frame without finding
// a view
NS_ASSERTION(aOldParentFrame && aNewParentFrame, "didn't find view");
aOldParentFrame->GetParent(&aOldParentFrame);
aNewParentFrame->GetParent(&aNewParentFrame);
// We should never walk all the way to the root frame without finding
// a view
NS_ASSERTION(aOldParentFrame && aNewParentFrame, "didn't find view");
// See if we reached a common parent
if (aOldParentFrame == aNewParentFrame) {
break;
}
// Get the views
aOldParentFrame->GetView(aPresContext, &oldParentView);
aNewParentFrame->GetView(aPresContext, &newParentView);
} while (!(oldParentView || newParentView));
// See if we reached a common ancestor
if (aOldParentFrame == aNewParentFrame) {
break;
}
}
@ -560,15 +508,10 @@ nsHTMLContainerFrame::ReparentFrameViewList(nsIPresContext* aPresContext,
return NS_OK;
}
// We found views for one or both of the parent frames before we found a
// common parent
NS_ASSERTION(oldParentView || newParentView, "internal error");
if (!oldParentView) {
oldParentView = GetClosestViewFor(aPresContext, aOldParentFrame);
}
if (!newParentView) {
newParentView = GetClosestViewFor(aPresContext, aNewParentFrame);
}
// We found views for one or both of the ancestor frames before we
// found a common ancestor.
nsIView* oldParentView = aOldParentFrame->GetClosestView(aPresContext);
nsIView* newParentView = aNewParentFrame->GetClosestView(aPresContext);
// See if the old parent frame and the new parent frame are in the
// same view sub-hierarchy. If they are then we don't have to do
@ -594,9 +537,7 @@ nsHTMLContainerFrame::CreateViewForFrame(nsIPresContext* aPresContext,
nsIFrame* aContentParentFrame,
PRBool aForce)
{
nsIView* view;
aFrame->GetView(aPresContext, &view);
if (nsnull != view) {
if (aFrame->HasView()) {
return NS_OK;
}
@ -611,12 +552,12 @@ nsHTMLContainerFrame::CreateViewForFrame(nsIPresContext* aPresContext,
aFrame->GetParentWithView(aPresContext, &parent);
NS_ASSERTION(parent, "GetParentWithView failed");
nsIView* parentView = nsnull;
parent->GetView(aPresContext, &parentView);
nsIView* parentView = parent->GetView(aPresContext);
NS_ASSERTION(parentView, "no parent with view");
// Create a view
static NS_DEFINE_CID(kViewCID, NS_VIEW_CID);
nsIView* view;
nsresult result = CallCreateInstance(kViewCID, &view);
if (NS_FAILED(result)) {
return result;
@ -643,23 +584,7 @@ nsHTMLContainerFrame::CreateViewForFrame(nsIPresContext* aPresContext,
viewManager->InsertChild(parentView, view, nsnull, PR_TRUE);
if (nsnull != aContentParentFrame) {
// If, for some reason, GetView below fails to initialize zParentView,
// then ensure that we completely bypass InsertZPlaceholder below.
// The effect will be as if we never knew about aContentParentFrame
// in the first place, so at least this code won't be doing any damage.
nsIView* zParentView = parentView;
aContentParentFrame->GetView(aPresContext, &zParentView);
if (nsnull == zParentView) {
nsIFrame* zParentFrame = nsnull;
aContentParentFrame->GetParentWithView(aPresContext, &zParentFrame);
NS_ASSERTION(zParentFrame, "GetParentWithView failed");
zParentFrame->GetView(aPresContext, &zParentView);
NS_ASSERTION(zParentView, "no parent with view");
}
nsIView* zParentView = aContentParentFrame->GetClosestView(aPresContext);
if (zParentView != parentView) {
viewManager->InsertZPlaceholder(zParentView, view, nsnull, PR_TRUE);
}

View File

@ -448,11 +448,10 @@ CanvasFrame::Paint(nsIPresContext* aPresContext,
nscoord width, height;
scrollableFrame->GetClipSize(aPresContext, &width, &height);
}
nsIView* parentView;
parentFrame->GetView(aPresContext, &parentView);
nsIView* parentView = parentFrame->GetView(aPresContext);
nsIScrollableView* scrollableView;
if (NS_SUCCEEDED(parentView->QueryInterface(NS_GET_IID(nsIScrollableView), (void**)&scrollableView))) {
if (NS_SUCCEEDED(CallQueryInterface(parentView, &scrollableView))) {
nscoord width, height;
scrollableView->GetContainerSize(&width, &height);
const nsIView* clippedView;

View File

@ -1571,10 +1571,9 @@ nsImageFrame::TranslateEventCoords(nsIPresContext* aPresContext,
// If we have a view then the event coordinates are already relative
// to this frame; otherwise we have to adjust the coordinates
// appropriately.
nsIView* view;
GetView(aPresContext, &view);
if (nsnull == view) {
if (!HasView()) {
nsPoint offset;
nsIView *view;
GetOffsetFromView(aPresContext, offset, &view);
if (nsnull != view) {
x -= offset.x;
@ -1820,10 +1819,8 @@ nsImageFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) con
#ifdef DEBUG_waterson
fprintf(out, " [parent=%p]", mParent);
#endif
nsIView* view;
GetView(aPresContext, &view);
if (view) {
fprintf(out, " [view=%p]", view);
if (HasView()) {
fprintf(out, " [view=%p]", GetView(aPresContext));
}
fprintf(out, " {%d,%d,%d,%d}", mRect.x, mRect.y, mRect.width,
mRect.height);

View File

@ -1194,20 +1194,18 @@ nsImageMap::Invalidate(nsIPresContext* aPresContext, nsIFrame* aFrame, nsRect& a
nsIView* view;
nsRect damageRect(aRect);
aFrame->GetView(aPresContext, &view);
if (view) {
view->GetViewManager(*getter_AddRefs(viewManager));
viewManager->UpdateView(view, damageRect, flags);
if (aFrame->HasView()) {
view = aFrame->GetView(aPresContext);
}
else {
nsPoint offset;
nsPoint offset;
aFrame->GetOffsetFromView(aPresContext, offset, &view);
NS_ASSERTION(nsnull != view, "no view");
damageRect += offset;
view->GetViewManager(*getter_AddRefs(viewManager));
viewManager->UpdateView(view, damageRect, flags);
}
view->GetViewManager(*getter_AddRefs(viewManager));
viewManager->UpdateView(view, damageRect, flags);
return NS_OK;
}

View File

@ -1228,9 +1228,8 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame,
// Size the frame and size its view (if it has one)
aFrame->SizeTo(mPresContext, metrics.width, metrics.height);
nsIView* view;
aFrame->GetView(mPresContext, &view);
if (view) {
if (aFrame->HasView()) {
nsIView* view = aFrame->GetView(mPresContext);
nsIViewManager *vm;
view->GetViewManager(vm);

View File

@ -797,10 +797,9 @@ nsObjectFrame::CreateWidget(nsIPresContext* aPresContext,
nsRect boundBox(0, 0, aWidth, aHeight);
nsIFrame* parWithView;
nsIView *parView;
GetParentWithView(aPresContext, &parWithView);
parWithView->GetView(aPresContext, &parView);
nsIView *parView = parWithView->GetView(aPresContext);
if (NS_SUCCEEDED(parView->GetViewManager(*getter_AddRefs(viewMan))))
{
@ -1533,9 +1532,8 @@ nsObjectFrame::DidReflow(nsIPresContext* aPresContext,
PRBool bHidden = IsHidden();
nsIView* view = nsnull;
GetView(aPresContext, &view);
if (view) {
if (HasView()) {
nsIView* view = GetView(aPresContext);
nsCOMPtr<nsIViewManager> vm;
view->GetViewManager(*getter_AddRefs(vm));
if (vm)
@ -2427,10 +2425,9 @@ NS_IMETHODIMP nsPluginInstanceOwner::InvalidateRect(nsPluginRect *invalidRect)
if(invalidRect)
{
//no reference count on view
nsIView* view;
rv = mOwner->GetView(mContext, &view);
nsIView* view = mOwner->GetView(mContext);
if((rv == NS_OK) && view)
if (view)
{
float ptot;
mContext->GetPixelsToTwips(&ptot);
@ -2462,11 +2459,11 @@ NS_IMETHODIMP nsPluginInstanceOwner::InvalidateRegion(nsPluginRegion invalidRegi
NS_IMETHODIMP nsPluginInstanceOwner::ForceRedraw()
{
nsresult rv = NS_OK;
//no reference count on view
nsIView* view;
nsresult rv = mOwner->GetView(mContext, &view);
nsIView* view = mOwner->GetView(mContext);
if((rv == NS_OK) && view)
if (view)
{
nsIViewManager* manager;
rv = view->GetViewManager(manager);
@ -3740,7 +3737,7 @@ nsPluginInstanceOwner::Destroy()
nsIView* curView = nsnull;
if (parentWithView)
parentWithView->GetView(mContext, &curView);
curView = parentWithView->GetView(mContext);
while (curView)
{
nsIScrollableView* scrollingView;
@ -3967,7 +3964,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::Init(nsIPresContext* aPresContext, nsObject
mOwner->GetParentWithView(mContext, &parentWithView);
nsIView* curView = nsnull;
if (parentWithView)
parentWithView->GetView(mContext, &curView);
curView = parentWithView->GetView(mContext);
while (curView)
{
nsIScrollableView* scrollingView;
@ -4020,7 +4017,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void)
{
// Create view if necessary
mOwner->GetView(mContext, &view);
view = mOwner->GetView(mContext);
if (!view || !mWidget)
{
@ -4036,7 +4033,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void)
windowless);
if (NS_OK == rv)
{
mOwner->GetView(mContext, &view);
view = mOwner->GetView(mContext);
if (view)
{
view->GetWidget(*getter_AddRefs(mWidget));
@ -4109,9 +4106,8 @@ aContainerWidget)
aAbs.x = 0;
aAbs.y = 0;
nsIView *view = nsnull;
// See if this frame has a view
aFrame->GetView(aPresContext, &view);
nsIView *view = aFrame->GetView(aPresContext);
if (nsnull == view) {
// Calculate frames offset from its nearest view
aFrame->GetOffsetFromView(aPresContext,
@ -4167,8 +4163,7 @@ nsPluginPort* nsPluginInstanceOwner::FixUpPluginWindow(PRInt32 inPaintState)
return nsnull;
// first, check our view for CSS visibility style
nsIView *view;
mOwner->GetView(mContext, &view);
nsIView *view = mOwner->GetView(mContext);
nsViewVisibility vis;
view->GetVisibility(vis);
PRBool isVisible = (vis == nsViewVisibility_kShow) ? PR_TRUE : PR_FALSE;
@ -4226,12 +4221,11 @@ nsPluginPort* nsPluginInstanceOwner::FixUpPluginWindow(PRInt32 inPaintState)
void nsPluginInstanceOwner::Composite()
{
//no reference count on view
nsIView* view;
nsresult rv = mOwner->GetView(mContext, &view);
nsIView* view = mOwner->GetView(mContext);
if (NS_SUCCEEDED(rv) && view) {
if (view) {
nsIViewManager* manager;
rv = view->GetViewManager(manager);
nsresult rv = view->GetViewManager(manager);
//set flags to not do a synchronous update, force update does the redraw
if (NS_SUCCEEDED(rv) && manager) {

View File

@ -136,8 +136,7 @@ NS_IMETHODIMP nsPageContentFrame::Reflow(nsIPresContext* aPresContext,
nsRect r;
frame->GetRect(r);
printf("PCF: Area Frame %p Bounds: %5d,%5d,%5d,%5d\n", frame, r.x, r.y, r.width, r.height);
nsIView* view;
frame->GetView(aPresContext, &view);
nsIView* view = frame->GetView(aPresContext);
if (view) {
view->GetBounds(r);
printf("PCF: Area Frame View Bounds: %5d,%5d,%5d,%5d\n", r.x, r.y, r.width, r.height);

View File

@ -125,8 +125,7 @@ nsPageFrame::SetInitialChildList(nsIPresContext* aPresContext,
nsIAtom* aListName,
nsIFrame* aChildList)
{
nsIView * view;
aChildList->GetView(aPresContext, &view);
nsIView* view = aChildList->GetView(aPresContext);
if (view != nsnull && mDoCreateWidget) {
nscoord dx, dy;
nsCOMPtr<nsIWidget> widget;
@ -228,8 +227,7 @@ NS_IMETHODIMP nsPageFrame::Reflow(nsIPresContext* aPresContext,
aDesiredSize.height = aReflowState.availableHeight;
}
nsIView * view;
frame->GetView(aPresContext, &view);
nsIView* view = frame->GetView(aPresContext);
if (view) {
nsCOMPtr<nsIViewManager> vm;
view->GetViewManager(*getter_AddRefs(vm));

View File

@ -141,10 +141,8 @@ nsPlaceholderFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aInden
#ifdef DEBUG_waterson
fprintf(out, " [parent=%p]", NS_STATIC_CAST(void*, mParent));
#endif
nsIView* view;
GetView(aPresContext, &view);
if (nsnull != view) {
fprintf(out, " [view=%p]", (void*)view);
if (HasView()) {
fprintf(out, " [view=%p]", (void*)GetView(aPresContext));
}
fprintf(out, " {%d,%d,%d,%d}", mRect.x, mRect.y, mRect.width, mRect.height);
if (0 != mState) {

View File

@ -918,8 +918,7 @@ IncrementalReflow::Dispatch(nsIPresContext *aPresContext,
first->SizeTo(aPresContext, aDesiredSize.width, aDesiredSize.height);
nsIView* view;
first->GetView(aPresContext, &view);
nsIView* view = first->GetView(aPresContext);
if (view)
nsContainerFrame::SyncFrameViewAfterReflow(aPresContext, first, view, nsnull);
@ -2850,8 +2849,7 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight)
rootFrame->SizeTo(mPresContext, desiredSize.width, desiredSize.height);
mPresContext->SetVisibleArea(nsRect(0,0,desiredSize.width,desiredSize.height));
nsIView* view;
rootFrame->GetView(mPresContext, &view);
nsIView* view = rootFrame->GetView(mPresContext);
if (view) {
nsContainerFrame::SyncFrameViewAfterReflow(mPresContext, rootFrame, view,
nsnull);
@ -2993,8 +2991,7 @@ PresShell::ResizeReflow(nscoord aWidth, nscoord aHeight)
rootFrame->SizeTo(mPresContext, desiredSize.width, desiredSize.height);
mPresContext->SetVisibleArea(nsRect(0,0,desiredSize.width,desiredSize.height));
nsIView* view;
rootFrame->GetView(mPresContext, &view);
nsIView* view = rootFrame->GetView(mPresContext);
if (view) {
nsContainerFrame::SyncFrameViewAfterReflow(mPresContext, rootFrame, view,
nsnull);
@ -3536,8 +3533,7 @@ PresShell::StyleChangeReflow()
rootFrame->Reflow(mPresContext, desiredSize, reflowState, status);
rootFrame->SizeTo(mPresContext, desiredSize.width, desiredSize.height);
mPresContext->SetVisibleArea(nsRect(0,0,desiredSize.width,desiredSize.height));
nsIView* view;
rootFrame->GetView(mPresContext, &view);
nsIView* view = rootFrame->GetView(mPresContext);
if (view) {
nsContainerFrame::SyncFrameViewAfterReflow(mPresContext, rootFrame, view,
nsnull);
@ -3959,14 +3955,10 @@ PresShell::CreateRenderingContext(nsIFrame *aFrame,
return NS_ERROR_NULL_POINTER;
}
nsIView *view = nsnull;
nsPoint pt;
nsresult rv;
aFrame->GetView(mPresContext, &view);
if (nsnull == view)
aFrame->GetOffsetFromView(mPresContext, pt, &view);
nsIView *view = aFrame->GetClosestView(mPresContext);
nsCOMPtr<nsIWidget> widget;
if (nsnull != view) {
@ -6261,7 +6253,7 @@ PresShell::HandleEvent(nsIView *aView,
nsPoint offset(0,0);
nsRect oldTargetRect(mCurrentTargetRect);
mCurrentEventFrame->GetRect(mCurrentTargetRect);
mCurrentEventFrame->GetView(mPresContext, &mCurrentTargetView);
mCurrentTargetView = mCurrentEventFrame->GetView(mPresContext);
if (!mCurrentTargetView ) {
mCurrentEventFrame->GetOffsetFromView(mPresContext, offset,
&mCurrentTargetView);
@ -7007,8 +6999,8 @@ CompareTrees(nsIPresContext* aFirstPresContext, nsIFrame* aFirstFrame,
// do have views, make sure the views are the same size. If the
// views have widgets, make sure they both do or neither does. If
// they do, make sure the widgets are the same size.
k1->GetView(aFirstPresContext, &v1);
k2->GetView(aSecondPresContext, &v2);
v1 = k1->GetView(aFirstPresContext);
v2 = k2->GetView(aSecondPresContext);
if (((nsnull == v1) && (nsnull != v2)) ||
((nsnull != v1) && (nsnull == v2))) {
ok = PR_FALSE;

View File

@ -674,8 +674,7 @@ nsSimplePageSequenceFrame::StartPrint(nsIPresContext* aPresContext,
#if defined(DEBUG_rods) || defined(DEBUG_dcone)
{
nsIView * seqView;
GetView(aPresContext, &seqView);
nsIView* seqView = GetView(aPresContext);
nsRect rect;
GetRect(rect);
PR_PL(("Seq Frame: %p - [%5d,%5d,%5d,%5d] ", this, rect.x, rect.y, rect.width, rect.height));
@ -691,8 +690,7 @@ nsSimplePageSequenceFrame::StartPrint(nsIPresContext* aPresContext,
{
PRInt32 pageNum = 1;
for (nsIFrame* page = mFrames.FirstChild(); nsnull != page; page->GetNextSibling(&page)) {
nsIView* view;
page->GetView(aPresContext, &view);
nsIView* view = page->GetView(aPresContext);
NS_ASSERTION(nsnull != view, "no page view");
nsRect rect;
page->GetRect(rect);
@ -720,8 +718,7 @@ nsSimplePageSequenceFrame::StartPrint(nsIPresContext* aPresContext,
nscoord y = 0;//mMargin.top;
for (nsIFrame* page = mFrames.FirstChild(); nsnull != page; page->GetNextSibling(&page)) {
nsIView* view = nsnull;
page->GetView(aPresContext, &view);
nsIView* view = page->GetView(aPresContext);
NS_ASSERTION(nsnull != view, "no page view");
nsCOMPtr<nsIViewManager> vm;
@ -889,7 +886,7 @@ nsSimplePageSequenceFrame::PrintNextPage(nsIPresContext* aPresContext)
nsIFrame* childFrame = mFrames.FirstChild();
nsIFrame* conFrame;
childFrame->FirstChild(aPresContext, nsnull, &conFrame);
conFrame->GetView(aPresContext, &containerView);
containerView = conFrame->GetView(aPresContext);
NS_ASSERTION(containerView != nsnull, "Container view can't be null!");
containerView->GetBounds(containerRect);
containerRect.y -= mYSelOffset;
@ -922,8 +919,7 @@ nsSimplePageSequenceFrame::PrintNextPage(nsIPresContext* aPresContext)
}
// Print the page
nsIView* view;
mCurrentPageFrame->GetView(aPresContext, &view);
nsIView* view = mCurrentPageFrame->GetView(aPresContext);
NS_ASSERTION(nsnull != view, "no page view");

View File

@ -6009,10 +6009,8 @@ nsTextFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) cons
#ifdef DEBUG_waterson
fprintf(out, " [parent=%p]", mParent);
#endif
nsIView* view;
GetView(aPresContext, &view);
if (nsnull != view) {
fprintf(out, " [view=%p]", NS_STATIC_CAST(void*, view));
if (HasView()) {
fprintf(out, " [view=%p]", NS_STATIC_CAST(void*, GetView(aPresContext)));
}
PRInt32 totalContentLength;

View File

@ -368,9 +368,7 @@ nsHTMLFrameOuterFrame::Init(nsIPresContext* aPresContext,
// (e.g., the canvas) when it really needs to have the OuterFrame's
// view as its parent. So, create the OuterFrame's view right away
// if we need it, and the InnerFrame's view will get it as the parent.
nsIView* view = nsnull;
GetView(aPresContext, &view);
if (!view) {
if (!HasView()) {
// To properly initialize the view we need to know the frame for the content
// that is the parent of content for this frame. This might not be our actual
// frame parent if we are out of flow (e.g., positioned) so our parent frame
@ -399,8 +397,8 @@ nsHTMLFrameOuterFrame::Init(nsIPresContext* aPresContext,
}
nsHTMLContainerFrame::CreateViewForFrame(aPresContext,this,mStyleContext,contentParent,PR_TRUE);
GetView(aPresContext, &view);
}
nsIView* view = GetView(aPresContext);
if (aParent->GetStyleDisplay()->mDisplay == NS_STYLE_DISPLAY_DECK) {
nsCOMPtr<nsIWidget> widget;
@ -1027,8 +1025,7 @@ nsHTMLFrameInnerFrame::DidReflow(nsIPresContext* aPresContext,
// The view is created hidden; once we have reflowed it and it has been
// positioned then we show it.
if (NS_FRAME_REFLOW_FINISHED == aStatus) {
nsIView* view = nsnull;
GetView(aPresContext, &view);
nsIView* view = GetView(aPresContext);
if (view) {
nsViewVisibility newVis = GetStyleVisibility()->IsVisible()
? nsViewVisibility_kShow

View File

@ -349,9 +349,8 @@ nsHTMLFramesetFrame::Init(nsIPresContext* aPresContext,
presShell->GetViewManager(getter_AddRefs(viewMan));
nsIFrame* parWithView;
nsIView *parView;
GetParentWithView(aPresContext, &parWithView);
parWithView->GetView(aPresContext, &parView);
nsIView *parView = parWithView->GetView(aPresContext);
nsRect boundBox(0, 0, 0, 0);
result = view->Init(viewMan, boundBox, parView);
// XXX Put it last in document order until we can do better
@ -1457,8 +1456,7 @@ nsHTMLFramesetFrame::StartMouseDrag(nsIPresContext* aPresContext,
IndexOf(aBorder, index);
NS_ASSERTION((nsnull != aBorder) && (index >= 0), "invalid dragger");
#endif
nsIView* view;
GetView(aPresContext, &view);
nsIView* view = GetView(aPresContext);
if (view) {
nsCOMPtr<nsIViewManager> viewMan;
view->GetViewManager(*getter_AddRefs(viewMan));
@ -1572,8 +1570,7 @@ nsHTMLFramesetFrame::MouseDrag(nsIPresContext* aPresContext,
void
nsHTMLFramesetFrame::EndMouseDrag(nsIPresContext* aPresContext)
{
nsIView* view;
GetView(aPresContext, &view);
nsIView* view = GetView(aPresContext);
if (view) {
nsCOMPtr<nsIViewManager> viewMan;
view->GetViewManager(*getter_AddRefs(viewMan));

View File

@ -568,8 +568,7 @@ nsComboboxControlFrame::ScrollIntoView(nsIPresContext* aPresContext)
void
nsComboboxControlFrame::ShowPopup(PRBool aShowPopup)
{
nsIView* view = nsnull;
mDropdownFrame->GetView(mPresContext, &view);
nsIView* view = mDropdownFrame->GetView(mPresContext);
nsCOMPtr<nsIViewManager> viewManager;
view->GetViewManager(*getter_AddRefs(viewManager));
@ -617,8 +616,7 @@ nsComboboxControlFrame::ShowList(nsIPresContext* aPresContext, PRBool aShowList)
// Get parent view
nsIFrame * listFrame;
if (NS_OK == mListControlFrame->QueryInterface(NS_GET_IID(nsIFrame), (void **)&listFrame)) {
nsIView * view = nsnull;
listFrame->GetView(aPresContext, &view);
nsIView* view = listFrame->GetView(aPresContext);
NS_ASSERTION(view != nsnull, "nsComboboxControlFrame view is null");
if (view) {
view->GetWidget(*getter_AddRefs(widget));
@ -677,8 +675,7 @@ nsComboboxControlFrame::ReflowComboChildFrame(nsIFrame* aFrame,
// ensure we start off hidden
if (aReflowState.reason == eReflowReason_Initial) {
nsIView* view = nsnull;
mDropdownFrame->GetView(mPresContext, &view);
nsIView* view = mDropdownFrame->GetView(mPresContext);
nsCOMPtr<nsIViewManager> viewManager;
view->GetViewManager(*getter_AddRefs(viewManager));
viewManager->SetViewVisibility(view, nsViewVisibility_kHide);
@ -1810,8 +1807,7 @@ nsComboboxControlFrame::ShowDropDown(PRBool aDoDropDown)
if (!mDroppedDown && aDoDropDown) {
// XXX Temporary for Bug 19416
nsIView * lstView;
mDropdownFrame->GetView(mPresContext, &lstView);
nsIView* lstView = mDropdownFrame->GetView(mPresContext);
if (lstView) {
lstView->IgnoreSetPosition(PR_FALSE);
}
@ -2359,8 +2355,7 @@ nsComboboxControlFrame::Destroy(nsIPresContext* aPresContext)
// Get parent view
nsIFrame * listFrame;
if (NS_OK == mListControlFrame->QueryInterface(NS_GET_IID(nsIFrame), (void **)&listFrame)) {
nsIView * view = nsnull;
listFrame->GetView(aPresContext, &view);
nsIView* view = listFrame->GetView(aPresContext);
NS_ASSERTION(view != nsnull, "nsComboboxControlFrame view is null");
if (view) {
view->GetWidget(*getter_AddRefs(widget));

View File

@ -277,9 +277,7 @@ nsFieldSetFrame::Paint(nsIPresContext* aPresContext,
#ifdef DEBUG
if ((NS_FRAME_PAINT_LAYER_DEBUG == aWhichLayer) && GetShowFrameBorders()) {
nsIView* view;
GetView(aPresContext, &view);
if (nsnull != view) {
if (HasView()) {
aRenderingContext.SetColor(NS_RGB(0,0,255));
}
else {

View File

@ -496,8 +496,7 @@ nsFormControlFrame::DidReflow(nsIPresContext* aPresContext,
// The view is created hidden; once we have reflowed it and it has been
// positioned then we show it.
if (NS_FRAME_REFLOW_FINISHED == aStatus) {
nsIView* view = nsnull;
GetView(aPresContext, &view);
nsIView* view = GetView(aPresContext);
if (view) {
nsViewVisibility newVis = GetStyleVisibility()->IsVisible()
? nsViewVisibility_kShow

View File

@ -268,19 +268,17 @@ nsImageControlFrame::Init(nsIPresContext* aPresContext,
aContext, aPrevInFlow);
// create our view, we need a view to grab the mouse
nsIView* view;
GetView(aPresContext, &view);
if (!view) {
nsresult result = nsComponentManager::CreateInstance(kViewCID, nsnull, NS_GET_IID(nsIView), (void **)&view);
if (!HasView()) {
nsIView* view;
nsresult result = CallCreateInstance(kViewCID, &view);
nsCOMPtr<nsIPresShell> presShell;
aPresContext->GetShell(getter_AddRefs(presShell));
nsCOMPtr<nsIViewManager> viewMan;
presShell->GetViewManager(getter_AddRefs(viewMan));
nsIFrame* parWithView;
nsIView *parView;
GetParentWithView(aPresContext, &parWithView);
parWithView->GetView(aPresContext, &parView);
nsIView *parView = parWithView->GetView(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 File

@ -1666,7 +1666,7 @@ nsListControlFrame::CaptureMouseEvents(nsIPresContext* aPresContext, PRBool aGra
{
nsIView* view = nsnull;
if (IsInDropDownMode()) {
GetView(aPresContext, &view);
view = GetView(aPresContext);
} else {
nsIFrame* scrolledFrame = nsnull;
GetScrolledFrame(aPresContext, scrolledFrame);
@ -1678,7 +1678,7 @@ nsListControlFrame::CaptureMouseEvents(nsIPresContext* aPresContext, PRBool aGra
NS_ASSERTION(scrollport, "No scrollport found");
NS_ENSURE_TRUE(scrollport, NS_ERROR_FAILURE);
scrollport->GetView(aPresContext, &view);
view = scrollport->GetView(aPresContext);
}
NS_ASSERTION(view, "no view???");

View File

@ -3108,13 +3108,11 @@ nsTextControlFrame::SetInitialChildList(nsIPresContext* aPresContext,
while(first)
{
nsIScrollableView *scrollView;
nsIView *view;
first->GetView(aPresContext,&view);
nsIView *view = first->GetView(aPresContext);
if (view)
{
view->QueryInterface(NS_GET_IID(nsIScrollableView),(void **)&scrollView);
if (scrollView)
nsIScrollableView *scrollView;
if (NS_SUCCEEDED(CallQueryInterface(view, &scrollView)))
{
mScrollableView = scrollView; // Note: views are not addref'd
mTextSelImpl->SetScrollableView(scrollView);

View File

@ -3750,16 +3750,11 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell,
}
}
if (aPresContext) {
PRBool isPaginated = PR_FALSE;
if (NS_SUCCEEDED(aPresContext->IsPaginated(&isPaginated))) {
if (isPaginated) {
if (printPreviewContext) { // print preview
aPresContext->GetPaginatedScrolling(&isScrollable);
} else {
isScrollable = PR_FALSE; // we are printing
}
}
if (isPaginated) {
if (printPreviewContext) { // print preview
aPresContext->GetPaginatedScrolling(&isScrollable);
} else {
isScrollable = PR_FALSE; // we are printing
}
}
@ -3869,8 +3864,7 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell,
newScrollableFrame);
// Inform the view manager about the root scrollable view
nsIView* view = nsnull;
newScrollableFrame->GetView(aPresContext, &view);
nsIView* view = newScrollableFrame->GetView(aPresContext);
NS_ENSURE_TRUE(view, NS_ERROR_FAILURE);
nsIScrollableView* scrollableView = nsnull;
@ -3910,8 +3904,7 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell,
scrollPseudoStyle);
// Inform the view manager about the root scrollable view
nsIView* view = nsnull;
scrollFrame->GetView(aPresContext, &view);
nsIView* view = scrollFrame->GetView(aPresContext);
NS_ENSURE_TRUE(view, NS_ERROR_FAILURE);
nsIScrollableView* scrollableView = nsnull;
@ -4221,8 +4214,7 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsIPresShell* aPresShell,
newFrame = listFrame;
// XXX Temporary for Bug 19416
{
nsIView * lstView;
scrolledFrame->GetView(aPresContext, &lstView);
nsIView* lstView = scrolledFrame->GetView(aPresContext);
if (lstView) {
lstView->IgnoreSetPosition(PR_TRUE);
}
@ -4231,8 +4223,7 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsIPresShell* aPresShell,
// Set flag so the events go to the listFrame not child frames.
// XXX: We should replace this with a real widget manager similar
// to how the nsFormControlFrame works. Re-directing events is a temporary Kludge.
nsIView *listView;
listFrame->GetView(aPresContext, &listView);
nsIView *listView = listFrame->GetView(aPresContext);
NS_ASSERTION(nsnull != listView,"ListFrame's view is nsnull");
nsIWidget * viewWidget;
listView->GetWidget(viewWidget);
@ -4335,8 +4326,7 @@ nsCSSFrameConstructor::InitializeSelectFrame(nsIPresShell* aPresShell,
aStyleContext, aParentFrame, aBuildCombobox);
if (aBuildCombobox) {
// Give the drop-down list a popup widget
nsIView * view;
scrollFrame->GetView(aPresContext, &view);
nsIView* view = scrollFrame->GetView(aPresContext);
NS_ASSERTION(view, "We asked for a view but didn't get one");
if (view) {
nsCOMPtr<nsIViewManager> vm;
@ -4461,9 +4451,6 @@ nsCSSFrameConstructor::ConstructFieldSetFrame(nsIPresShell* aPresShel
nsHTMLContainerFrame::CreateViewForFrame(aPresContext, newFrame,
aStyleContext, aParentFrame, PR_FALSE);
// cache our display type
const nsStyleDisplay* styleDisplay = newFrame->GetStyleDisplay();
nsIFrame* areaFrame;
NS_NewAreaFrame(shell, &areaFrame, NS_BLOCK_SPACE_MGR | NS_BLOCK_SHRINK_WRAP);
@ -9840,9 +9827,7 @@ UpdateViewsForTree(nsIPresContext* aPresContext, nsIFrame* aFrame,
NS_PRECONDITION(gInApplyRenderingChangeToTree,
"should only be called within ApplyRenderingChangeToTree");
nsIView* view;
aFrame->GetView(aPresContext, &view);
nsIView* view = aFrame->GetView(aPresContext);
if (view) {
if (aChange & nsChangeHint_RepaintFrame) {
aViewManager->UpdateView(view, NS_VMREFRESH_NO_SYNC);
@ -9916,8 +9901,7 @@ DoApplyRenderingChangeToTree(nsIPresContext* aPresContext,
// frame doesn't have a view, find the nearest containing view
// (adjusting r's coordinate system to reflect the nesting) and
// update there.
nsIView* view = nsnull;
aFrame->GetView(aPresContext, &view);
nsIView* view = aFrame->GetView(aPresContext);
nsIView* parentView;
if (! view) { // XXX can view have children outside it?
aFrame->GetOffsetFromView(aPresContext, viewOffset, &parentView);
@ -9977,14 +9961,7 @@ ApplyRenderingChangeToTree(nsIPresContext* aPresContext,
nsCOMPtr<nsIViewManager> viewManager(aViewManager);
if (!viewManager) {
nsIView* view = nsnull;
aFrame->GetView(aPresContext, &view);
if (! view) {
nsPoint offset;
aFrame->GetOffsetFromView(aPresContext, offset, &view);
}
NS_ASSERTION(view, "no view");
view->GetViewManager(*getter_AddRefs(viewManager));
shell->GetViewManager(getter_AddRefs(viewManager));
}
// Trigger rendering updates by damaging this frame and any
@ -11020,8 +10997,9 @@ nsCSSFrameConstructor::CreateContinuingOuterTableFrame(nsIPresShell* aPresShell,
nsStyleContext* captionStyle = childFrame->GetStyleContext();
nsIContent* caption;
childFrame->GetContent(&caption);
const nsStyleDisplay* display = captionStyle->GetStyleDisplay();
NS_ASSERTION(NS_STYLE_DISPLAY_TABLE_CAPTION == display->mDisplay, "expected caption");
NS_ASSERTION(NS_STYLE_DISPLAY_TABLE_CAPTION ==
captionStyle->GetStyleDisplay()->mDisplay,
"expected caption");
// Replicate the caption frame
// XXX We have to do it this way instead of calling ConstructFrameByDisplayType(),
@ -13378,16 +13356,14 @@ nsCSSFrameConstructor::ConstructInline(nsIPresShell* aPresShell,
InitAndRestoreFrame(aPresContext, aState, aContent,
aParentFrame, blockSC, nsnull, blockFrame);
nsIView* originalInlineFrameView;
aNewFrame->GetView(aPresContext, &originalInlineFrameView);
nsIView* originalInlineFrameView = aNewFrame->GetView(aPresContext);
// Any inline frame could have a view (e.g., opacity)
// XXXbz should we be passing in a non-null aContentParentFrame?
nsHTMLContainerFrame::CreateViewForFrame(aPresContext, blockFrame,
aStyleContext, nsnull, PR_FALSE);
nsIView* view;
blockFrame->GetView(aPresContext, &view);
nsIView* view = blockFrame->GetView(aPresContext);
if (view || originalInlineFrameView) {
// Move list2's frames into the new view
nsIFrame* oldParent;
@ -13422,8 +13398,7 @@ nsCSSFrameConstructor::ConstructInline(nsIPresShell* aPresShell,
nsHTMLContainerFrame::CreateViewForFrame(aPresContext, inlineFrame,
aStyleContext, nsnull, PR_FALSE);
nsIView* inlineView;
inlineFrame->GetView(aPresContext, &inlineView);
nsIView* inlineView = inlineFrame->GetView(aPresContext);
if (inlineView || originalInlineFrameView) {
// Move list3's frames into the new view
nsIFrame* oldParent;

View File

@ -2879,8 +2879,7 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext,
// attachment (root or BODY) or the stylesheet specifying that
// attachment, set the BitBlt flag here as well.
if (canvasColor.mBackgroundAttachment == NS_STYLE_BG_ATTACHMENT_FIXED) {
nsIView *view;
aForFrame->GetView(aPresContext, &view);
nsIView *view = aForFrame->GetView(aPresContext);
if (view)
vm->SetViewBitBltEnabled(view, PR_FALSE);
}
@ -3112,7 +3111,7 @@ nsCSSRendering::PaintBackgroundWithSC(nsIPresContext* aPresContext,
if (scrolledFrame) {
scrolledFrame->GetRect(viewportArea);
scrolledFrame->GetView(aPresContext, &viewportView);
viewportView = scrolledFrame->GetView(aPresContext);
}
else {
// The viewport isn't scrollable, so use the root frame's view
@ -3132,7 +3131,7 @@ nsCSSRendering::PaintBackgroundWithSC(nsIPresContext* aPresContext,
rootFrame = page;
}
rootFrame->GetView(aPresContext, &viewportView);
viewportView = rootFrame->GetView(aPresContext);
NS_ASSERTION(viewportView, "no viewport view");
viewportView->GetBounds(viewportArea);
viewportArea.x = 0;
@ -3168,8 +3167,7 @@ nsCSSRendering::PaintBackgroundWithSC(nsIPresContext* aPresContext,
ComputeBackgroundAnchorPoint(aColor, viewportArea, viewportArea, tileWidth, tileHeight, anchor);
// Convert the anchor point to aForFrame's coordinate space
nsIView* view;
aForFrame->GetView(aPresContext, &view);
nsIView* view = aForFrame->GetView(aPresContext);
if (!view) {
nsPoint offset;
aForFrame->GetOffsetFromView(aPresContext, offset, &view);

View File

@ -635,10 +635,7 @@ void nsTableRowFrame::PaintChildren(nsIPresContext* aPresContext,
{
nsIFrame* kid = mFrames.FirstChild();
while (nsnull != kid) {
nsIView *pView;
kid->GetView(aPresContext, &pView);
if (nsnull == pView) {
if (!kid->HasView()) {
nsRect kidRect;
kid->GetRect(kidRect);
nsRect damageArea;

View File

@ -254,10 +254,7 @@ void nsTableRowGroupFrame::PaintChildren(nsIPresContext* aPresContext,
{
nsIFrame* kid = GetFirstFrame();
while (nsnull != kid) {
nsIView *pView;
kid->GetView(aPresContext, &pView);
if (nsnull == pView) {
if (!kid->HasView()) {
PRBool clipState;
nsRect kidRect;
kid->GetRect(kidRect);

View File

@ -2718,8 +2718,7 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO, PRBool aDoCalcShrink)
}
if (frame) {
nsIView* view = nsnull;
frame->GetView(aPO->mParent->mPresContext, &view);
nsIView* view = frame->GetView(aPO->mParent->mPresContext);
if (view) {
nsCOMPtr<nsIWidget> w2;
view->GetWidget(*getter_AddRefs(w2));
@ -2871,8 +2870,7 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO, PRBool aDoCalcShrink)
//DumpFrames(fd, aPO->mPresContext, renderingContext, theRootFrame, 0);
fprintf(fd, "---------------------------------------\n\n");
fprintf(fd, "--------------- Views From Root Frame----------------\n");
nsIView * v;
theRootFrame->GetView(aPO->mPresContext, &v);
nsIView* v = theRootFrame->GetView(aPO->mPresContext);
if (v) {
v->List(fd);
} else {
@ -4799,8 +4797,7 @@ static void DumpFrames(FILE* out,
nsRect rect;
child->GetRect(rect);
fprintf(out, "[%d,%d,%d,%d] ", rect.x, rect.y, rect.width, rect.height);
nsIView * view;
child->GetView(aPresContext, &view);
nsIView* view = child->GetView(aPresContext);
fprintf(out, "v: %p ", view);
fprintf(out, "\n");
DumpFrames(out, aPresContext, aRendContext, child, aLevel+1);
@ -4895,8 +4892,7 @@ void DumpLayoutData(char* aTitleStr,
//DumpFrames(fd, aPresContext, renderingContext, aRootFrame, 0);
fprintf(fd, "---------------------------------------\n\n");
fprintf(fd, "--------------- Views From Root Frame----------------\n");
nsIView * v;
aRootFrame->GetView(aPresContext, &v);
nsIView* v = aRootFrame->GetView(aPresContext);
if (v) {
v->List(fd);
} else {

View File

@ -533,21 +533,8 @@ nsSVGOuterSVGFrame::AppendFrames(nsIPresContext* aPresContext,
// get the view manager, so that we can wrap this up in a batch
// update.
NS_ENSURE_TRUE(mPresShell, NS_ERROR_FAILURE);
nsCOMPtr<nsIPresContext> presCtx;
mPresShell->GetPresContext(getter_AddRefs(presCtx));
NS_ENSURE_TRUE(presCtx, NS_ERROR_FAILURE);
nsIView* view = nsnull;
GetView(presCtx, &view);
if (!view) {
nsIFrame* frame;
GetParentWithView(presCtx, &frame);
if (frame)
frame->GetView(presCtx, &view);
}
NS_ENSURE_TRUE(view, NS_ERROR_FAILURE);
nsCOMPtr<nsIViewManager> vm;
view->GetViewManager(*getter_AddRefs(vm));
mPresShell->GetViewManager(getter_AddRefs(vm));
vm->BeginUpdateViewBatch();
@ -594,21 +581,8 @@ nsSVGOuterSVGFrame::InsertFrames(nsIPresContext* aPresContext,
// get the view manager, so that we can wrap this up in a batch
// update.
NS_ENSURE_TRUE(mPresShell, NS_ERROR_FAILURE);
nsCOMPtr<nsIPresContext> presCtx;
mPresShell->GetPresContext(getter_AddRefs(presCtx));
NS_ENSURE_TRUE(presCtx, NS_ERROR_FAILURE);
nsIView* view = nsnull;
GetView(presCtx, &view);
if (!view) {
nsIFrame* frame;
GetParentWithView(presCtx, &frame);
if (frame)
frame->GetView(presCtx, &view);
}
NS_ENSURE_TRUE(view, NS_ERROR_FAILURE);
nsCOMPtr<nsIViewManager> vm;
view->GetViewManager(*getter_AddRefs(vm));
mPresShell->GetViewManager(getter_AddRefs(vm));
vm->BeginUpdateViewBatch();
@ -653,21 +627,8 @@ nsSVGOuterSVGFrame::RemoveFrame(nsIPresContext* aPresContext,
// get the view manager, so that we can wrap this up in a batch
// update.
NS_ENSURE_TRUE(mPresShell, NS_ERROR_FAILURE);
nsCOMPtr<nsIPresContext> presCtx;
mPresShell->GetPresContext(getter_AddRefs(presCtx));
NS_ENSURE_TRUE(presCtx, NS_ERROR_FAILURE);
nsIView* view = nsnull;
GetView(presCtx, &view);
if (!view) {
nsIFrame* frame;
GetParentWithView(presCtx, &frame);
if (frame)
frame->GetView(presCtx, &view);
}
NS_ENSURE_TRUE(view, NS_ERROR_FAILURE);
nsCOMPtr<nsIViewManager> vm;
view->GetViewManager(*getter_AddRefs(vm));
mPresShell->GetViewManager(getter_AddRefs(vm));
vm->BeginUpdateViewBatch();
@ -868,23 +829,15 @@ nsSVGOuterSVGFrame::InvalidateRegion(ArtUta* uta, PRBool bRedraw)
{
// NS_ASSERTION(mView, "need a view!");
// if (!mView) return NS_ERROR_FAILURE;
if (!uta && !bRedraw) return NS_OK;
NS_ENSURE_TRUE(mPresShell, NS_ERROR_FAILURE);
nsCOMPtr<nsIPresContext> presCtx;
mPresShell->GetPresContext(getter_AddRefs(presCtx));
NS_ENSURE_TRUE(presCtx, NS_ERROR_FAILURE);
nsIView* view = nsnull;
GetView(presCtx, &view);
if (!view) {
nsIFrame* frame;
GetParentWithView(presCtx, &frame);
if (frame)
frame->GetView(presCtx, &view);
}
nsIView* view = GetClosestView(presCtx);
NS_ENSURE_TRUE(view, NS_ERROR_FAILURE);
if (!uta && !bRedraw) return NS_OK;
nsCOMPtr<nsIViewManager> vm;
view->GetViewManager(*getter_AddRefs(vm));
@ -932,21 +885,8 @@ nsSVGOuterSVGFrame::NotifyRedrawSuspended()
// get the view manager, so that we can wrap this up in a batch
// update.
NS_ENSURE_TRUE(mPresShell, NS_ERROR_FAILURE);
nsCOMPtr<nsIPresContext> presCtx;
mPresShell->GetPresContext(getter_AddRefs(presCtx));
NS_ENSURE_TRUE(presCtx, NS_ERROR_FAILURE);
nsIView* view = nsnull;
GetView(presCtx, &view);
if (!view) {
nsIFrame* frame;
GetParentWithView(presCtx, &frame);
if (frame)
frame->GetView(presCtx, &view);
}
NS_ENSURE_TRUE(view, NS_ERROR_FAILURE);
nsCOMPtr<nsIViewManager> vm;
view->GetViewManager(*getter_AddRefs(vm));
mPresShell->GetViewManager(getter_AddRefs(vm));
vm->BeginUpdateViewBatch();
@ -976,22 +916,8 @@ nsSVGOuterSVGFrame::NotifyRedrawUnsuspended()
// get the view manager, so that we can wrap this up in a batch
// update.
NS_ENSURE_TRUE(mPresShell, NS_ERROR_FAILURE);
nsCOMPtr<nsIPresContext> presCtx;
mPresShell->GetPresContext(getter_AddRefs(presCtx));
NS_ENSURE_TRUE(presCtx, NS_ERROR_FAILURE);
nsIView* view = nsnull;
GetView(presCtx, &view);
if (!view) {
nsIFrame* frame;
GetParentWithView(presCtx, &frame);
if (frame)
frame->GetView(presCtx, &view);
}
NS_ENSURE_TRUE(view, NS_ERROR_FAILURE);
nsCOMPtr<nsIViewManager> vm;
view->GetViewManager(*getter_AddRefs(vm));
mPresShell->GetViewManager(getter_AddRefs(vm));
nsIFrame* kid = mFrames.FirstChild();
while (kid) {

View File

@ -635,10 +635,7 @@ void nsTableRowFrame::PaintChildren(nsIPresContext* aPresContext,
{
nsIFrame* kid = mFrames.FirstChild();
while (nsnull != kid) {
nsIView *pView;
kid->GetView(aPresContext, &pView);
if (nsnull == pView) {
if (!kid->HasView()) {
nsRect kidRect;
kid->GetRect(kidRect);
nsRect damageArea;

View File

@ -254,10 +254,7 @@ void nsTableRowGroupFrame::PaintChildren(nsIPresContext* aPresContext,
{
nsIFrame* kid = GetFirstFrame();
while (nsnull != kid) {
nsIView *pView;
kid->GetView(aPresContext, &pView);
if (nsnull == pView) {
if (!kid->HasView()) {
PRBool clipState;
nsRect kidRect;
kid->GetRect(kidRect);

View File

@ -618,12 +618,11 @@ nsBox::SetBounds(nsBoxLayoutState& aState, const nsRect& aRect)
/*
// only if the origin changed
if ((rect.x != aRect.x) || (rect.y != aRect.y)) {
nsIView* view;
frame->GetView(presContext, &view);
if (view) {
nsContainerFrame::PositionFrameView(presContext, frame, view);
if (frame->HasView()) {
nsContainerFrame::PositionFrameView(presContext, frame,
frame->GetView(presContext));
} else {
nsContainerFrame::PositionChildViews(presContext, frame);
nsContainerFrame::PositionChildViews(presContext, frame);
}
}
*/
@ -846,8 +845,7 @@ nsBox::CollapseChild(nsBoxLayoutState& aState, nsIFrame* aFrame, PRBool aHide)
nsIPresContext* presContext = aState.GetPresContext();
// shrink the view
nsIView* view = nsnull;
aFrame->GetView(presContext, &view);
nsIView* view = aFrame->GetView(presContext);
// if we find a view stop right here. All views under it
// will be clipped.
@ -1111,8 +1109,7 @@ nsBox::SyncLayout(nsBoxLayoutState& aState)
flags |= stateFlags;
nsIView* view;
frame->GetView(presContext, &view);
nsIView* view = frame->GetView(presContext);
/*
// only if the origin changed
@ -1182,23 +1179,18 @@ nsBox::Redraw(nsBoxLayoutState& aState,
}
PRUint32 flags = aImmediate ? NS_VMREFRESH_IMMEDIATE : NS_VMREFRESH_NO_SYNC;
nsIView* view;
frame->GetView(presContext, &view);
if (view) {
view->GetViewManager(*getter_AddRefs(viewManager));
viewManager->UpdateView(view, damageRect, flags);
nsIView *view;
if (frame->HasView()) {
view = frame->GetView(presContext);
} else {
nsRect rect(damageRect);
nsPoint offset;
frame->GetOffsetFromView(presContext, offset, &view);
NS_BOX_ASSERTION(this, nsnull != view, "no view");
rect += offset;
view->GetViewManager(*getter_AddRefs(viewManager));
viewManager->UpdateView(view, rect, flags);
damageRect += offset;
}
view->GetViewManager(*getter_AddRefs(viewManager));
viewManager->UpdateView(view, damageRect, flags);
return NS_OK;
}

View File

@ -269,13 +269,11 @@ nsBoxFrame::Init(nsIPresContext* aPresContext,
PRBool needsWidget = PR_FALSE;
parent->ChildrenMustHaveWidgets(needsWidget);
if (needsWidget) {
nsIView* view = nsnull;
GetView(aPresContext, &view);
if (!view) {
if (!HasView()) {
nsHTMLContainerFrame::CreateViewForFrame(aPresContext,this,mStyleContext,nsnull,PR_TRUE);
GetView(aPresContext, &view);
}
nsIView* view = GetView(aPresContext);
nsCOMPtr<nsIWidget> widget;
view->GetWidget(*getter_AddRefs(widget));
@ -1482,9 +1480,7 @@ nsBoxFrame::PaintChild(nsIPresContext* aPresContext,
if (aFrame->GetStyleVisibility()->mVisible == NS_STYLE_VISIBILITY_COLLAPSE)
return;
nsIView *pView;
aFrame->GetView(aPresContext, &pView);
if (nsnull == pView) {
if (!aFrame->HasView()) {
nsRect kidRect;
aFrame->GetRect(kidRect);
@ -1994,10 +1990,9 @@ nsBoxFrame::TranslateEventCoords(nsIPresContext* aPresContext,
// If we have a view then the event coordinates are already relative
// to this frame; otherwise we have to adjust the coordinates
// appropriately.
nsIView* view;
GetView(aPresContext, &view);
if (nsnull == view) {
if (!HasView()) {
nsPoint offset;
nsIView* view;
GetOffsetFromView(aPresContext, offset, &view);
if (nsnull != view) {
x -= offset.x;
@ -2456,10 +2451,8 @@ nsBoxFrame::CreateViewForFrame(nsIPresContext* aPresContext,
nsStyleContext* aStyleContext,
PRBool aForce)
{
nsIView* view;
aFrame->GetView(aPresContext, &view);
// If we don't yet have a view, see if we need a view
if (nsnull == view) {
if (!aFrame->HasView()) {
PRInt32 zIndex = 0;
PRBool autoZIndex = PR_FALSE;
PRBool fixedBackgroundAttachment = PR_FALSE;
@ -2496,16 +2489,14 @@ nsBoxFrame::CreateViewForFrame(nsIPresContext* aPresContext,
if (aForce) {
// Create a view
nsIFrame* parent;
aFrame->GetParentWithView(aPresContext, &parent);
NS_ASSERTION(parent, "GetParentWithView failed");
nsIView* parentView;
parent->GetView(aPresContext, &parentView);
nsIView* parentView = parent->GetView(aPresContext);
NS_ASSERTION(parentView, "no parent with view");
// Create a view
static NS_DEFINE_IID(kViewCID, NS_VIEW_CID);
nsIView *view;
nsresult result = CallCreateInstance(kViewCID, &view);
if (NS_SUCCEEDED(result)) {
nsIViewManager* viewManager;

View File

@ -309,10 +309,8 @@ nsBoxObject::GetScreenRect(nsRect& aRect)
while (frame) {
// Look for a widget so we can get screen coordinates
nsIView* view;
rv = frame->GetView(presContext, &view);
if (view) {
rv = view->GetWidget(*getter_AddRefs(widget));
if (frame->HasView()) {
frame->GetView(presContext)->GetWidget(*getter_AddRefs(widget));
if (widget)
break;
}

View File

@ -176,14 +176,12 @@ nsBoxToBlockAdaptor::SetParentBox(nsIBox* aParent)
if (needsWidget) {
nsCOMPtr<nsIPresContext> context;
mPresShell->GetPresContext(getter_AddRefs(context));
nsIView* view = nsnull;
mFrame->GetView(context, &view);
if (!view) {
if (!mFrame->HasView()) {
nsStyleContext* style = mFrame->GetStyleContext();
nsHTMLContainerFrame::CreateViewForFrame(context,mFrame,style,nsnull,PR_TRUE);
mFrame->GetView(context, &view);
}
nsIView* view = mFrame->GetView(context);
nsCOMPtr<nsIWidget> widget;
view->GetWidget(*getter_AddRefs(widget));

View File

@ -142,8 +142,7 @@ nsDeckFrame::HideBox(nsIPresContext* aPresContext, nsIBox* aBox)
nsIFrame* frame = nsnull;
aBox->GetFrame(&frame);
nsIView* view = nsnull;
frame->GetView(aPresContext, &view);
nsIView* view = frame->GetView(aPresContext);
if (view) {
nsCOMPtr<nsIViewManager> viewManager;
@ -162,8 +161,7 @@ nsDeckFrame::ShowBox(nsIPresContext* aPresContext, nsIBox* aBox)
nsRect rect;
frame->GetRect(rect);
nsIView* view = nsnull;
frame->GetView(aPresContext, &view);
nsIView* view = frame->GetView(aPresContext);
if (view) {
nsCOMPtr<nsIViewManager> viewManager;
view->GetViewManager(*getter_AddRefs(viewManager));

View File

@ -219,9 +219,7 @@ nsGroupBoxFrame::Paint(nsIPresContext* aPresContext,
#ifdef DEBUG
if ((NS_FRAME_PAINT_LAYER_DEBUG == aWhichLayer) && GetShowFrameBorders()) {
nsIView* view;
GetView(aPresContext, &view);
if (nsnull != view) {
if (HasView()) {
aRenderingContext.SetColor(NS_RGB(0,0,255));
}
else {

View File

@ -114,13 +114,10 @@ nsLeafBoxFrame::Init(nsIPresContext* aPresContext,
PRBool needsWidget = PR_FALSE;
parent->ChildrenMustHaveWidgets(needsWidget);
if (needsWidget) {
nsIView* view = nsnull;
GetView(aPresContext, &view);
if (!view) {
if (!HasView()) {
nsHTMLContainerFrame::CreateViewForFrame(aPresContext,this,mStyleContext,nsnull,PR_TRUE);
GetView(aPresContext, &view);
}
nsIView* view = GetView(aPresContext);
nsCOMPtr<nsIWidget> widget;
view->GetWidget(*getter_AddRefs(widget));

View File

@ -555,30 +555,15 @@ nsListBoxBodyFrame::ScrollByLines(PRInt32 aNumLines)
// we have to do a sync update for mac because if we scroll too quickly
// w/out going back to the main event loop we can easily scroll the wrong
// bits and it looks like garbage (bug 63465).
nsIFrame* frame = nsnull;
if (NS_FAILED(QueryInterface(NS_GET_IID(nsIFrame), (void **)&frame)))
return NS_ERROR_FAILURE;
nsIView* view = nsnull;
frame->GetView(mPresContext, &view);
if (!view) {
nsIFrame* frameWithView;
frame->GetParentWithView(mPresContext, &frameWithView);
if (frameWithView)
frameWithView->GetView(mPresContext, &view);
else
return NS_ERROR_FAILURE;
}
if (view) {
nsCOMPtr<nsIViewManager> vm;
if (view->GetViewManager(*getter_AddRefs(vm)) && nsnull != vm) {
// I'd use Composite here, but it doesn't always work.
// vm->Composite();
vm->ForceUpdate();
}
}
nsCOMPtr<nsIPresShell> shell;
mPresContext->GetShell(getter_AddRefs(shell));
nsCOMPtr<nsIViewManager> vm;
shell->GetViewManager(getter_AddRefs(vm));
// I'd use Composite here, but it doesn't always work.
// vm->Composite();
vm->ForceUpdate();
return NS_OK;
}

View File

@ -657,8 +657,7 @@ nsMenuFrame::ActivateMenu(PRBool aActivateFlag)
if (aActivateFlag) {
nsRect rect;
menuPopup->GetRect(rect);
nsIView* view = nsnull;
menuPopup->GetView(mPresContext, &view);
nsIView* view = menuPopup->GetView(mPresContext);
nsCOMPtr<nsIViewManager> viewManager;
view->GetViewManager(*getter_AddRefs(viewManager));
rect.x = rect.y = 0;
@ -679,8 +678,7 @@ nsMenuFrame::ActivateMenu(PRBool aActivateFlag)
viewManager->SetViewVisibility(view, nsViewVisibility_kShow);
} else {
nsIView* view = nsnull;
menuPopup->GetView(mPresContext, &view);
nsIView* view = menuPopup->GetView(mPresContext);
NS_ASSERTION(view, "View is gone, looks like someone forgot to rollup the popup!");
if (view) {
nsCOMPtr<nsIViewManager> viewManager;
@ -840,8 +838,7 @@ nsMenuFrame::OpenMenuInternal(PRBool aActivateFlag)
menuPopup->SetBounds(state, nsRect(0,0,mLastPref.width, mLastPref.height));
nsIView* view = nsnull;
menuPopup->GetView(mPresContext, &view);
nsIView* view = menuPopup->GetView(mPresContext);
nsCOMPtr<nsIViewManager> vm;
view->GetViewManager(*getter_AddRefs(vm));
if (vm) {
@ -1075,8 +1072,7 @@ nsMenuFrame::DoLayout(nsBoxLayoutState& aState)
// Only size the popups view if open.
if (mMenuOpen) {
nsIView* view = nsnull;
popupChild->GetView(aState.GetPresContext(), &view);
nsIView* view = popupChild->GetView(aState.GetPresContext());
nsCOMPtr<nsIViewManager> viewManager;
view->GetViewManager(*getter_AddRefs(viewManager));
nsRect r(0, 0, bounds.width, bounds.height);

View File

@ -192,8 +192,7 @@ nsMenuPopupFrame::Init(nsIPresContext* aPresContext,
// Now that we've made a view, remove it and insert it at the correct
// position in the view hierarchy (as the root view). We do this so that we
// can draw the menus outside the confines of the window.
nsIView* ourView;
GetView(aPresContext, &ourView);
nsIView* ourView = GetView(aPresContext);
nsCOMPtr<nsIViewManager> viewManager;
ourView->GetViewManager(*getter_AddRefs(viewManager));
@ -528,9 +527,7 @@ nsMenuPopupFrame::GetRootViewForPopup(nsIPresContext* aPresContext,
}
if (parentWithView) {
nsIView* view = nsnull;
nsIView* temp = nsnull;
parentWithView->GetView(aPresContext, &view);
nsIView* view = parentWithView->GetView(aPresContext);
NS_ASSERTION(view, "GetParentWithView returned frame with no view!");
nsIView* rootView = nsnull;
if (aStopAtViewManagerRoot) {
@ -560,6 +557,7 @@ nsMenuPopupFrame::GetRootViewForPopup(nsIPresContext* aPresContext,
return;
}
nsIView* temp = nsnull;
view->GetParent(temp);
if (!temp) {
// Otherwise, we've walked all the way up to the root view and not
@ -910,8 +908,7 @@ nsMenuPopupFrame::SyncViewWithFrame(nsIPresContext* aPresContext,
// |view|
// The root view for the popup window widget associated with this frame,
// or, the view associated with this frame.
nsIView* view = nsnull;
GetView(aPresContext, &view);
nsIView* view = GetView(aPresContext);
///////////////////////////////////////////////////////////////////////////////
//
@ -1497,9 +1494,9 @@ nsIScrollableView* nsMenuPopupFrame::GetScrollableView(nsIFrame* aStart)
// try start frame and siblings
currFrame=aStart;
do {
currFrame->GetView(mPresContext, &view);
view = currFrame->GetView(mPresContext);
if ( view )
view->QueryInterface(NS_GET_IID(nsIScrollableView), (void**)&scrollableView);
CallQueryInterface(view, &scrollableView);
if ( scrollableView )
return scrollableView;
currFrame->GetNextSibling(&currFrame);
@ -2343,8 +2340,7 @@ nsMenuPopupFrame::MoveTo(PRInt32 aLeft, PRInt32 aTop)
mContent->SetAttr(kNameSpaceID_None, nsXULAtoms::left, left, PR_FALSE);
mContent->SetAttr(kNameSpaceID_None, nsXULAtoms::top, top, PR_FALSE);
nsIView* view = nsnull;
GetView(mPresContext, &view);
nsIView* view = GetView(mPresContext);
// Retrieve screen position of parent view
nsIView* parentView = nsnull;

View File

@ -111,8 +111,7 @@ nsNativeScrollbarFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent,
// suit. We don't have to lift a finger!
static NS_DEFINE_IID(kScrollbarCID, NS_NATIVESCROLLBAR_CID);
if ( NS_SUCCEEDED(CreateViewForFrame(aPresContext, this, aContext, PR_TRUE)) ) {
nsIView* myView = nsnull;
GetView(aPresContext, &myView);
nsIView* myView = GetView(aPresContext);
if ( myView ) {
nsWidgetInitData widgetData;
if ( NS_SUCCEEDED(myView->CreateWidget(kScrollbarCID, &widgetData, nsnull)) ) {

View File

@ -271,8 +271,7 @@ nsPopupSetFrame::DoLayout(nsBoxLayoutState& aState)
// only size popup if open
if (currEntry->mCreateHandlerSucceeded) {
nsIView* view = nsnull;
popupChild->GetView(aState.GetPresContext(), &view);
nsIView* view = popupChild->GetView(aState.GetPresContext());
nsCOMPtr<nsIViewManager> viewManager;
view->GetViewManager(*getter_AddRefs(viewManager));
nsRect r(0, 0, bounds.width, bounds.height);
@ -568,9 +567,8 @@ nsPopupSetFrame::ActivatePopup(nsPopupFrameList* aEntry, PRBool aActivateFlag)
// since we could be cleaning up after someone that didn't correctly
// destroy the popup.
nsIFrame* activeChild = aEntry->mPopupFrame;
nsIView* view = nsnull;
if (activeChild) {
activeChild->GetView(mPresContext, &view);
nsIView* view = activeChild->GetView(mPresContext);
NS_ASSERTION(view, "View is gone, looks like someone forgot to roll up the popup!");
if (view) {
nsCOMPtr<nsIViewManager> viewManager;

View File

@ -222,9 +222,9 @@ nsScrollBoxFrame::GetScrollingParentView(nsIPresContext* aPresContext,
nsIFrame* aParent,
nsIView** aParentView)
{
nsresult rv = aParent->GetView(aPresContext, aParentView);
*aParentView = aParent->GetView(aPresContext);
NS_ASSERTION(aParentView, "GetParentWithView failed");
return(rv);
return NS_OK;
}
nsresult
@ -383,10 +383,9 @@ nsScrollBoxFrame::DoLayout(nsBoxLayoutState& aState)
SyncLayout(aState);
if (adaptor) {
nsIView* view;
nsIFrame* frame;
kid->GetFrame(&frame);
frame->GetView(presContext, &view);
nsIView* view = frame->GetView(presContext);
nsRect r(0, 0, childRect.width, childRect.height);
nsContainerFrame::SyncFrameViewAfterReflow(presContext, frame, view, &r,
@ -394,8 +393,7 @@ nsScrollBoxFrame::DoLayout(nsBoxLayoutState& aState)
}
nsIScrollableView* scrollingView;
nsIView* view;
GetView(presContext, &view);
nsIView* view = GetView(presContext);
if (NS_SUCCEEDED(CallQueryInterface(view, &scrollingView))) {
scrollingView->ComputeScrollOffsets(PR_TRUE);
}
@ -468,8 +466,7 @@ nsScrollBoxFrame::DoLayout(nsBoxLayoutState& aState)
// it. if it does then the user must have moved it, and we no longer
// need to restore.
nsIPresContext* presContext = aState.GetPresContext();
nsIView* view;
GetView(presContext, &view);
nsIView* view = GetView(presContext);
if (!view)
return NS_OK; // don't freak out if we have no view
@ -677,8 +674,7 @@ nsScrollBoxFrame::SaveState(nsIPresContext* aPresContext,
nsCOMPtr<nsIPresState> state;
nsresult res = NS_OK;
nsIView* view;
GetView(aPresContext, &view);
nsIView* view = GetView(aPresContext);
NS_ENSURE_TRUE(view, NS_ERROR_FAILURE);
PRInt32 x,y;
@ -775,8 +771,7 @@ nsScrollBoxFrame::RestoreState(nsIPresContext* aPresContext,
// don't do it now, store it later and do it in layout.
if (NS_SUCCEEDED(res)) {
mRestoreRect.SetRect(x, y, w, h);
nsIView* view;
GetView(aPresContext, &view);
nsIView* view = GetView(aPresContext);
if (!view)
return NS_ERROR_FAILURE;

View File

@ -380,10 +380,9 @@ nsScrollBoxObject::GetScrollableView()
nsCOMPtr<nsIPresContext> context;
mPresShell->GetPresContext(getter_AddRefs(context));
nsIView* view;
frame->GetView(context, &view);
nsIScrollableView* scrollingView = nsnull;
if (NS_SUCCEEDED(view->QueryInterface(NS_GET_IID(nsIScrollableView), (void**)&scrollingView))) {
nsIView* view = frame->GetView(context);
nsIScrollableView* scrollingView;
if (NS_SUCCEEDED(CallQueryInterface(view, &scrollingView))) {
return scrollingView;
}

View File

@ -88,8 +88,7 @@ nsScrollbarFrame::Init(nsIPresContext* aPresContext,
{
nsresult rv = nsBoxFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
CreateViewForFrame(aPresContext,this,aContext,PR_TRUE);
nsIView* view;
GetView(aPresContext, &view);
nsIView* view = GetView(aPresContext);
nsCOMPtr<nsIViewManager> vm;
view->GetViewManager(*getter_AddRefs(vm));
vm->SetViewContentTransparency(view, PR_TRUE);

View File

@ -137,8 +137,7 @@ nsSliderFrame::Init(nsIPresContext* aPresContext,
}
CreateViewForFrame(aPresContext,this,aContext,PR_TRUE);
nsIView* view;
GetView(aPresContext, &view);
nsIView* view = GetView(aPresContext);
nsCOMPtr<nsIViewManager> vm;
view->GetViewManager(*getter_AddRefs(vm));
vm->SetViewContentTransparency(view, PR_TRUE);
@ -499,11 +498,10 @@ nsSliderFrame::HandleEvent(nsIPresContext* aPresContext,
{
// if we hit a scrollable view make sure we take into account
// how much we are scrolled.
nsIScrollableView* scrollingView;
nsIView* view;
parent->GetView(aPresContext, &view);
nsIView* view = parent->GetView(aPresContext);
if (view) {
nsresult result = view->QueryInterface(NS_GET_IID(nsIScrollableView), (void**)&scrollingView);
nsIScrollableView* scrollingView;
nsresult result = CallQueryInterface(view, &scrollingView);
if (NS_SUCCEEDED(result)) {
nscoord xoff = 0;
nscoord yoff = 0;
@ -538,20 +536,7 @@ nsSliderFrame::HandleEvent(nsIPresContext* aPresContext,
// in the coordinate system for the frame's contained view so that it
// matches aEvent->point's coordinate system.
nsIView *view = nsnull;
this->GetView(aPresContext, &view);
if (!view) {
// hmmmm, we don't have a contained view, let's
// just use our parent view.
nsIFrame *parent = nsnull;
GetParentWithView(aPresContext, &parent);
if (parent)
parent->GetView(aPresContext, &view);
}
nsIView *view = this->GetClosestView(aPresContext);
nsCOMPtr<nsIWidget> rootWidget;
@ -685,11 +670,10 @@ nsSliderFrame::HandleEvent(nsIPresContext* aPresContext,
{
// if we hit a scrollable view make sure we take into account
// how much we are scrolled.
nsIScrollableView* scrollingView;
nsIView* view;
parent->GetView(aPresContext, &view);
nsIView* view = parent->GetView(aPresContext);
if (view) {
nsresult result = view->QueryInterface(NS_GET_IID(nsIScrollableView), (void**)&scrollingView);
nsIScrollableView* scrollingView;
nsresult result = CallQueryInterface(view, &scrollingView);
if (NS_SUCCEEDED(result)) {
nscoord xoff = 0;
nscoord yoff = 0;
@ -988,12 +972,11 @@ nsSliderFrame::MouseDown(nsIDOMEvent* aMouseEvent)
while(parent != nsnull) {
// if we hit a scrollable view make sure we take into account
// how much we are scrolled.
nsIScrollableView* scrollingView;
nsIView* view;
// XXX hack
parent->GetView(mPresContext, &view);
nsIView* view = parent->GetView(mPresContext);
if (view) {
nsresult result = view->QueryInterface(NS_GET_IID(nsIScrollableView), (void**)&scrollingView);
nsIScrollableView* scrollingView;
nsresult result = CallQueryInterface(view, &scrollingView);
if (NS_SUCCEEDED(result)) {
nscoord xoff = 0;
nscoord yoff = 0;
@ -1067,8 +1050,7 @@ NS_IMETHODIMP
nsSliderFrame :: DragThumb(nsIPresContext* aPresContext, PRBool aGrabMouseEvents)
{
// get its view
nsIView* view = nsnull;
GetView(aPresContext, &view);
nsIView* view = GetView(aPresContext);
nsCOMPtr<nsIViewManager> viewMan;
PRBool result;
@ -1091,8 +1073,7 @@ PRBool
nsSliderFrame :: isDraggingThumb(nsIPresContext* aPresContext)
{
// get its view
nsIView* view = nsnull;
GetView(aPresContext, &view);
nsIView* view = GetView(aPresContext);
nsCOMPtr<nsIViewManager> viewMan;
if (view) {

View File

@ -368,8 +368,7 @@ nsSplitterFrame::Init(nsIPresContext* aPresContext,
mPresContext = aPresContext;
nsHTMLContainerFrame::CreateViewForFrame(aPresContext,this,aContext,nsnull,PR_TRUE);
nsIView* view;
GetView(aPresContext, &view);
nsIView* view = GetView(aPresContext);
nsCOMPtr<nsIViewManager> viewManager;
view->GetViewManager(*getter_AddRefs(viewManager));
@ -551,11 +550,10 @@ nsSplitterFrameInner::MouseDrag(nsIPresContext* aPresContext, nsGUIEvent* aEvent
{
// if we hit a scrollable view make sure we take into account
// how much we are scrolled.
nsIScrollableView* scrollingView;
nsIView* view;
parent->GetView(aPresContext, &view);
nsIView* view = parent->GetView(aPresContext);
if (view) {
nsresult result = view->QueryInterface(NS_GET_IID(nsIScrollableView), (void**)&scrollingView);
nsIScrollableView* scrollingView;
nsresult result = CallQueryInterface(view, &scrollingView);
if (NS_SUCCEEDED(result)) {
nscoord xoff = 0;
nscoord yoff = 0;
@ -698,8 +696,7 @@ nsresult
nsSplitterFrameInner :: CaptureMouse(nsIPresContext* aPresContext, PRBool aGrabMouseEvents)
{
// get its view
nsIView* view = nsnull;
mOuter->GetView(aPresContext, &view);
nsIView* view = mOuter->GetView(aPresContext);
nsCOMPtr<nsIViewManager> viewMan;
PRBool result;
//nsCOMPtr<nsIWidget> widget;
@ -728,8 +725,7 @@ PRBool
nsSplitterFrameInner :: IsMouseCaptured(nsIPresContext* aPresContext)
{
// get its view
nsIView* view = nsnull;
mOuter->GetView(aPresContext, &view);
nsIView* view = mOuter->GetView(aPresContext);
nsCOMPtr<nsIViewManager> viewMan;
if (view) {
@ -924,8 +920,7 @@ nsSplitterFrameInner::MouseDown(nsIDOMEvent* aMouseEvent)
mChildInfosAfterCount = 0;
nsRect vr(0,0,0,0);
nsIView *v;
mOuter->GetView(mOuter->mPresContext, &v);
nsIView *v = mOuter->GetView(mOuter->mPresContext);
v->GetBounds(vr);
PRInt32 c = 0;
@ -1081,8 +1076,7 @@ if (realTimeDrag) {
mParentBox->GetFrame(&frame);
nsCOMPtr<nsIViewManager> viewManager;
nsIView* view = nsnull;
frame->GetView(aPresContext, &view);
nsIView* view = frame->GetView(aPresContext);
if (!view) {
nsPoint offset;
@ -1266,8 +1260,7 @@ nsSplitterFrameInner::MoveSplitterBy(nsIPresContext* aPresContext, nscoord aDiff
const nsRect& r = mOuter->mRect;
nsRect vr;
nsCOMPtr<nsIViewManager> vm;
nsIView *v;
mOuter->GetView(aPresContext, &v);
nsIView *v = mOuter->GetView(aPresContext);
v->GetViewManager(*getter_AddRefs(vm));
v->GetBounds(vr);
nsRect invalid;

Some files were not shown because too many files have changed in this diff Show More