diff --git a/mozilla/accessible/src/base/nsAccessible.cpp b/mozilla/accessible/src/base/nsAccessible.cpp index 2973035a532..9eacf3700cb 100644 --- a/mozilla/accessible/src/base/nsAccessible.cpp +++ b/mozilla/accessible/src/base/nsAccessible.cpp @@ -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)); diff --git a/mozilla/content/base/src/nsPrintEngine.cpp b/mozilla/content/base/src/nsPrintEngine.cpp index 1d5db12d734..2d3313d4611 100644 --- a/mozilla/content/base/src/nsPrintEngine.cpp +++ b/mozilla/content/base/src/nsPrintEngine.cpp @@ -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 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 { diff --git a/mozilla/content/base/src/nsSelection.cpp b/mozilla/content/base/src/nsSelection.cpp index a56774f1458..10e7435e64b 100644 --- a/mozilla/content/base/src/nsSelection.cpp +++ b/mozilla/content/base/src/nsSelection.cpp @@ -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); diff --git a/mozilla/content/events/src/nsEventStateManager.cpp b/mozilla/content/events/src/nsEventStateManager.cpp index 163c20358d5..2cc5ceb5dd7 100644 --- a/mozilla/content/events/src/nsEventStateManager.cpp +++ b/mozilla/content/events/src/nsEventStateManager.cpp @@ -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 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 element(do_QueryInterface(child)); diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp index 4dc005b3ec5..74f9b945216 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp @@ -2990,30 +2990,29 @@ nsHTMLDocument::GetPixelDimensions(nsIPresShell* aShell, nsCOMPtr 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)) { diff --git a/mozilla/content/svg/content/src/nsSVGSVGElement.cpp b/mozilla/content/svg/content/src/nsSVGSVGElement.cpp index 9b624b610a2..c1066c76099 100644 --- a/mozilla/content/svg/content/src/nsSVGSVGElement.cpp +++ b/mozilla/content/svg/content/src/nsSVGSVGElement.cpp @@ -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; } diff --git a/mozilla/content/xul/content/src/nsXULElement.cpp b/mozilla/content/xul/content/src/nsXULElement.cpp index 0d1c43aaf1d..c78a9fd8766 100644 --- a/mozilla/content/xul/content/src/nsXULElement.cpp +++ b/mozilla/content/xul/content/src/nsXULElement.cpp @@ -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 widget; view->GetWidget(*getter_AddRefs(widget)); + // XXXldb Um, not all views have widgets... widget->HideWindowChrome(aShouldHide); } } diff --git a/mozilla/content/xul/document/src/nsXULDocument.cpp b/mozilla/content/xul/document/src/nsXULDocument.cpp index fec0e8e58b8..0884e5e3604 100644 --- a/mozilla/content/xul/document/src/nsXULDocument.cpp +++ b/mozilla/content/xul/document/src/nsXULDocument.cpp @@ -1684,33 +1684,30 @@ nsXULDocument::GetPixelDimensions(nsIPresShell* aShell, PRInt32* aWidth, result = aShell->GetPrimaryFrameFor(mRootContent, &frame); if (NS_SUCCEEDED(result) && frame) { - nsIView* view; nsCOMPtr 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)) { diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index 9c552391946..19da3a956df 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -3269,20 +3269,10 @@ nsDocShell::GetVisibility(PRBool * aVisibility) if (frame) { nsCOMPtr 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 presContext; GetPresContext(getter_AddRefs(presContext)); - nsIView* canvasView = nsnull; - frame->GetView(presContext, &canvasView); + nsIView* canvasView = frame->GetViewExternal(presContext); nsCOMPtr viewManager; canvasView->GetViewManager(*getter_AddRefs(viewManager)); diff --git a/mozilla/editor/libeditor/base/nsEditor.cpp b/mozilla/editor/libeditor/base/nsEditor.cpp index 401d4e957a4..d0027aa38fa 100644 --- a/mozilla/editor/libeditor/base/nsEditor.cpp +++ b/mozilla/editor/libeditor/base/nsEditor.cpp @@ -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) { diff --git a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp index b3749621443..1aadec20fe3 100644 --- a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp +++ b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp @@ -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; diff --git a/mozilla/extensions/inspector/base/src/inFlasher.cpp b/mozilla/extensions/inspector/base/src/inFlasher.cpp index 81ddb49c92b..a71f6b41c0e 100644 --- a/mozilla/extensions/inspector/base/src/inFlasher.cpp +++ b/mozilla/extensions/inspector/base/src/inFlasher.cpp @@ -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 viewManager; view->GetViewManager(*getter_AddRefs(viewManager)); if (viewManager) { diff --git a/mozilla/extensions/inspector/base/src/inLayoutUtils.cpp b/mozilla/extensions/inspector/base/src/inLayoutUtils.cpp index 142741ff99f..7162520cd08 100644 --- a/mozilla/extensions/inspector/base/src/inLayoutUtils.cpp +++ b/mozilla/extensions/inspector/base/src/inLayoutUtils.cpp @@ -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; diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index be8e465be42..71bbcc402b6 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -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 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 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; diff --git a/mozilla/layout/base/nsCSSRendering.cpp b/mozilla/layout/base/nsCSSRendering.cpp index 422e4d0bd57..5d9ecbe4730 100644 --- a/mozilla/layout/base/nsCSSRendering.cpp +++ b/mozilla/layout/base/nsCSSRendering.cpp @@ -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); diff --git a/mozilla/layout/base/nsFrameManager.cpp b/mozilla/layout/base/nsFrameManager.cpp index ca7156ceaac..4d0533d674c 100644 --- a/mozilla/layout/base/nsFrameManager.cpp +++ b/mozilla/layout/base/nsFrameManager.cpp @@ -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) { diff --git a/mozilla/layout/base/nsImageLoader.cpp b/mozilla/layout/base/nsImageLoader.cpp index 7fad0df0891..153d44ab58d 100644 --- a/mozilla/layout/base/nsImageLoader.cpp +++ b/mozilla/layout/base/nsImageLoader.cpp @@ -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; diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index bda9513a5c0..52f88f36b71 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -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 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; diff --git a/mozilla/layout/base/public/nsIFrame.h b/mozilla/layout/base/public/nsIFrame.h index 87878fd522c..1d19cb8016a 100644 --- a/mozilla/layout/base/public/nsIFrame.h +++ b/mozilla/layout/base/public/nsIFrame.h @@ -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 diff --git a/mozilla/layout/base/src/nsImageLoader.cpp b/mozilla/layout/base/src/nsImageLoader.cpp index 7fad0df0891..153d44ab58d 100644 --- a/mozilla/layout/base/src/nsImageLoader.cpp +++ b/mozilla/layout/base/src/nsImageLoader.cpp @@ -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; diff --git a/mozilla/layout/forms/nsComboboxControlFrame.cpp b/mozilla/layout/forms/nsComboboxControlFrame.cpp index 36935c4cd7c..c5c86caac44 100644 --- a/mozilla/layout/forms/nsComboboxControlFrame.cpp +++ b/mozilla/layout/forms/nsComboboxControlFrame.cpp @@ -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 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 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)); diff --git a/mozilla/layout/forms/nsFieldSetFrame.cpp b/mozilla/layout/forms/nsFieldSetFrame.cpp index 8bdff25d534..3864f2466d6 100644 --- a/mozilla/layout/forms/nsFieldSetFrame.cpp +++ b/mozilla/layout/forms/nsFieldSetFrame.cpp @@ -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 { diff --git a/mozilla/layout/forms/nsFormControlFrame.cpp b/mozilla/layout/forms/nsFormControlFrame.cpp index c6a7dd49bb1..ee83d251986 100644 --- a/mozilla/layout/forms/nsFormControlFrame.cpp +++ b/mozilla/layout/forms/nsFormControlFrame.cpp @@ -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 diff --git a/mozilla/layout/forms/nsImageControlFrame.cpp b/mozilla/layout/forms/nsImageControlFrame.cpp index 0a7fd55e0dc..368c96884ed 100644 --- a/mozilla/layout/forms/nsImageControlFrame.cpp +++ b/mozilla/layout/forms/nsImageControlFrame.cpp @@ -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 presShell; aPresContext->GetShell(getter_AddRefs(presShell)); nsCOMPtr 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); diff --git a/mozilla/layout/forms/nsListControlFrame.cpp b/mozilla/layout/forms/nsListControlFrame.cpp index cb6399f291d..41b4c511aa7 100644 --- a/mozilla/layout/forms/nsListControlFrame.cpp +++ b/mozilla/layout/forms/nsListControlFrame.cpp @@ -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???"); diff --git a/mozilla/layout/forms/nsTextControlFrame.cpp b/mozilla/layout/forms/nsTextControlFrame.cpp index 310d13f5554..78e6cbf3bba 100644 --- a/mozilla/layout/forms/nsTextControlFrame.cpp +++ b/mozilla/layout/forms/nsTextControlFrame.cpp @@ -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); diff --git a/mozilla/layout/generic/nsAbsoluteContainingBlock.cpp b/mozilla/layout/generic/nsAbsoluteContainingBlock.cpp index 79a30a5cb4b..c98852b5b22 100644 --- a/mozilla/layout/generic/nsAbsoluteContainingBlock.cpp +++ b/mozilla/layout/generic/nsAbsoluteContainingBlock.cpp @@ -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); diff --git a/mozilla/layout/generic/nsBlockFrame.cpp b/mozilla/layout/generic/nsBlockFrame.cpp index bbcdf3bf5f2..44064547c36 100644 --- a/mozilla/layout/generic/nsBlockFrame.cpp +++ b/mozilla/layout/generic/nsBlockFrame.cpp @@ -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); } diff --git a/mozilla/layout/generic/nsContainerFrame.cpp b/mozilla/layout/generic/nsContainerFrame.cpp index 3ed724fde69..2af9def7eab 100644 --- a/mozilla/layout/generic/nsContainerFrame.cpp +++ b/mozilla/layout/generic/nsContainerFrame.cpp @@ -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)); diff --git a/mozilla/layout/generic/nsFrame.cpp b/mozilla/layout/generic/nsFrame.cpp index 8e53f3fc357..fa19c9a7696 100644 --- a/mozilla/layout/generic/nsFrame.cpp +++ b/mozilla/layout/generic/nsFrame.cpp @@ -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 presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); - - if (presShell) { - nsCOMPtr 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 presShell; + aPresContext->GetShell(getter_AddRefs(presShell)); + + nsCOMPtr 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 presShell; aPresContext->GetShell(getter_AddRefs(presShell)); - if (presShell) { - nsCOMPtr frameManager; - presShell->GetFrameManager(getter_AddRefs(frameManager)); - - if (frameManager) { - frameManager->SetFrameProperty(this, nsLayoutAtoms::viewProperty, - aView, nsnull); - } - } + nsCOMPtr 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 vm; - view->GetViewManager(*getter_AddRefs(vm)); - vm->GetWidget(&window); - } + NS_NOTREACHED("this shouldn't happen, should it?"); + nsCOMPtr shell; + aPresContext->GetShell(getter_AddRefs(shell)); + nsCOMPtr 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, "\n", PRUptrdiff(mNextSibling)); } - nsIView* view; - GetView(aPresContext, &view); - if (view) { + if (HasView()) { IndentBy(out, aIndent); - fprintf(out, "\n", PRUptrdiff(view)); + fprintf(out, "\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 viewMan; PRBool result; if (view) { + nsCOMPtr 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 viewMan; + nsIView* view = GetClosestView(aPresContext); if (view) { + nsCOMPtr viewMan; view->GetViewManager(*getter_AddRefs(viewMan)); if (viewMan) { diff --git a/mozilla/layout/generic/nsFrame.h b/mozilla/layout/generic/nsFrame.h index 2865416919c..2d8ee93bb4d 100644 --- a/mozilla/layout/generic/nsFrame.h +++ b/mozilla/layout/generic/nsFrame.h @@ -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, diff --git a/mozilla/layout/generic/nsFrameFrame.cpp b/mozilla/layout/generic/nsFrameFrame.cpp index 5c9205d17c5..d9c699f8eff 100644 --- a/mozilla/layout/generic/nsFrameFrame.cpp +++ b/mozilla/layout/generic/nsFrameFrame.cpp @@ -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 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 diff --git a/mozilla/layout/generic/nsFrameSetFrame.cpp b/mozilla/layout/generic/nsFrameSetFrame.cpp index 6046a1b0fac..1d84e1561c3 100644 --- a/mozilla/layout/generic/nsFrameSetFrame.cpp +++ b/mozilla/layout/generic/nsFrameSetFrame.cpp @@ -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 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 viewMan; view->GetViewManager(*getter_AddRefs(viewMan)); diff --git a/mozilla/layout/generic/nsGfxScrollFrame.cpp b/mozilla/layout/generic/nsGfxScrollFrame.cpp index 9a56b92d389..6f9c4e4007e 100644 --- a/mozilla/layout/generic/nsGfxScrollFrame.cpp +++ b/mozilla/layout/generic/nsGfxScrollFrame.cpp @@ -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(¤tPoint.x, ¤tPoint.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); diff --git a/mozilla/layout/generic/nsHTMLContainerFrame.cpp b/mozilla/layout/generic/nsHTMLContainerFrame.cpp index e2d77b02a56..ebf7e4cca71 100644 --- a/mozilla/layout/generic/nsHTMLContainerFrame.cpp +++ b/mozilla/layout/generic/nsHTMLContainerFrame.cpp @@ -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); } diff --git a/mozilla/layout/generic/nsHTMLFrame.cpp b/mozilla/layout/generic/nsHTMLFrame.cpp index a4924345e4e..dcc3dbade3a 100644 --- a/mozilla/layout/generic/nsHTMLFrame.cpp +++ b/mozilla/layout/generic/nsHTMLFrame.cpp @@ -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; diff --git a/mozilla/layout/generic/nsIFrame.h b/mozilla/layout/generic/nsIFrame.h index 87878fd522c..1d19cb8016a 100644 --- a/mozilla/layout/generic/nsIFrame.h +++ b/mozilla/layout/generic/nsIFrame.h @@ -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 diff --git a/mozilla/layout/generic/nsImageFrame.cpp b/mozilla/layout/generic/nsImageFrame.cpp index 790fb65d9db..66cbb993786 100644 --- a/mozilla/layout/generic/nsImageFrame.cpp +++ b/mozilla/layout/generic/nsImageFrame.cpp @@ -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); diff --git a/mozilla/layout/generic/nsImageMap.cpp b/mozilla/layout/generic/nsImageMap.cpp index ff993bf7197..52e97e71e67 100644 --- a/mozilla/layout/generic/nsImageMap.cpp +++ b/mozilla/layout/generic/nsImageMap.cpp @@ -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; } diff --git a/mozilla/layout/generic/nsLineLayout.cpp b/mozilla/layout/generic/nsLineLayout.cpp index 743e8d5862c..666a0e284a6 100644 --- a/mozilla/layout/generic/nsLineLayout.cpp +++ b/mozilla/layout/generic/nsLineLayout.cpp @@ -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); diff --git a/mozilla/layout/generic/nsObjectFrame.cpp b/mozilla/layout/generic/nsObjectFrame.cpp index cde89502758..0f48a6a8849 100644 --- a/mozilla/layout/generic/nsObjectFrame.cpp +++ b/mozilla/layout/generic/nsObjectFrame.cpp @@ -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 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) { diff --git a/mozilla/layout/generic/nsPageContentFrame.cpp b/mozilla/layout/generic/nsPageContentFrame.cpp index 202746c761e..b06db87ecca 100644 --- a/mozilla/layout/generic/nsPageContentFrame.cpp +++ b/mozilla/layout/generic/nsPageContentFrame.cpp @@ -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); diff --git a/mozilla/layout/generic/nsPageFrame.cpp b/mozilla/layout/generic/nsPageFrame.cpp index a611cc44268..e251e8e9f1c 100644 --- a/mozilla/layout/generic/nsPageFrame.cpp +++ b/mozilla/layout/generic/nsPageFrame.cpp @@ -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 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 vm; view->GetViewManager(*getter_AddRefs(vm)); diff --git a/mozilla/layout/generic/nsPlaceholderFrame.cpp b/mozilla/layout/generic/nsPlaceholderFrame.cpp index da8138765c6..12a4650f9fb 100644 --- a/mozilla/layout/generic/nsPlaceholderFrame.cpp +++ b/mozilla/layout/generic/nsPlaceholderFrame.cpp @@ -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) { diff --git a/mozilla/layout/generic/nsSelection.cpp b/mozilla/layout/generic/nsSelection.cpp index a56774f1458..10e7435e64b 100644 --- a/mozilla/layout/generic/nsSelection.cpp +++ b/mozilla/layout/generic/nsSelection.cpp @@ -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); diff --git a/mozilla/layout/generic/nsSimplePageSequence.cpp b/mozilla/layout/generic/nsSimplePageSequence.cpp index 94b860534ef..bcba9f20e37 100644 --- a/mozilla/layout/generic/nsSimplePageSequence.cpp +++ b/mozilla/layout/generic/nsSimplePageSequence.cpp @@ -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 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"); diff --git a/mozilla/layout/generic/nsTextFrame.cpp b/mozilla/layout/generic/nsTextFrame.cpp index 36c75a2399f..18cf9a10ef0 100644 --- a/mozilla/layout/generic/nsTextFrame.cpp +++ b/mozilla/layout/generic/nsTextFrame.cpp @@ -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; diff --git a/mozilla/layout/html/base/src/nsAbsoluteContainingBlock.cpp b/mozilla/layout/html/base/src/nsAbsoluteContainingBlock.cpp index 79a30a5cb4b..c98852b5b22 100644 --- a/mozilla/layout/html/base/src/nsAbsoluteContainingBlock.cpp +++ b/mozilla/layout/html/base/src/nsAbsoluteContainingBlock.cpp @@ -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); diff --git a/mozilla/layout/html/base/src/nsBlockFrame.cpp b/mozilla/layout/html/base/src/nsBlockFrame.cpp index bbcdf3bf5f2..44064547c36 100644 --- a/mozilla/layout/html/base/src/nsBlockFrame.cpp +++ b/mozilla/layout/html/base/src/nsBlockFrame.cpp @@ -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); } diff --git a/mozilla/layout/html/base/src/nsContainerFrame.cpp b/mozilla/layout/html/base/src/nsContainerFrame.cpp index 3ed724fde69..2af9def7eab 100644 --- a/mozilla/layout/html/base/src/nsContainerFrame.cpp +++ b/mozilla/layout/html/base/src/nsContainerFrame.cpp @@ -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)); diff --git a/mozilla/layout/html/base/src/nsFrame.cpp b/mozilla/layout/html/base/src/nsFrame.cpp index 8e53f3fc357..fa19c9a7696 100644 --- a/mozilla/layout/html/base/src/nsFrame.cpp +++ b/mozilla/layout/html/base/src/nsFrame.cpp @@ -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 presShell; - aPresContext->GetShell(getter_AddRefs(presShell)); - - if (presShell) { - nsCOMPtr 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 presShell; + aPresContext->GetShell(getter_AddRefs(presShell)); + + nsCOMPtr 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 presShell; aPresContext->GetShell(getter_AddRefs(presShell)); - if (presShell) { - nsCOMPtr frameManager; - presShell->GetFrameManager(getter_AddRefs(frameManager)); - - if (frameManager) { - frameManager->SetFrameProperty(this, nsLayoutAtoms::viewProperty, - aView, nsnull); - } - } + nsCOMPtr 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 vm; - view->GetViewManager(*getter_AddRefs(vm)); - vm->GetWidget(&window); - } + NS_NOTREACHED("this shouldn't happen, should it?"); + nsCOMPtr shell; + aPresContext->GetShell(getter_AddRefs(shell)); + nsCOMPtr 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, "\n", PRUptrdiff(mNextSibling)); } - nsIView* view; - GetView(aPresContext, &view); - if (view) { + if (HasView()) { IndentBy(out, aIndent); - fprintf(out, "\n", PRUptrdiff(view)); + fprintf(out, "\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 viewMan; PRBool result; if (view) { + nsCOMPtr 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 viewMan; + nsIView* view = GetClosestView(aPresContext); if (view) { + nsCOMPtr viewMan; view->GetViewManager(*getter_AddRefs(viewMan)); if (viewMan) { diff --git a/mozilla/layout/html/base/src/nsFrame.h b/mozilla/layout/html/base/src/nsFrame.h index 2865416919c..2d8ee93bb4d 100644 --- a/mozilla/layout/html/base/src/nsFrame.h +++ b/mozilla/layout/html/base/src/nsFrame.h @@ -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, diff --git a/mozilla/layout/html/base/src/nsFrameManager.cpp b/mozilla/layout/html/base/src/nsFrameManager.cpp index ca7156ceaac..4d0533d674c 100644 --- a/mozilla/layout/html/base/src/nsFrameManager.cpp +++ b/mozilla/layout/html/base/src/nsFrameManager.cpp @@ -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) { diff --git a/mozilla/layout/html/base/src/nsGfxScrollFrame.cpp b/mozilla/layout/html/base/src/nsGfxScrollFrame.cpp index 9a56b92d389..6f9c4e4007e 100644 --- a/mozilla/layout/html/base/src/nsGfxScrollFrame.cpp +++ b/mozilla/layout/html/base/src/nsGfxScrollFrame.cpp @@ -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(¤tPoint.x, ¤tPoint.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); diff --git a/mozilla/layout/html/base/src/nsHRFrame.cpp b/mozilla/layout/html/base/src/nsHRFrame.cpp index 7fa42d5f649..1c4647bf23c 100644 --- a/mozilla/layout/html/base/src/nsHRFrame.cpp +++ b/mozilla/layout/html/base/src/nsHRFrame.cpp @@ -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; diff --git a/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp b/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp index e2d77b02a56..ebf7e4cca71 100644 --- a/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp +++ b/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp @@ -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); } diff --git a/mozilla/layout/html/base/src/nsHTMLFrame.cpp b/mozilla/layout/html/base/src/nsHTMLFrame.cpp index a4924345e4e..dcc3dbade3a 100644 --- a/mozilla/layout/html/base/src/nsHTMLFrame.cpp +++ b/mozilla/layout/html/base/src/nsHTMLFrame.cpp @@ -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; diff --git a/mozilla/layout/html/base/src/nsImageFrame.cpp b/mozilla/layout/html/base/src/nsImageFrame.cpp index 790fb65d9db..66cbb993786 100644 --- a/mozilla/layout/html/base/src/nsImageFrame.cpp +++ b/mozilla/layout/html/base/src/nsImageFrame.cpp @@ -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); diff --git a/mozilla/layout/html/base/src/nsImageMap.cpp b/mozilla/layout/html/base/src/nsImageMap.cpp index ff993bf7197..52e97e71e67 100644 --- a/mozilla/layout/html/base/src/nsImageMap.cpp +++ b/mozilla/layout/html/base/src/nsImageMap.cpp @@ -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; } diff --git a/mozilla/layout/html/base/src/nsLineLayout.cpp b/mozilla/layout/html/base/src/nsLineLayout.cpp index 743e8d5862c..666a0e284a6 100644 --- a/mozilla/layout/html/base/src/nsLineLayout.cpp +++ b/mozilla/layout/html/base/src/nsLineLayout.cpp @@ -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); diff --git a/mozilla/layout/html/base/src/nsObjectFrame.cpp b/mozilla/layout/html/base/src/nsObjectFrame.cpp index cde89502758..0f48a6a8849 100644 --- a/mozilla/layout/html/base/src/nsObjectFrame.cpp +++ b/mozilla/layout/html/base/src/nsObjectFrame.cpp @@ -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 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) { diff --git a/mozilla/layout/html/base/src/nsPageContentFrame.cpp b/mozilla/layout/html/base/src/nsPageContentFrame.cpp index 202746c761e..b06db87ecca 100644 --- a/mozilla/layout/html/base/src/nsPageContentFrame.cpp +++ b/mozilla/layout/html/base/src/nsPageContentFrame.cpp @@ -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); diff --git a/mozilla/layout/html/base/src/nsPageFrame.cpp b/mozilla/layout/html/base/src/nsPageFrame.cpp index a611cc44268..e251e8e9f1c 100644 --- a/mozilla/layout/html/base/src/nsPageFrame.cpp +++ b/mozilla/layout/html/base/src/nsPageFrame.cpp @@ -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 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 vm; view->GetViewManager(*getter_AddRefs(vm)); diff --git a/mozilla/layout/html/base/src/nsPlaceholderFrame.cpp b/mozilla/layout/html/base/src/nsPlaceholderFrame.cpp index da8138765c6..12a4650f9fb 100644 --- a/mozilla/layout/html/base/src/nsPlaceholderFrame.cpp +++ b/mozilla/layout/html/base/src/nsPlaceholderFrame.cpp @@ -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) { diff --git a/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp index bda9513a5c0..52f88f36b71 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/layout/html/base/src/nsPresShell.cpp @@ -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 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; diff --git a/mozilla/layout/html/base/src/nsSimplePageSequence.cpp b/mozilla/layout/html/base/src/nsSimplePageSequence.cpp index 94b860534ef..bcba9f20e37 100644 --- a/mozilla/layout/html/base/src/nsSimplePageSequence.cpp +++ b/mozilla/layout/html/base/src/nsSimplePageSequence.cpp @@ -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 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"); diff --git a/mozilla/layout/html/base/src/nsTextFrame.cpp b/mozilla/layout/html/base/src/nsTextFrame.cpp index 36c75a2399f..18cf9a10ef0 100644 --- a/mozilla/layout/html/base/src/nsTextFrame.cpp +++ b/mozilla/layout/html/base/src/nsTextFrame.cpp @@ -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; diff --git a/mozilla/layout/html/document/src/nsFrameFrame.cpp b/mozilla/layout/html/document/src/nsFrameFrame.cpp index 5c9205d17c5..d9c699f8eff 100644 --- a/mozilla/layout/html/document/src/nsFrameFrame.cpp +++ b/mozilla/layout/html/document/src/nsFrameFrame.cpp @@ -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 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 diff --git a/mozilla/layout/html/document/src/nsFrameSetFrame.cpp b/mozilla/layout/html/document/src/nsFrameSetFrame.cpp index 6046a1b0fac..1d84e1561c3 100644 --- a/mozilla/layout/html/document/src/nsFrameSetFrame.cpp +++ b/mozilla/layout/html/document/src/nsFrameSetFrame.cpp @@ -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 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 viewMan; view->GetViewManager(*getter_AddRefs(viewMan)); diff --git a/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp b/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp index 36935c4cd7c..c5c86caac44 100644 --- a/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp @@ -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 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 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)); diff --git a/mozilla/layout/html/forms/src/nsFieldSetFrame.cpp b/mozilla/layout/html/forms/src/nsFieldSetFrame.cpp index 8bdff25d534..3864f2466d6 100644 --- a/mozilla/layout/html/forms/src/nsFieldSetFrame.cpp +++ b/mozilla/layout/html/forms/src/nsFieldSetFrame.cpp @@ -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 { diff --git a/mozilla/layout/html/forms/src/nsFormControlFrame.cpp b/mozilla/layout/html/forms/src/nsFormControlFrame.cpp index c6a7dd49bb1..ee83d251986 100644 --- a/mozilla/layout/html/forms/src/nsFormControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsFormControlFrame.cpp @@ -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 diff --git a/mozilla/layout/html/forms/src/nsImageControlFrame.cpp b/mozilla/layout/html/forms/src/nsImageControlFrame.cpp index 0a7fd55e0dc..368c96884ed 100644 --- a/mozilla/layout/html/forms/src/nsImageControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsImageControlFrame.cpp @@ -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 presShell; aPresContext->GetShell(getter_AddRefs(presShell)); nsCOMPtr 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); diff --git a/mozilla/layout/html/forms/src/nsListControlFrame.cpp b/mozilla/layout/html/forms/src/nsListControlFrame.cpp index cb6399f291d..41b4c511aa7 100644 --- a/mozilla/layout/html/forms/src/nsListControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsListControlFrame.cpp @@ -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???"); diff --git a/mozilla/layout/html/forms/src/nsTextControlFrame.cpp b/mozilla/layout/html/forms/src/nsTextControlFrame.cpp index 310d13f5554..78e6cbf3bba 100644 --- a/mozilla/layout/html/forms/src/nsTextControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsTextControlFrame.cpp @@ -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); diff --git a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp index be8e465be42..71bbcc402b6 100644 --- a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -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 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 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; diff --git a/mozilla/layout/html/style/src/nsCSSRendering.cpp b/mozilla/layout/html/style/src/nsCSSRendering.cpp index 422e4d0bd57..5d9ecbe4730 100644 --- a/mozilla/layout/html/style/src/nsCSSRendering.cpp +++ b/mozilla/layout/html/style/src/nsCSSRendering.cpp @@ -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); diff --git a/mozilla/layout/html/table/src/nsTableRowFrame.cpp b/mozilla/layout/html/table/src/nsTableRowFrame.cpp index fad2f95cee7..c6457860f61 100644 --- a/mozilla/layout/html/table/src/nsTableRowFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableRowFrame.cpp @@ -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; diff --git a/mozilla/layout/html/table/src/nsTableRowGroupFrame.cpp b/mozilla/layout/html/table/src/nsTableRowGroupFrame.cpp index fe8b51d29ed..82f7a939433 100644 --- a/mozilla/layout/html/table/src/nsTableRowGroupFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableRowGroupFrame.cpp @@ -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); diff --git a/mozilla/layout/printing/nsPrintEngine.cpp b/mozilla/layout/printing/nsPrintEngine.cpp index 1d5db12d734..2d3313d4611 100644 --- a/mozilla/layout/printing/nsPrintEngine.cpp +++ b/mozilla/layout/printing/nsPrintEngine.cpp @@ -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 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 { diff --git a/mozilla/layout/svg/base/src/nsSVGOuterSVGFrame.cpp b/mozilla/layout/svg/base/src/nsSVGOuterSVGFrame.cpp index 180f0265be5..efac87bf739 100644 --- a/mozilla/layout/svg/base/src/nsSVGOuterSVGFrame.cpp +++ b/mozilla/layout/svg/base/src/nsSVGOuterSVGFrame.cpp @@ -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 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 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 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 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 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 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 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 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 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 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 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 vm; - view->GetViewManager(*getter_AddRefs(vm)); - + mPresShell->GetViewManager(getter_AddRefs(vm)); nsIFrame* kid = mFrames.FirstChild(); while (kid) { diff --git a/mozilla/layout/tables/nsTableRowFrame.cpp b/mozilla/layout/tables/nsTableRowFrame.cpp index fad2f95cee7..c6457860f61 100644 --- a/mozilla/layout/tables/nsTableRowFrame.cpp +++ b/mozilla/layout/tables/nsTableRowFrame.cpp @@ -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; diff --git a/mozilla/layout/tables/nsTableRowGroupFrame.cpp b/mozilla/layout/tables/nsTableRowGroupFrame.cpp index fe8b51d29ed..82f7a939433 100644 --- a/mozilla/layout/tables/nsTableRowGroupFrame.cpp +++ b/mozilla/layout/tables/nsTableRowGroupFrame.cpp @@ -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); diff --git a/mozilla/layout/xul/base/src/nsBox.cpp b/mozilla/layout/xul/base/src/nsBox.cpp index edab94feefb..6d624e4f7fb 100644 --- a/mozilla/layout/xul/base/src/nsBox.cpp +++ b/mozilla/layout/xul/base/src/nsBox.cpp @@ -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; } diff --git a/mozilla/layout/xul/base/src/nsBoxFrame.cpp b/mozilla/layout/xul/base/src/nsBoxFrame.cpp index 7c83c008b24..78ba931ffb5 100644 --- a/mozilla/layout/xul/base/src/nsBoxFrame.cpp +++ b/mozilla/layout/xul/base/src/nsBoxFrame.cpp @@ -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 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; diff --git a/mozilla/layout/xul/base/src/nsBoxObject.cpp b/mozilla/layout/xul/base/src/nsBoxObject.cpp index c4de84059d1..a3991ca894b 100644 --- a/mozilla/layout/xul/base/src/nsBoxObject.cpp +++ b/mozilla/layout/xul/base/src/nsBoxObject.cpp @@ -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; } diff --git a/mozilla/layout/xul/base/src/nsBoxToBlockAdaptor.cpp b/mozilla/layout/xul/base/src/nsBoxToBlockAdaptor.cpp index 2b432c6d7e5..eff32f13634 100644 --- a/mozilla/layout/xul/base/src/nsBoxToBlockAdaptor.cpp +++ b/mozilla/layout/xul/base/src/nsBoxToBlockAdaptor.cpp @@ -176,14 +176,12 @@ nsBoxToBlockAdaptor::SetParentBox(nsIBox* aParent) if (needsWidget) { nsCOMPtr 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 widget; view->GetWidget(*getter_AddRefs(widget)); diff --git a/mozilla/layout/xul/base/src/nsDeckFrame.cpp b/mozilla/layout/xul/base/src/nsDeckFrame.cpp index 98fa1f769d6..788411b6474 100644 --- a/mozilla/layout/xul/base/src/nsDeckFrame.cpp +++ b/mozilla/layout/xul/base/src/nsDeckFrame.cpp @@ -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 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 viewManager; view->GetViewManager(*getter_AddRefs(viewManager)); diff --git a/mozilla/layout/xul/base/src/nsGroupBoxFrame.cpp b/mozilla/layout/xul/base/src/nsGroupBoxFrame.cpp index 4633ae04ae3..5ef153c441c 100644 --- a/mozilla/layout/xul/base/src/nsGroupBoxFrame.cpp +++ b/mozilla/layout/xul/base/src/nsGroupBoxFrame.cpp @@ -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 { diff --git a/mozilla/layout/xul/base/src/nsLeafBoxFrame.cpp b/mozilla/layout/xul/base/src/nsLeafBoxFrame.cpp index 60c6ee0a70e..9ed39434658 100644 --- a/mozilla/layout/xul/base/src/nsLeafBoxFrame.cpp +++ b/mozilla/layout/xul/base/src/nsLeafBoxFrame.cpp @@ -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 widget; view->GetWidget(*getter_AddRefs(widget)); diff --git a/mozilla/layout/xul/base/src/nsListBoxBodyFrame.cpp b/mozilla/layout/xul/base/src/nsListBoxBodyFrame.cpp index e3f39011192..222d39b7d0c 100644 --- a/mozilla/layout/xul/base/src/nsListBoxBodyFrame.cpp +++ b/mozilla/layout/xul/base/src/nsListBoxBodyFrame.cpp @@ -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 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 shell; + mPresContext->GetShell(getter_AddRefs(shell)); + nsCOMPtr vm; + shell->GetViewManager(getter_AddRefs(vm)); + // I'd use Composite here, but it doesn't always work. + // vm->Composite(); + vm->ForceUpdate(); + return NS_OK; } diff --git a/mozilla/layout/xul/base/src/nsMenuFrame.cpp b/mozilla/layout/xul/base/src/nsMenuFrame.cpp index a83da1c2767..2449b009af8 100644 --- a/mozilla/layout/xul/base/src/nsMenuFrame.cpp +++ b/mozilla/layout/xul/base/src/nsMenuFrame.cpp @@ -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 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 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 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 viewManager; view->GetViewManager(*getter_AddRefs(viewManager)); nsRect r(0, 0, bounds.width, bounds.height); diff --git a/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp b/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp index cf36154c629..d924a20d6d5 100644 --- a/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp +++ b/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp @@ -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 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; diff --git a/mozilla/layout/xul/base/src/nsNativeScrollbarFrame.cpp b/mozilla/layout/xul/base/src/nsNativeScrollbarFrame.cpp index 5bf6785f2b1..3eb7a380bb5 100644 --- a/mozilla/layout/xul/base/src/nsNativeScrollbarFrame.cpp +++ b/mozilla/layout/xul/base/src/nsNativeScrollbarFrame.cpp @@ -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)) ) { diff --git a/mozilla/layout/xul/base/src/nsPopupSetFrame.cpp b/mozilla/layout/xul/base/src/nsPopupSetFrame.cpp index f80164713fa..9c37dee6dc7 100644 --- a/mozilla/layout/xul/base/src/nsPopupSetFrame.cpp +++ b/mozilla/layout/xul/base/src/nsPopupSetFrame.cpp @@ -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 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 viewManager; diff --git a/mozilla/layout/xul/base/src/nsScrollBoxFrame.cpp b/mozilla/layout/xul/base/src/nsScrollBoxFrame.cpp index 75bbab82fb0..242ab387d47 100644 --- a/mozilla/layout/xul/base/src/nsScrollBoxFrame.cpp +++ b/mozilla/layout/xul/base/src/nsScrollBoxFrame.cpp @@ -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 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; diff --git a/mozilla/layout/xul/base/src/nsScrollBoxObject.cpp b/mozilla/layout/xul/base/src/nsScrollBoxObject.cpp index c296a271ae6..c5d69d2ede3 100644 --- a/mozilla/layout/xul/base/src/nsScrollBoxObject.cpp +++ b/mozilla/layout/xul/base/src/nsScrollBoxObject.cpp @@ -380,10 +380,9 @@ nsScrollBoxObject::GetScrollableView() nsCOMPtr 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; } diff --git a/mozilla/layout/xul/base/src/nsScrollbarFrame.cpp b/mozilla/layout/xul/base/src/nsScrollbarFrame.cpp index 8d28f9cb6e9..9eb9194524a 100644 --- a/mozilla/layout/xul/base/src/nsScrollbarFrame.cpp +++ b/mozilla/layout/xul/base/src/nsScrollbarFrame.cpp @@ -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 vm; view->GetViewManager(*getter_AddRefs(vm)); vm->SetViewContentTransparency(view, PR_TRUE); diff --git a/mozilla/layout/xul/base/src/nsSliderFrame.cpp b/mozilla/layout/xul/base/src/nsSliderFrame.cpp index 08d29e4e8e4..229975e0dd8 100644 --- a/mozilla/layout/xul/base/src/nsSliderFrame.cpp +++ b/mozilla/layout/xul/base/src/nsSliderFrame.cpp @@ -137,8 +137,7 @@ nsSliderFrame::Init(nsIPresContext* aPresContext, } CreateViewForFrame(aPresContext,this,aContext,PR_TRUE); - nsIView* view; - GetView(aPresContext, &view); + nsIView* view = GetView(aPresContext); nsCOMPtr 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 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 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 viewMan; if (view) { diff --git a/mozilla/layout/xul/base/src/nsSplitterFrame.cpp b/mozilla/layout/xul/base/src/nsSplitterFrame.cpp index adba2a20024..a5a5c0e0328 100644 --- a/mozilla/layout/xul/base/src/nsSplitterFrame.cpp +++ b/mozilla/layout/xul/base/src/nsSplitterFrame.cpp @@ -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 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 viewMan; PRBool result; //nsCOMPtr 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 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 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 vm; - nsIView *v; - mOuter->GetView(aPresContext, &v); + nsIView *v = mOuter->GetView(aPresContext); v->GetViewManager(*getter_AddRefs(vm)); v->GetBounds(vr); nsRect invalid; diff --git a/mozilla/layout/xul/base/src/nsTitleBarFrame.cpp b/mozilla/layout/xul/base/src/nsTitleBarFrame.cpp index c984e679b00..f386825e089 100644 --- a/mozilla/layout/xul/base/src/nsTitleBarFrame.cpp +++ b/mozilla/layout/xul/base/src/nsTitleBarFrame.cpp @@ -209,8 +209,7 @@ NS_IMETHODIMP nsTitleBarFrame::CaptureMouseEvents(nsIPresContext* aPresContext,PRBool aGrabMouseEvents) { // get its view - nsIView* view = nsnull; - GetView(aPresContext, &view); + nsIView* view = GetView(aPresContext); nsCOMPtr viewMan; PRBool result; diff --git a/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp b/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp index a08449655f0..dd7507ce4b0 100644 --- a/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp +++ b/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp @@ -406,8 +406,7 @@ nsTreeBodyFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent, mPresContext = aPresContext; nsresult rv = nsLeafBoxFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow); nsBoxFrame::CreateViewForFrame(aPresContext, this, aContext, PR_TRUE); - nsIView* ourView; - nsLeafBoxFrame::GetView(aPresContext, &ourView); + nsIView* ourView = nsLeafBoxFrame::GetView(aPresContext); static NS_DEFINE_CID(kWidgetCID, NS_CHILD_CID); @@ -1133,8 +1132,7 @@ nsTreeBodyFrame::AdjustEventCoordsToBoxCoordSpace (PRInt32 aX, PRInt32 aY, PRInt // Take into account the parent's scroll offset, since clientX and clientY // are relative to the viewport. - nsIView* parentView; - nsLeafBoxFrame::GetView(mPresContext, &parentView); + nsIView* parentView = nsLeafBoxFrame::GetView(mPresContext); parentView->GetParent(parentView); parentView->GetParent(parentView);