Don't use QueryInterface to get a view from a scrollable view b=258521 r+sr=roc

This commit is contained in:
neil%parkwaycc.co.uk 2004-09-20 22:25:07 +00:00
Родитель 03f4b6764f
Коммит 6a4f37de6b
20 изменённых файлов: 51 добавлений и 189 удалений

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

@ -443,11 +443,7 @@ void nsDocAccessible::GetBoundsRect(nsRect& aBounds, nsIFrame** aRelativeFrame)
nsRect viewBounds(0, 0, 0, 0);
if (scrollableView) {
const nsIView *view = nsnull;
scrollableView->GetClipView(&view);
if (view) {
viewBounds = view->GetBounds();
}
viewBounds = scrollableView->View()->GetBounds();
}
else {
nsIView *view;

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

@ -2903,7 +2903,6 @@ nsSelection::CommonPageMove(PRBool aForward,
// and remain relative position of the caret in view. see Bug 4302.
nsresult result;
const nsIView* clipView;
//get the frame from the scrollable view
nsIFrame* mainframe = nsnull;
@ -2922,9 +2921,7 @@ nsSelection::CommonPageMove(PRBool aForward,
return NS_ERROR_FAILURE;
// find out where we are; determine amount to page up/down
if (NS_FAILED(result = aScrollableView->GetClipView(&clipView)))
return result;
nsRect viewRect = clipView->GetBounds();
nsRect viewRect = aScrollableView->View()->GetBounds();
// find out where the caret is.
// we should know mDesiredX value of nsSelection, but I havent seen that behavior in other windows applications yet.
@ -5251,17 +5248,6 @@ nsTypedSelection::ScrollPointIntoClipView(nsPresContext *aPresContext, nsIView *
if (!scrollableView)
return NS_OK; // Nothing to do!
//
// Get the clip view.
//
const nsIView *cView = 0;
result = scrollableView->GetClipView(&cView);
if (NS_FAILED(result))
return result;
//
// Get the view that is being scrolled.
//
@ -5269,8 +5255,6 @@ nsTypedSelection::ScrollPointIntoClipView(nsPresContext *aPresContext, nsIView *
nsIView *scrolledView = 0;
result = scrollableView->GetScrolledView(scrolledView);
if (!cView)
return NS_ERROR_FAILURE;
//
// Now walk up aView's hierarchy, this time keeping track of
@ -5289,7 +5273,7 @@ nsTypedSelection::ScrollPointIntoClipView(nsPresContext *aPresContext, nsIView *
// If it is, scroll the view till it is inside the visible area!
//
nsRect bounds = cView->GetBounds();
nsRect bounds = scrollableView->View()->GetBounds();
result = scrollableView->GetScrollPosition(bounds.x,bounds.y);
@ -5445,9 +5429,7 @@ nsTypedSelection::ScrollPointIntoView(nsPresContext *aPresContext, nsIView *aVie
//
nsIView *scrolledView = 0;
nsIView *view = 0;
CallQueryInterface(scrollableView, &view);
nsIView *view = scrollableView->View();
if (view)
{
@ -5500,12 +5482,7 @@ nsTypedSelection::ScrollPointIntoView(nsPresContext *aPresContext, nsIView *aVie
// can scroll the next parent view.
//
view = 0;
result = CallQueryInterface(scrollableView, &view);
if (!view)
return result;
view = view->GetParent();
view = scrollableView->View()->GetParent();
}
}
}
@ -6976,14 +6953,7 @@ nsTypedSelection::GetSelectionRegionRectAndScrollableView(SelectionRegion aRegio
// padding!
//
const nsIView* clipView = 0;
result = (*aScrollableView)->GetClipView(&clipView);
if (NS_FAILED(result))
return result;
nsRect clipRect = clipView->GetBounds();
nsRect clipRect = (*aScrollableView)->View()->GetBounds();
result = (*aScrollableView)->GetScrollPosition(clipRect.x, clipRect.y);
@ -7072,10 +7042,7 @@ nsTypedSelection::ScrollRectIntoView(nsIScrollableView *aScrollableView,
// Determine the visible rect in the scrolled view's coordinate space.
// The size of the visible area is the clip view size
const nsIView* clipView;
aScrollableView->GetClipView(&clipView);
nsRect visibleRect = clipView->GetBounds();
nsRect visibleRect = aScrollableView->View()->GetBounds();
aScrollableView->GetScrollPosition(visibleRect.x, visibleRect.y);
// The actual scroll offsets
@ -7147,12 +7114,7 @@ nsTypedSelection::ScrollRectIntoView(nsIScrollableView *aScrollableView,
// Check if aScrollableRect has a parent scrollable view!
//
nsIView *view = 0;
rv = CallQueryInterface(aScrollableView, &view);
if (!view)
return rv;
view = view->GetParent();
nsIView *view = aScrollableView->View()->GetParent();
if (view)
{

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

@ -1690,17 +1690,11 @@ nsEventStateManager::DoScrollText(nsPresContext* aPresContext,
nsSize scrolledSize;
scrollView->GetContainerSize(&scrolledSize.width, &scrolledSize.height);
nsIView* portView = nsnull;
CallQueryInterface(scrollView, &portView);
if (portView) {
nsRect portRect = portView->GetBounds();
nsRect portRect = scrollView->View()->GetBounds();
passToParent = (aScrollHorizontal ?
(xPos + portRect.width >= scrolledSize.width) :
(yPos + portRect.height >= scrolledSize.height));
} else {
NS_WARNING("failed to get view from scrollview");
}
passToParent = (aScrollHorizontal ?
(xPos + portRect.width >= scrolledSize.width) :
(yPos + portRect.height >= scrolledSize.height));
}
// Comboboxes need special care.
@ -1742,10 +1736,7 @@ nsEventStateManager::DoScrollText(nsPresContext* aPresContext,
else
scrollView->ScrollByLines(scrollX, scrollY);
nsIView* updateView = nsnull;
CallQueryInterface(scrollView, &updateView);
if (updateView)
ForceViewUpdate(updateView);
ForceViewUpdate(scrollView->View());
}
if (passToParent) {
nsresult rv;

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

@ -1209,10 +1209,7 @@ nsGenericHTMLElement::GetClientHeight(PRInt32* aClientHeight)
GetScrollInfo(&scrollView, &p2t, &t2p, &frame);
if (scrollView) {
const nsIView *view = nsnull;
scrollView->GetClipView(&view);
nsRect r = view->GetBounds();
nsRect r = scrollView->View()->GetBounds();
*aClientHeight = NSTwipsToIntPixels(r.height, t2p);
} else if (frame &&
@ -1240,10 +1237,7 @@ nsGenericHTMLElement::GetClientWidth(PRInt32* aClientWidth)
GetScrollInfo(&scrollView, &p2t, &t2p, &frame);
if (scrollView) {
const nsIView *view = nsnull;
scrollView->GetClipView(&view);
nsRect r = view->GetBounds();
nsRect r = scrollView->View()->GetBounds();
*aClientWidth = NSTwipsToIntPixels(r.width, t2p);
} else if (frame &&

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

@ -391,15 +391,11 @@ nsImageDocument::RestoreImageTo(PRInt32 aX, PRInt32 aY)
if (!view)
return NS_OK;
nsIView* portView;
if (NS_FAILED(CallQueryInterface(view, &portView)))
return NS_OK;
nsSize scrolledSize;
if (NS_FAILED(view->GetContainerSize(&scrolledSize.width, &scrolledSize.height)))
return NS_OK;
nsRect portRect = portView->GetBounds();
nsRect portRect = view->View()->GetBounds();
view->ScrollTo((nscoord)(aX / (ratio * mImageWidth) * PR_MAX(0, scrolledSize.width - portRect.width) + 0.5),
(nscoord)(aY / (ratio * mImageHeight) * PR_MAX(0, scrolledSize.height - portRect.height) + 0.5),
NS_VMREFRESH_IMMEDIATE);

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

@ -1958,11 +1958,7 @@ GlobalWindowImpl::GetScrollMaxXY(PRInt32* aScrollMaxX, PRInt32* aScrollMaxY)
rv = view->GetContainerSize(&scrolledSize.width, &scrolledSize.height);
NS_ENSURE_SUCCESS(rv, rv);
nsIView* portView;
rv = CallQueryInterface(view, &portView);
NS_ENSURE_SUCCESS(rv, rv);
nsRect portRect = portView->GetBounds();
nsRect portRect = view->View()->GetBounds();
if (aScrollMaxX)
*aScrollMaxX = PR_MAX(0,

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

@ -784,11 +784,7 @@ void nsCaret::GetViewForRendering(nsIFrame *caretFrame, EViewCoordinates coordTy
if (scrollableView)
{
const nsIView* clipView = nsnull;
scrollableView->GetClipView(&clipView);
if (!clipView) return; // should always have one
nsRect bounds = clipView->GetBounds();
nsRect bounds = scrollableView->View()->GetBounds();
scrollableView->GetScrollPosition(bounds.x, bounds.y);
bounds += drawViewOffset; // offset to coords of returned view

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

@ -4040,10 +4040,7 @@ static void ScrollViewToShowRect(nsIScrollableView* aScrollingView,
{
// Determine the visible rect in the scrolling view's coordinate space.
// The size of the visible area is the clip view size
const nsIView* clipView;
aScrollingView->GetClipView(&clipView);
nsRect visibleRect = clipView->GetBounds(); // get width and height
nsRect visibleRect = aScrollingView->View()->GetBounds(); // get width and height
aScrollingView->GetScrollPosition(visibleRect.x, visibleRect.y);
// The actual scroll offsets

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

@ -784,11 +784,7 @@ void nsCaret::GetViewForRendering(nsIFrame *caretFrame, EViewCoordinates coordTy
if (scrollableView)
{
const nsIView* clipView = nsnull;
scrollableView->GetClipView(&clipView);
if (!clipView) return; // should always have one
nsRect bounds = clipView->GetBounds();
nsRect bounds = scrollableView->View()->GetBounds();
scrollableView->GetScrollPosition(bounds.x, bounds.y);
bounds += drawViewOffset; // offset to coords of returned view

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

@ -2776,13 +2776,11 @@ nsListControlFrame::ScrollToFrame(nsIContent* aOptElement)
if (NS_SUCCEEDED(result) && childframe) {
if (NS_SUCCEEDED(result) && scrollableView) {
const nsIView * clippedView;
scrollableView->GetClipView(&clippedView);
nscoord x;
nscoord y;
scrollableView->GetScrollPosition(x,y);
// get the clipped rect
nsRect rect = clippedView->GetBounds();
nsRect rect = scrollableView->View()->GetBounds();
// now move it by the offset of the scroll position
rect.x = x;
rect.y = y;

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

@ -426,9 +426,7 @@ CanvasFrame::Paint(nsPresContext* aPresContext,
if (NS_SUCCEEDED(CallQueryInterface(parentView, &scrollableView))) {
nscoord width, height;
scrollableView->GetContainerSize(&width, &height);
const nsIView* clippedView;
scrollableView->GetClipView(&clippedView);
nsRect vcr = clippedView->GetBounds();
nsRect vcr = scrollableView->View()->GetBounds();
focusRect.width = vcr.width;
focusRect.height = vcr.height;
nscoord x,y;

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

@ -2903,7 +2903,6 @@ nsSelection::CommonPageMove(PRBool aForward,
// and remain relative position of the caret in view. see Bug 4302.
nsresult result;
const nsIView* clipView;
//get the frame from the scrollable view
nsIFrame* mainframe = nsnull;
@ -2922,9 +2921,7 @@ nsSelection::CommonPageMove(PRBool aForward,
return NS_ERROR_FAILURE;
// find out where we are; determine amount to page up/down
if (NS_FAILED(result = aScrollableView->GetClipView(&clipView)))
return result;
nsRect viewRect = clipView->GetBounds();
nsRect viewRect = aScrollableView->View()->GetBounds();
// find out where the caret is.
// we should know mDesiredX value of nsSelection, but I havent seen that behavior in other windows applications yet.
@ -5251,17 +5248,6 @@ nsTypedSelection::ScrollPointIntoClipView(nsPresContext *aPresContext, nsIView *
if (!scrollableView)
return NS_OK; // Nothing to do!
//
// Get the clip view.
//
const nsIView *cView = 0;
result = scrollableView->GetClipView(&cView);
if (NS_FAILED(result))
return result;
//
// Get the view that is being scrolled.
//
@ -5269,8 +5255,6 @@ nsTypedSelection::ScrollPointIntoClipView(nsPresContext *aPresContext, nsIView *
nsIView *scrolledView = 0;
result = scrollableView->GetScrolledView(scrolledView);
if (!cView)
return NS_ERROR_FAILURE;
//
// Now walk up aView's hierarchy, this time keeping track of
@ -5289,7 +5273,7 @@ nsTypedSelection::ScrollPointIntoClipView(nsPresContext *aPresContext, nsIView *
// If it is, scroll the view till it is inside the visible area!
//
nsRect bounds = cView->GetBounds();
nsRect bounds = scrollableView->View()->GetBounds();
result = scrollableView->GetScrollPosition(bounds.x,bounds.y);
@ -5445,9 +5429,7 @@ nsTypedSelection::ScrollPointIntoView(nsPresContext *aPresContext, nsIView *aVie
//
nsIView *scrolledView = 0;
nsIView *view = 0;
CallQueryInterface(scrollableView, &view);
nsIView *view = scrollableView->View();
if (view)
{
@ -5500,12 +5482,7 @@ nsTypedSelection::ScrollPointIntoView(nsPresContext *aPresContext, nsIView *aVie
// can scroll the next parent view.
//
view = 0;
result = CallQueryInterface(scrollableView, &view);
if (!view)
return result;
view = view->GetParent();
view = scrollableView->View()->GetParent();
}
}
}
@ -6976,14 +6953,7 @@ nsTypedSelection::GetSelectionRegionRectAndScrollableView(SelectionRegion aRegio
// padding!
//
const nsIView* clipView = 0;
result = (*aScrollableView)->GetClipView(&clipView);
if (NS_FAILED(result))
return result;
nsRect clipRect = clipView->GetBounds();
nsRect clipRect = (*aScrollableView)->View()->GetBounds();
result = (*aScrollableView)->GetScrollPosition(clipRect.x, clipRect.y);
@ -7072,10 +7042,7 @@ nsTypedSelection::ScrollRectIntoView(nsIScrollableView *aScrollableView,
// Determine the visible rect in the scrolled view's coordinate space.
// The size of the visible area is the clip view size
const nsIView* clipView;
aScrollableView->GetClipView(&clipView);
nsRect visibleRect = clipView->GetBounds();
nsRect visibleRect = aScrollableView->View()->GetBounds();
aScrollableView->GetScrollPosition(visibleRect.x, visibleRect.y);
// The actual scroll offsets
@ -7147,12 +7114,7 @@ nsTypedSelection::ScrollRectIntoView(nsIScrollableView *aScrollableView,
// Check if aScrollableRect has a parent scrollable view!
//
nsIView *view = 0;
rv = CallQueryInterface(aScrollableView, &view);
if (!view)
return rv;
view = view->GetParent();
nsIView *view = aScrollableView->View()->GetParent();
if (view)
{

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

@ -426,9 +426,7 @@ CanvasFrame::Paint(nsPresContext* aPresContext,
if (NS_SUCCEEDED(CallQueryInterface(parentView, &scrollableView))) {
nscoord width, height;
scrollableView->GetContainerSize(&width, &height);
const nsIView* clippedView;
scrollableView->GetClipView(&clippedView);
nsRect vcr = clippedView->GetBounds();
nsRect vcr = scrollableView->View()->GetBounds();
focusRect.width = vcr.width;
focusRect.height = vcr.height;
nscoord x,y;

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

@ -4040,10 +4040,7 @@ static void ScrollViewToShowRect(nsIScrollableView* aScrollingView,
{
// Determine the visible rect in the scrolling view's coordinate space.
// The size of the visible area is the clip view size
const nsIView* clipView;
aScrollingView->GetClipView(&clipView);
nsRect visibleRect = clipView->GetBounds(); // get width and height
nsRect visibleRect = aScrollingView->View()->GetBounds(); // get width and height
aScrollingView->GetScrollPosition(visibleRect.x, visibleRect.y);
// The actual scroll offsets

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

@ -2776,13 +2776,11 @@ nsListControlFrame::ScrollToFrame(nsIContent* aOptElement)
if (NS_SUCCEEDED(result) && childframe) {
if (NS_SUCCEEDED(result) && scrollableView) {
const nsIView * clippedView;
scrollableView->GetClipView(&clippedView);
nscoord x;
nscoord y;
scrollableView->GetScrollPosition(x,y);
// get the clipped rect
nsRect rect = clippedView->GetBounds();
nsRect rect = scrollableView->View()->GetBounds();
// now move it by the offset of the scroll position
rect.x = x;
rect.y = y;

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

@ -1407,23 +1407,19 @@ void nsMenuPopupFrame::EnsureMenuItemIsVisible(nsIMenuFrame* aMenuItem)
nsIScrollableView *scrollableView;
scrollableView=GetScrollableView(childFrame);
if ( scrollableView ) {
nsIView* view=nsnull;
scrollableView->QueryInterface(NS_GET_IID(nsIView), (void**)&view);
if ( view ) {
nscoord scrollX, scrollY;
nscoord scrollX, scrollY;
nsRect viewRect = view->GetBounds();
nsRect itemRect = frame->GetRect();
scrollableView->GetScrollPosition(scrollX, scrollY);
// scroll down
if ( itemRect.y + itemRect.height > scrollY + viewRect.height )
scrollableView->ScrollTo(scrollX, itemRect.y + itemRect.height - viewRect.height, NS_SCROLL_PROPERTY_ALWAYS_BLIT);
// scroll up
else if ( itemRect.y < scrollY )
scrollableView->ScrollTo(scrollX, itemRect.y, NS_SCROLL_PROPERTY_ALWAYS_BLIT);
}
nsRect viewRect = scrollableView->View()->GetBounds();
nsRect itemRect = frame->GetRect();
scrollableView->GetScrollPosition(scrollX, scrollY);
// scroll down
if ( itemRect.y + itemRect.height > scrollY + viewRect.height )
scrollableView->ScrollTo(scrollX, itemRect.y + itemRect.height - viewRect.height, NS_SCROLL_PROPERTY_ALWAYS_BLIT);
// scroll up
else if ( itemRect.y < scrollY )
scrollableView->ScrollTo(scrollX, itemRect.y, NS_SCROLL_PROPERTY_ALWAYS_BLIT);
}
}
}

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

@ -68,8 +68,6 @@ class nsIScrollableView {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISCROLLABLEVIEW_IID)
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) = 0;
/**
* Create the controls used to allow scrolling. Call this method
* before anything else is done with the scrollable view.
@ -192,10 +190,9 @@ public:
NS_IMETHOD ScrollByWhole(PRBool aTop) = 0;
/**
* Returns the clip view
* XXX Obsolete; with nsScrollingView gone, this always returns 'this'
* Returns the view as an nsIView*
*/
NS_IMETHOD GetClipView(const nsIView** aClipView) const = 0;
NS_IMETHOD_(nsIView*) View() = 0;
/**
* Adds a scroll position listener.

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

@ -123,10 +123,9 @@ nsresult nsScrollPortView::QueryInterface(const nsIID& aIID, void** aInstancePtr
return nsView::QueryInterface(aIID, aInstancePtr);
}
NS_IMETHODIMP nsScrollPortView::GetClipView(const nsIView** aClipView) const
NS_IMETHODIMP_(nsIView*) nsScrollPortView::View()
{
*aClipView = this;
return NS_OK;
return this;
}
NS_IMETHODIMP nsScrollPortView::AddScrollPositionListener(nsIScrollPositionListener* aListener)

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

@ -78,7 +78,7 @@ public:
NS_IMETHOD ScrollByPages(PRInt32 aNumPagesX, PRInt32 aNumPagesY);
NS_IMETHOD ScrollByWhole(PRBool aTop);
NS_IMETHOD GetClipView(const nsIView** aClipView) const;
NS_IMETHOD_(nsIView*) View();
NS_IMETHOD AddScrollPositionListener(nsIScrollPositionListener* aListener);
NS_IMETHOD RemoveScrollPositionListener(nsIScrollPositionListener* aListener);

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

@ -2834,9 +2834,7 @@ PRBool nsViewManager::CanScrollWithBitBlt(nsView* aView)
// the root scrollable) are on top.
nsRegion opaqueRegion;
if (mRootScrollable != nsnull) {
const nsIView* scrollableClipView;
mRootScrollable->GetClipView(&scrollableClipView);
if (IsAncestorOf(NS_STATIC_CAST(const nsView*, scrollableClipView), aView)) {
if (IsAncestorOf(NS_STATIC_CAST(const nsScrollPortView*, mRootScrollable), aView)) {
// add areas of fixed views to the opaque area.
// This is a bit of a hack. We should not be doing special case processing for fixed views.
nsView* fixedView = mRootView->GetFirstChild();
@ -3898,10 +3896,7 @@ nsresult nsViewManager::GetVisibleRect(nsRect& aVisibleRect)
if (scrollingView) {
// Determine the visible rect in the scrolled view's coordinate space.
// The size of the visible area is the clip view size
const nsIView* clipViewI;
scrollingView->GetClipView(&clipViewI);
const nsView* clipView = NS_STATIC_CAST(const nsView*, clipViewI);
nsScrollPortView* clipView = NS_STATIC_CAST(nsScrollPortView*, scrollingView);
clipView->GetDimensions(aVisibleRect);
scrollingView->GetScrollPosition(aVisibleRect.x, aVisibleRect.y);