diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp
index 9a34124ab5d..fca9a59b59d 100644
--- a/mozilla/content/html/document/src/nsHTMLDocument.cpp
+++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp
@@ -2500,8 +2500,7 @@ nsHTMLDocument::GetPixelDimensions(nsIPresShell* aShell,
// 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);
+ nsIScrollableView* scrollableView = view->ToScrollableView();
if (scrollableView) {
scrollableView->GetScrolledView(view);
diff --git a/mozilla/content/xul/document/src/nsXULDocument.cpp b/mozilla/content/xul/document/src/nsXULDocument.cpp
index 6d12bc67308..8ba0df23b12 100644
--- a/mozilla/content/xul/document/src/nsXULDocument.cpp
+++ b/mozilla/content/xul/document/src/nsXULDocument.cpp
@@ -1592,9 +1592,9 @@ nsXULDocument::GetPixelDimensions(nsIPresShell* aShell, PRInt32* aWidth,
// If we have a view check if it's scrollable. If not,
// just use the view size itself
if (view) {
- nsIScrollableView* scrollableView;
+ nsIScrollableView* scrollableView = view->ToScrollableView();
- if (NS_SUCCEEDED(CallQueryInterface(view, &scrollableView))) {
+ if (scrollableView) {
scrollableView->GetScrolledView(view);
}
diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp
index 7530efdcfc1..e754626789b 100644
--- a/mozilla/layout/base/nsCSSFrameConstructor.cpp
+++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp
@@ -4293,8 +4293,8 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell,
nsIView* view = newScrollableFrame->GetView();
NS_ENSURE_TRUE(view, NS_ERROR_FAILURE);
- nsIScrollableView* scrollableView = nsnull;
- NS_ENSURE_SUCCESS(CallQueryInterface(view, &scrollableView), NS_ERROR_FAILURE);
+ nsIScrollableView* scrollableView = view->ToScrollableView();
+ NS_ENSURE_TRUE(scrollableView, NS_ERROR_FAILURE);
viewManager->SetRootScrollableView(scrollableView);
parentFrame = newScrollableFrame;
@@ -4333,8 +4333,8 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell,
nsIView* view = scrollFrame->GetView();
NS_ENSURE_TRUE(view, NS_ERROR_FAILURE);
- nsIScrollableView* scrollableView = nsnull;
- NS_ENSURE_SUCCESS(CallQueryInterface(view, &scrollableView), NS_ERROR_FAILURE);
+ nsIScrollableView* scrollableView = view->ToScrollableView();
+ NS_ENSURE_TRUE(scrollableView, NS_ERROR_FAILURE);
viewManager->SetRootScrollableView(scrollableView);
diff --git a/mozilla/layout/base/nsCaret.cpp b/mozilla/layout/base/nsCaret.cpp
index 33a05a4dabb..6e75ecff703 100644
--- a/mozilla/layout/base/nsCaret.cpp
+++ b/mozilla/layout/base/nsCaret.cpp
@@ -767,7 +767,7 @@ void nsCaret::GetViewForRendering(nsIFrame *caretFrame, EViewCoordinates coordTy
do {
//is this a scrollable view?
if (!scrollableView)
- theView->QueryInterface(NS_GET_IID(nsIScrollableView), (void **)&scrollableView);
+ scrollableView = theView->ToScrollableView();
if (theView->HasWidget())
{
diff --git a/mozilla/layout/base/nsLayoutUtils.cpp b/mozilla/layout/base/nsLayoutUtils.cpp
index 02fd6e3a4dc..51ee20b741d 100644
--- a/mozilla/layout/base/nsLayoutUtils.cpp
+++ b/mozilla/layout/base/nsLayoutUtils.cpp
@@ -401,7 +401,7 @@ nsLayoutUtils::GetNearestScrollingView(nsIView* aView, Direction aDirection)
NS_ASSERTION(aView, "GetNearestScrollingView expects a non-null view");
nsIScrollableView* scrollableView = nsnull;
for (; aView; aView = aView->GetParent()) {
- CallQueryInterface(aView, &scrollableView);
+ scrollableView = aView->ToScrollableView();
if (scrollableView) {
nsPresContext::ScrollbarStyles ss =
nsLayoutUtils::ScrollbarStylesOfView(scrollableView);
diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp
index 5c6789317d9..b671360bb14 100644
--- a/mozilla/layout/base/nsPresShell.cpp
+++ b/mozilla/layout/base/nsPresShell.cpp
@@ -4247,15 +4247,9 @@ PresShell::ScrollFrameIntoView(nsIFrame *aFrame,
}
}
-#ifdef DEBUG
- if (closestView) {
- nsIScrollableView* _testView = nsnull;
- CallQueryInterface(closestView, &_testView);
- NS_ASSERTION(!_testView,
- "What happened to the scrolled view? "
- "The frame should not be directly in the scrolling view!");
- }
-#endif
+ NS_ASSERTION(closestView && !closestView->ToScrollableView(),
+ "What happened to the scrolled view? "
+ "The frame should not be directly in the scrolling view!");
// Walk up the view hierarchy. Make sure to add the view's position
// _after_ we get the parent and see whether it's scrollable. We want to
@@ -4264,7 +4258,7 @@ PresShell::ScrollFrameIntoView(nsIFrame *aFrame,
while (closestView) {
nsIView* parent = closestView->GetParent();
if (parent) {
- CallQueryInterface(parent, &scrollingView);
+ scrollingView = parent->ToScrollableView();
if (scrollingView) {
ScrollViewToShowRect(scrollingView, frameBounds, aVPercent, aHPercent);
}
@@ -6608,7 +6602,6 @@ PresShell::Observe(nsISupports* aSubject,
#ifdef NS_DEBUG
#include "nsViewsCID.h"
#include "nsWidgetsCID.h"
-#include "nsIScrollableView.h"
#include "nsIDeviceContext.h"
#include "nsIURL.h"
#include "nsILinkHandler.h"
diff --git a/mozilla/layout/base/src/nsCaret.cpp b/mozilla/layout/base/src/nsCaret.cpp
index 33a05a4dabb..6e75ecff703 100644
--- a/mozilla/layout/base/src/nsCaret.cpp
+++ b/mozilla/layout/base/src/nsCaret.cpp
@@ -767,7 +767,7 @@ void nsCaret::GetViewForRendering(nsIFrame *caretFrame, EViewCoordinates coordTy
do {
//is this a scrollable view?
if (!scrollableView)
- theView->QueryInterface(NS_GET_IID(nsIScrollableView), (void **)&scrollableView);
+ scrollableView = theView->ToScrollableView();
if (theView->HasWidget())
{
diff --git a/mozilla/layout/base/src/nsLayoutUtils.cpp b/mozilla/layout/base/src/nsLayoutUtils.cpp
index 02fd6e3a4dc..51ee20b741d 100644
--- a/mozilla/layout/base/src/nsLayoutUtils.cpp
+++ b/mozilla/layout/base/src/nsLayoutUtils.cpp
@@ -401,7 +401,7 @@ nsLayoutUtils::GetNearestScrollingView(nsIView* aView, Direction aDirection)
NS_ASSERTION(aView, "GetNearestScrollingView expects a non-null view");
nsIScrollableView* scrollableView = nsnull;
for (; aView; aView = aView->GetParent()) {
- CallQueryInterface(aView, &scrollableView);
+ scrollableView = aView->ToScrollableView();
if (scrollableView) {
nsPresContext::ScrollbarStyles ss =
nsLayoutUtils::ScrollbarStylesOfView(scrollableView);
diff --git a/mozilla/layout/forms/nsComboboxControlFrame.cpp b/mozilla/layout/forms/nsComboboxControlFrame.cpp
index 3d04dc45765..f7dd3a9591b 100644
--- a/mozilla/layout/forms/nsComboboxControlFrame.cpp
+++ b/mozilla/layout/forms/nsComboboxControlFrame.cpp
@@ -73,7 +73,6 @@
#include "nsIDocument.h"
#include "nsINodeInfo.h"
#include "nsIScrollableFrame.h"
-#include "nsIScrollableView.h"
#include "nsListControlFrame.h"
#include "nsContentCID.h"
#ifdef ACCESSIBILITY
@@ -529,8 +528,8 @@ nsComboboxControlFrame::ShowPopup(PRBool aShowPopup)
nsRect rect = mDropdownFrame->GetRect();
rect.x = rect.y = 0;
viewManager->ResizeView(view, rect);
- nsIScrollableView* scrollingView;
- if (NS_SUCCEEDED(view->QueryInterface(NS_GET_IID(nsIScrollableView), (void**)&scrollingView))) {
+ nsIScrollableView* scrollingView = view->ToScrollableView();
+ if (scrollingView) {
scrollingView->ComputeScrollOffsets(PR_TRUE);
}
viewManager->SetViewVisibility(view, nsViewVisibility_kShow);
diff --git a/mozilla/layout/forms/nsTextControlFrame.cpp b/mozilla/layout/forms/nsTextControlFrame.cpp
index b0ac2ce130e..8c67585e1c7 100644
--- a/mozilla/layout/forms/nsTextControlFrame.cpp
+++ b/mozilla/layout/forms/nsTextControlFrame.cpp
@@ -3190,8 +3190,8 @@ nsTextControlFrame::SetInitialChildList(nsPresContext* aPresContext,
nsIView *view = first->GetView();
if (view)
{
- nsIScrollableView *scrollView;
- if (NS_SUCCEEDED(CallQueryInterface(view, &scrollView)))
+ nsIScrollableView *scrollView = view->ToScrollableView();
+ if (scrollView)
{
mScrollableView = scrollView; // Note: views are not addref'd
mTextSelImpl->SetScrollableView(scrollView);
diff --git a/mozilla/layout/generic/nsContainerFrame.cpp b/mozilla/layout/generic/nsContainerFrame.cpp
index bc73ae5d724..fe49cfc7471 100644
--- a/mozilla/layout/generic/nsContainerFrame.cpp
+++ b/mozilla/layout/generic/nsContainerFrame.cpp
@@ -494,8 +494,7 @@ nsContainerFrame::PositionFrameView(nsPresContext* aPresContext,
if (parentView) {
// If the parent view is scrollable, then adjust the origin by
// the parent's scroll position.
- nsIScrollableView* scrollable = nsnull;
- CallQueryInterface(parentView, &scrollable);
+ nsIScrollableView* scrollable = parentView->ToScrollableView();
if (scrollable) {
nscoord scrollX = 0, scrollY = 0;
scrollable->GetScrollPosition(scrollX, scrollY);
diff --git a/mozilla/layout/generic/nsGfxScrollFrame.cpp b/mozilla/layout/generic/nsGfxScrollFrame.cpp
index e12df9ffb1a..b4eb3bb3ed0 100644
--- a/mozilla/layout/generic/nsGfxScrollFrame.cpp
+++ b/mozilla/layout/generic/nsGfxScrollFrame.cpp
@@ -1518,12 +1518,8 @@ nsGfxScrollFrameInner::GetScrollableView() const
nsIView* view = mScrollAreaBox->GetView();
if (!view) return nsnull;
- nsIScrollableView* scrollingView;
-#ifdef DEBUG
- nsresult result =
-#endif
- CallQueryInterface(view, &scrollingView);
- NS_ASSERTION(NS_SUCCEEDED(result),
+ nsIScrollableView* scrollingView = view->ToScrollableView();
+ NS_ASSERTION(scrollingView,
"assertion gfx scrollframe does not contain a scrollframe");
return scrollingView;
}
diff --git a/mozilla/layout/generic/nsHTMLContainerFrame.cpp b/mozilla/layout/generic/nsHTMLContainerFrame.cpp
index b1534e3ae40..6636948ca18 100644
--- a/mozilla/layout/generic/nsHTMLContainerFrame.cpp
+++ b/mozilla/layout/generic/nsHTMLContainerFrame.cpp
@@ -559,8 +559,8 @@ nsHTMLContainerFrame::CreateViewForFrame(nsIFrame* aFrame,
// Insert the view into the view hierarchy. If the parent view is a
// scrolling view we need to do this differently
- nsIScrollableView* scrollingView;
- if (NS_SUCCEEDED(CallQueryInterface(parentView, &scrollingView))) {
+ nsIScrollableView* scrollingView = parentView->ToScrollableView();
+ if (scrollingView) {
scrollingView->SetScrolledView(view);
} else {
nsIView* insertBefore = nsLayoutUtils::FindSiblingViewFor(parentView, aFrame);
diff --git a/mozilla/layout/generic/nsHTMLFrame.cpp b/mozilla/layout/generic/nsHTMLFrame.cpp
index baf4d58026f..e17a3c135a8 100644
--- a/mozilla/layout/generic/nsHTMLFrame.cpp
+++ b/mozilla/layout/generic/nsHTMLFrame.cpp
@@ -55,7 +55,6 @@
#include "nsHTMLAtoms.h"
#include "nsIEventStateManager.h"
#include "nsIDeviceContext.h"
-#include "nsIScrollableView.h"
#include "nsLayoutAtoms.h"
#include "nsIPresShell.h"
#include "nsIScrollPositionListener.h"
@@ -422,11 +421,11 @@ CanvasFrame::Paint(nsPresContext* aPresContext,
nsIFrame * parentFrame = GetParent();
nsIView* parentView = parentFrame->GetView();
- nsIScrollableView* scrollableView;
- if (NS_SUCCEEDED(CallQueryInterface(parentView, &scrollableView))) {
+ nsIScrollableView* scrollableView = parentView->ToScrollableView();
+ if (scrollableView) {
nscoord width, height;
scrollableView->GetContainerSize(&width, &height);
- nsRect vcr = scrollableView->View()->GetBounds();
+ nsRect vcr = parentView->GetBounds();
focusRect.width = vcr.width;
focusRect.height = vcr.height;
nscoord x,y;
diff --git a/mozilla/layout/generic/nsObjectFrame.cpp b/mozilla/layout/generic/nsObjectFrame.cpp
index 8c19fff00e5..e72aa10ad79 100644
--- a/mozilla/layout/generic/nsObjectFrame.cpp
+++ b/mozilla/layout/generic/nsObjectFrame.cpp
@@ -3586,8 +3586,8 @@ nsPluginInstanceOwner::Destroy()
nsIView* curView = parentWithView ? parentWithView->GetView() : nsnull;
while (curView)
{
- nsIScrollableView* scrollingView;
- if (NS_SUCCEEDED(CallQueryInterface(curView, &scrollingView)))
+ nsIScrollableView* scrollingView = curView->ToScrollableView();
+ if (scrollingView)
scrollingView->RemoveScrollPositionListener((nsIScrollPositionListener *)this);
curView = curView->GetParent();
@@ -3816,8 +3816,8 @@ NS_IMETHODIMP nsPluginInstanceOwner::Init(nsPresContext* aPresContext, nsObjectF
nsIView* curView = parentWithView ? parentWithView->GetView() : nsnull;
while (curView)
{
- nsIScrollableView* scrollingView;
- if (NS_SUCCEEDED(CallQueryInterface(curView, &scrollingView)))
+ nsIScrollableView* scrollingView = curView->ToScrollableView();
+ if (scrollingView)
scrollingView->AddScrollPositionListener((nsIScrollPositionListener *)this);
curView = curView->GetParent();
diff --git a/mozilla/layout/html/base/src/nsContainerFrame.cpp b/mozilla/layout/html/base/src/nsContainerFrame.cpp
index bc73ae5d724..fe49cfc7471 100644
--- a/mozilla/layout/html/base/src/nsContainerFrame.cpp
+++ b/mozilla/layout/html/base/src/nsContainerFrame.cpp
@@ -494,8 +494,7 @@ nsContainerFrame::PositionFrameView(nsPresContext* aPresContext,
if (parentView) {
// If the parent view is scrollable, then adjust the origin by
// the parent's scroll position.
- nsIScrollableView* scrollable = nsnull;
- CallQueryInterface(parentView, &scrollable);
+ nsIScrollableView* scrollable = parentView->ToScrollableView();
if (scrollable) {
nscoord scrollX = 0, scrollY = 0;
scrollable->GetScrollPosition(scrollX, scrollY);
diff --git a/mozilla/layout/html/base/src/nsGfxScrollFrame.cpp b/mozilla/layout/html/base/src/nsGfxScrollFrame.cpp
index e12df9ffb1a..b4eb3bb3ed0 100644
--- a/mozilla/layout/html/base/src/nsGfxScrollFrame.cpp
+++ b/mozilla/layout/html/base/src/nsGfxScrollFrame.cpp
@@ -1518,12 +1518,8 @@ nsGfxScrollFrameInner::GetScrollableView() const
nsIView* view = mScrollAreaBox->GetView();
if (!view) return nsnull;
- nsIScrollableView* scrollingView;
-#ifdef DEBUG
- nsresult result =
-#endif
- CallQueryInterface(view, &scrollingView);
- NS_ASSERTION(NS_SUCCEEDED(result),
+ nsIScrollableView* scrollingView = view->ToScrollableView();
+ NS_ASSERTION(scrollingView,
"assertion gfx scrollframe does not contain a scrollframe");
return scrollingView;
}
diff --git a/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp b/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp
index b1534e3ae40..6636948ca18 100644
--- a/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp
+++ b/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp
@@ -559,8 +559,8 @@ nsHTMLContainerFrame::CreateViewForFrame(nsIFrame* aFrame,
// Insert the view into the view hierarchy. If the parent view is a
// scrolling view we need to do this differently
- nsIScrollableView* scrollingView;
- if (NS_SUCCEEDED(CallQueryInterface(parentView, &scrollingView))) {
+ nsIScrollableView* scrollingView = parentView->ToScrollableView();
+ if (scrollingView) {
scrollingView->SetScrolledView(view);
} else {
nsIView* insertBefore = nsLayoutUtils::FindSiblingViewFor(parentView, aFrame);
diff --git a/mozilla/layout/html/base/src/nsHTMLFrame.cpp b/mozilla/layout/html/base/src/nsHTMLFrame.cpp
index baf4d58026f..e17a3c135a8 100644
--- a/mozilla/layout/html/base/src/nsHTMLFrame.cpp
+++ b/mozilla/layout/html/base/src/nsHTMLFrame.cpp
@@ -55,7 +55,6 @@
#include "nsHTMLAtoms.h"
#include "nsIEventStateManager.h"
#include "nsIDeviceContext.h"
-#include "nsIScrollableView.h"
#include "nsLayoutAtoms.h"
#include "nsIPresShell.h"
#include "nsIScrollPositionListener.h"
@@ -422,11 +421,11 @@ CanvasFrame::Paint(nsPresContext* aPresContext,
nsIFrame * parentFrame = GetParent();
nsIView* parentView = parentFrame->GetView();
- nsIScrollableView* scrollableView;
- if (NS_SUCCEEDED(CallQueryInterface(parentView, &scrollableView))) {
+ nsIScrollableView* scrollableView = parentView->ToScrollableView();
+ if (scrollableView) {
nscoord width, height;
scrollableView->GetContainerSize(&width, &height);
- nsRect vcr = scrollableView->View()->GetBounds();
+ nsRect vcr = parentView->GetBounds();
focusRect.width = vcr.width;
focusRect.height = vcr.height;
nscoord x,y;
diff --git a/mozilla/layout/html/base/src/nsObjectFrame.cpp b/mozilla/layout/html/base/src/nsObjectFrame.cpp
index 8c19fff00e5..e72aa10ad79 100644
--- a/mozilla/layout/html/base/src/nsObjectFrame.cpp
+++ b/mozilla/layout/html/base/src/nsObjectFrame.cpp
@@ -3586,8 +3586,8 @@ nsPluginInstanceOwner::Destroy()
nsIView* curView = parentWithView ? parentWithView->GetView() : nsnull;
while (curView)
{
- nsIScrollableView* scrollingView;
- if (NS_SUCCEEDED(CallQueryInterface(curView, &scrollingView)))
+ nsIScrollableView* scrollingView = curView->ToScrollableView();
+ if (scrollingView)
scrollingView->RemoveScrollPositionListener((nsIScrollPositionListener *)this);
curView = curView->GetParent();
@@ -3816,8 +3816,8 @@ NS_IMETHODIMP nsPluginInstanceOwner::Init(nsPresContext* aPresContext, nsObjectF
nsIView* curView = parentWithView ? parentWithView->GetView() : nsnull;
while (curView)
{
- nsIScrollableView* scrollingView;
- if (NS_SUCCEEDED(CallQueryInterface(curView, &scrollingView)))
+ nsIScrollableView* scrollingView = curView->ToScrollableView();
+ if (scrollingView)
scrollingView->AddScrollPositionListener((nsIScrollPositionListener *)this);
curView = curView->GetParent();
diff --git a/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp
index 5c6789317d9..b671360bb14 100644
--- a/mozilla/layout/html/base/src/nsPresShell.cpp
+++ b/mozilla/layout/html/base/src/nsPresShell.cpp
@@ -4247,15 +4247,9 @@ PresShell::ScrollFrameIntoView(nsIFrame *aFrame,
}
}
-#ifdef DEBUG
- if (closestView) {
- nsIScrollableView* _testView = nsnull;
- CallQueryInterface(closestView, &_testView);
- NS_ASSERTION(!_testView,
- "What happened to the scrolled view? "
- "The frame should not be directly in the scrolling view!");
- }
-#endif
+ NS_ASSERTION(closestView && !closestView->ToScrollableView(),
+ "What happened to the scrolled view? "
+ "The frame should not be directly in the scrolling view!");
// Walk up the view hierarchy. Make sure to add the view's position
// _after_ we get the parent and see whether it's scrollable. We want to
@@ -4264,7 +4258,7 @@ PresShell::ScrollFrameIntoView(nsIFrame *aFrame,
while (closestView) {
nsIView* parent = closestView->GetParent();
if (parent) {
- CallQueryInterface(parent, &scrollingView);
+ scrollingView = parent->ToScrollableView();
if (scrollingView) {
ScrollViewToShowRect(scrollingView, frameBounds, aVPercent, aHPercent);
}
@@ -6608,7 +6602,6 @@ PresShell::Observe(nsISupports* aSubject,
#ifdef NS_DEBUG
#include "nsViewsCID.h"
#include "nsWidgetsCID.h"
-#include "nsIScrollableView.h"
#include "nsIDeviceContext.h"
#include "nsIURL.h"
#include "nsILinkHandler.h"
diff --git a/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp b/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp
index 3d04dc45765..f7dd3a9591b 100644
--- a/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp
+++ b/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp
@@ -73,7 +73,6 @@
#include "nsIDocument.h"
#include "nsINodeInfo.h"
#include "nsIScrollableFrame.h"
-#include "nsIScrollableView.h"
#include "nsListControlFrame.h"
#include "nsContentCID.h"
#ifdef ACCESSIBILITY
@@ -529,8 +528,8 @@ nsComboboxControlFrame::ShowPopup(PRBool aShowPopup)
nsRect rect = mDropdownFrame->GetRect();
rect.x = rect.y = 0;
viewManager->ResizeView(view, rect);
- nsIScrollableView* scrollingView;
- if (NS_SUCCEEDED(view->QueryInterface(NS_GET_IID(nsIScrollableView), (void**)&scrollingView))) {
+ nsIScrollableView* scrollingView = view->ToScrollableView();
+ if (scrollingView) {
scrollingView->ComputeScrollOffsets(PR_TRUE);
}
viewManager->SetViewVisibility(view, nsViewVisibility_kShow);
diff --git a/mozilla/layout/html/forms/src/nsTextControlFrame.cpp b/mozilla/layout/html/forms/src/nsTextControlFrame.cpp
index b0ac2ce130e..8c67585e1c7 100644
--- a/mozilla/layout/html/forms/src/nsTextControlFrame.cpp
+++ b/mozilla/layout/html/forms/src/nsTextControlFrame.cpp
@@ -3190,8 +3190,8 @@ nsTextControlFrame::SetInitialChildList(nsPresContext* aPresContext,
nsIView *view = first->GetView();
if (view)
{
- nsIScrollableView *scrollView;
- if (NS_SUCCEEDED(CallQueryInterface(view, &scrollView)))
+ nsIScrollableView *scrollView = view->ToScrollableView();
+ if (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 7530efdcfc1..e754626789b 100644
--- a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp
+++ b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp
@@ -4293,8 +4293,8 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell,
nsIView* view = newScrollableFrame->GetView();
NS_ENSURE_TRUE(view, NS_ERROR_FAILURE);
- nsIScrollableView* scrollableView = nsnull;
- NS_ENSURE_SUCCESS(CallQueryInterface(view, &scrollableView), NS_ERROR_FAILURE);
+ nsIScrollableView* scrollableView = view->ToScrollableView();
+ NS_ENSURE_TRUE(scrollableView, NS_ERROR_FAILURE);
viewManager->SetRootScrollableView(scrollableView);
parentFrame = newScrollableFrame;
@@ -4333,8 +4333,8 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell,
nsIView* view = scrollFrame->GetView();
NS_ENSURE_TRUE(view, NS_ERROR_FAILURE);
- nsIScrollableView* scrollableView = nsnull;
- NS_ENSURE_SUCCESS(CallQueryInterface(view, &scrollableView), NS_ERROR_FAILURE);
+ nsIScrollableView* scrollableView = view->ToScrollableView();
+ NS_ENSURE_TRUE(scrollableView, NS_ERROR_FAILURE);
viewManager->SetRootScrollableView(scrollableView);
diff --git a/mozilla/layout/xul/base/src/nsBoxFrame.cpp b/mozilla/layout/xul/base/src/nsBoxFrame.cpp
index c74f2cf7b3c..6f42a29e2c5 100644
--- a/mozilla/layout/xul/base/src/nsBoxFrame.cpp
+++ b/mozilla/layout/xul/base/src/nsBoxFrame.cpp
@@ -2453,8 +2453,8 @@ nsBoxFrame::CreateViewForFrame(nsPresContext* aPresContext,
// Insert the view into the view hierarchy. If the parent view is a
// scrolling view we need to do this differently
- nsIScrollableView* scrollingView;
- if (NS_SUCCEEDED(CallQueryInterface(parentView, &scrollingView))) {
+ nsIScrollableView* scrollingView = parentView->ToScrollableView();
+ if (scrollingView) {
scrollingView->SetScrolledView(view);
} else {
viewManager->SetViewZIndex(view, autoZIndex, zIndex);
diff --git a/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp b/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp
index 3c1a93d2113..3c28005cbb6 100644
--- a/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp
+++ b/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp
@@ -375,10 +375,7 @@ PRBool ParentIsScrollableView(nsIView* aStartView);
PRBool ParentIsScrollableView(nsIView* aStartView)
{
nsIView* scrollportView = aStartView->GetParent();
- nsIScrollableView* scrollableView = nsnull;
- if (scrollportView)
- scrollportView->QueryInterface(NS_GET_IID(nsIScrollableView), (void**) &scrollableView);
- return scrollableView != nsnull;
+ return scrollportView != nsnull && scrollportView->ToScrollableView() != nsnull;
}
///////////////////////////////////////////////////////////////////////////////
@@ -1373,7 +1370,7 @@ nsIScrollableView* nsMenuPopupFrame::GetScrollableView(nsIFrame* aStart)
do {
nsIView* view = currFrame->GetView();
if ( view )
- CallQueryInterface(view, &scrollableView);
+ scrollableView = view->ToScrollableView();
if ( scrollableView )
return scrollableView;
currFrame = currFrame->GetNextSibling();
diff --git a/mozilla/layout/xul/base/src/nsScrollBoxFrame.cpp b/mozilla/layout/xul/base/src/nsScrollBoxFrame.cpp
index f179717cdb9..710a7ba100c 100644
--- a/mozilla/layout/xul/base/src/nsScrollBoxFrame.cpp
+++ b/mozilla/layout/xul/base/src/nsScrollBoxFrame.cpp
@@ -206,12 +206,8 @@ nsScrollBoxFrame::GetScrollingParentView(nsPresContext* aPresContext,
nsIView*
nsScrollBoxFrame::GetMouseCapturer() const
{
- nsIScrollableView* scrollingView;
-#ifdef DEBUG
- nsresult result =
-#endif
- CallQueryInterface(GetView(), &scrollingView);
- NS_ASSERTION(NS_SUCCEEDED(result),
+ nsIScrollableView* scrollingView = GetView()->ToScrollableView();
+ NS_ASSERTION(scrollingView,
"Scrollbox does not contain a scrolling view?");
nsIView* view;
scrollingView->GetScrolledView(view);
@@ -368,8 +364,8 @@ nsScrollBoxFrame::DoLayout(nsBoxLayoutState& aState)
}
nsIView* view = GetView();
- nsIScrollableView* scrollingView;
- if (NS_SUCCEEDED(CallQueryInterface(view, &scrollingView))) {
+ nsIScrollableView* scrollingView = view->ToScrollableView();
+ if (scrollingView) {
scrollingView->ComputeScrollOffsets(PR_TRUE);
}
diff --git a/mozilla/layout/xul/base/src/nsSplitterFrame.cpp b/mozilla/layout/xul/base/src/nsSplitterFrame.cpp
index c0bad67ef7b..1b761ba1756 100644
--- a/mozilla/layout/xul/base/src/nsSplitterFrame.cpp
+++ b/mozilla/layout/xul/base/src/nsSplitterFrame.cpp
@@ -543,9 +543,8 @@ nsSplitterFrameInner::MouseDrag(nsPresContext* aPresContext, nsGUIEvent* aEvent)
// how much we are scrolled.
nsIView* view = parent->GetView();
if (view) {
- nsIScrollableView* scrollingView;
- nsresult result = CallQueryInterface(view, &scrollingView);
- if (NS_SUCCEEDED(result)) {
+ nsIScrollableView* scrollingView = view->ToScrollableView();
+ if (scrollingView) {
nscoord xoff = 0;
nscoord yoff = 0;
scrollingView->GetScrollPosition(xoff, yoff);
diff --git a/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp b/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp
index d95469d2be1..efecd964483 100644
--- a/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp
+++ b/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp
@@ -840,8 +840,7 @@ nsTreeBodyFrame::AdjustEventCoordsToBoxCoordSpace (PRInt32 aX, PRInt32 aY, PRInt
nsIView* parentView = nsLeafBoxFrame::GetView()->GetParent()->GetParent();
if (parentView) {
- nsIScrollableView* scrollView = nsnull;
- CallQueryInterface(parentView, &scrollView);
+ nsIScrollableView* scrollView = parentView->ToScrollableView();
if (scrollView) {
nscoord scrollX = 0, scrollY = 0;
scrollView->GetScrollPosition(scrollX, scrollY);
diff --git a/mozilla/view/public/nsIView.h b/mozilla/view/public/nsIView.h
index 9b2b4cd726b..5bcaa541a8e 100644
--- a/mozilla/view/public/nsIView.h
+++ b/mozilla/view/public/nsIView.h
@@ -45,6 +45,7 @@
#include "nsIWidget.h"
class nsIViewManager;
+class nsIScrollableView;
class nsViewManager;
class nsView;
struct nsRect;
@@ -113,18 +114,17 @@ struct nsViewZIndex {
* of a view, go through nsIViewManager.
*/
-// hack to make egcs / gcc 2.95.2 happy
-class nsIView_base
+class nsIView
{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IVIEW_IID)
- NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) = 0;
-};
+ /**
+ * See if this view is scrollable.
+ * @result an nsIScrollableView* if the view is scrollable, or nsnull if not.
+ */
+ virtual nsIScrollableView* ToScrollableView() { return nsnull; }
-class nsIView : public nsIView_base
-{
-public:
/**
* Get the view manager which "owns" the view.
* This method might require some expensive traversal work in the future. If you can get the
diff --git a/mozilla/view/src/nsScrollPortView.h b/mozilla/view/src/nsScrollPortView.h
index bb68dbe9fdd..84139b96f2a 100644
--- a/mozilla/view/src/nsScrollPortView.h
+++ b/mozilla/view/src/nsScrollPortView.h
@@ -54,6 +54,8 @@ class nsScrollPortView : public nsView, public nsIScrollableView
public:
nsScrollPortView(nsViewManager* aViewManager = nsnull);
+ virtual nsIScrollableView* ToScrollableView() { return this; }
+
NS_IMETHOD QueryInterface(REFNSIID aIID,
void** aInstancePtr);
diff --git a/mozilla/view/src/nsView.cpp b/mozilla/view/src/nsView.cpp
index 6f85ff2c5ea..71963ffe4cd 100644
--- a/mozilla/view/src/nsView.cpp
+++ b/mozilla/view/src/nsView.cpp
@@ -120,7 +120,15 @@ NS_IMETHODIMP ViewWrapper::QueryInterface(REFNSIID aIID, void** aInstancePtr)
NS_IMETHODIMP ViewWrapper::GetInterface(REFNSIID aIID, void** aInstancePtr)
{
- return mView->QueryInterface(aIID, aInstancePtr);
+ if (aIID.Equals(NS_GET_IID(nsIScrollableView))) {
+ *aInstancePtr = mView->ToScrollableView();
+ return NS_OK;
+ }
+ if (aIID.Equals(NS_GET_IID(nsIView))) {
+ *aInstancePtr = mView;
+ return NS_OK;
+ }
+ return QueryInterface(aIID, aInstancePtr);
}
/**