From f3fe4fa48c197fd5100d539d0f437ed127029c9f Mon Sep 17 00:00:00 2001 From: "roc+%cs.cmu.edu" Date: Wed, 28 Jul 2004 03:27:02 +0000 Subject: [PATCH] Bug 240276. Make be implemented as a regular scrollframe rathern than a scrollboxframe. This will help us remove scrollboxframe. r+sr=dbaron --- layout/base/nsCSSFrameConstructor.cpp | 5 -- .../html/style/src/nsCSSFrameConstructor.cpp | 5 -- layout/xul/base/src/nsScrollBoxObject.cpp | 77 +++++++++++-------- toolkit/content/xul.css | 1 + xpfe/global/resources/content/xul.css | 2 + 5 files changed, 49 insertions(+), 41 deletions(-) diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index d921843964ef..691eb68a2d6d 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -5345,11 +5345,6 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell, rv = NS_NewPopupSetFrame(aPresShell, &newFrame); ((nsPopupSetFrame*) newFrame)->SetFrameConstructor(this); } - else if (aTag == nsXULAtoms::scrollbox) { - rv = NS_NewScrollBoxFrame(aPresShell, &newFrame); - processChildren = PR_TRUE; - isReplaced = PR_TRUE; - } else if (aTag == nsXULAtoms::iframe || aTag == nsXULAtoms::editor || aTag == nsXULAtoms::browser) { isReplaced = PR_TRUE; diff --git a/layout/html/style/src/nsCSSFrameConstructor.cpp b/layout/html/style/src/nsCSSFrameConstructor.cpp index d921843964ef..691eb68a2d6d 100644 --- a/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -5345,11 +5345,6 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell, rv = NS_NewPopupSetFrame(aPresShell, &newFrame); ((nsPopupSetFrame*) newFrame)->SetFrameConstructor(this); } - else if (aTag == nsXULAtoms::scrollbox) { - rv = NS_NewScrollBoxFrame(aPresShell, &newFrame); - processChildren = PR_TRUE; - isReplaced = PR_TRUE; - } else if (aTag == nsXULAtoms::iframe || aTag == nsXULAtoms::editor || aTag == nsXULAtoms::browser) { isReplaced = PR_TRUE; diff --git a/layout/xul/base/src/nsScrollBoxObject.cpp b/layout/xul/base/src/nsScrollBoxObject.cpp index b2d512d053ee..a14857e6e0f2 100644 --- a/layout/xul/base/src/nsScrollBoxObject.cpp +++ b/layout/xul/base/src/nsScrollBoxObject.cpp @@ -47,6 +47,7 @@ #include "nsIPresContext.h" #include "nsIFrame.h" #include "nsIScrollableView.h" +#include "nsIScrollableFrame.h" #include "nsIBox.h" @@ -109,25 +110,46 @@ NS_IMETHODIMP nsScrollBoxObject::ScrollByLine(PRInt32 dlines) return scrollableView->ScrollByLines(0, dlines); } +// XUL elements have a single box child element. +// Get a pointer to that box. +// Note that now that the is just a regular box +// with 'overflow:hidden', the boxobject's frame is an nsXULScrollFrame, +// the 's box frame is the scrollframe's "scrolled frame", and +// the 's child box is a child of that. +static nsIBox* GetScrolledBox(nsBoxObject* aScrollBox) { + nsIFrame* frame = aScrollBox->GetFrame(); + if (!frame) + return nsnull; + nsIScrollableFrame* scrollFrame; + if (NS_FAILED(CallQueryInterface(frame, &scrollFrame))) { + NS_WARNING("nsIScrollBoxObject attached to something that's not a scroll frame!"); + return nsnull; + } + nsIFrame* scrolledFrame; + if (NS_FAILED(scrollFrame->GetScrolledFrame(frame->GetPresContext(), scrolledFrame))) + return nsnull; + nsIBox* scrollBox; + if (NS_FAILED(CallQueryInterface(scrolledFrame, &scrollBox))) + return nsnull; + nsIBox* scrolledBox; + if (NS_FAILED(scrollBox->GetChildBox(&scrolledBox))) + return nsnull; + return scrolledBox; +} + /* void scrollByIndex (in long dindexes); */ NS_IMETHODIMP nsScrollBoxObject::ScrollByIndex(PRInt32 dindexes) { nsIScrollableView* scrollableView = GetScrollableView(); if (!scrollableView) return NS_ERROR_FAILURE; - - // get our box - nsIFrame* frame = GetFrame(); - nsIBox* box; - CallQueryInterface(frame, &box); + nsIBox* scrolledBox = GetScrolledBox(this); + if (!scrolledBox) + return NS_ERROR_FAILURE; nsRect rect; - nsIBox* scrolledBox; nsIBox* child; - // get the scrolled box - box->GetChildBox(&scrolledBox); - // now get the scrolled boxes first child. scrolledBox->GetChildBox(&child); @@ -217,16 +239,14 @@ NS_IMETHODIMP nsScrollBoxObject::ScrollToElement(nsIDOMElement *child) float pixelsToTwips = 0.0; pixelsToTwips = context->PixelsToTwips(); - // get our box - nsIFrame* frame = GetFrame(); - nsIBox *box; - CallQueryInterface(frame, &box); + nsIBox* scrolledBox = GetScrolledBox(this); + if (!scrolledBox) + return NS_ERROR_FAILURE; nsRect rect, crect; - nsIBox* scrolledBox; nsCOMPtr childDOMXULElement (do_QueryInterface(child)); nsIBoxObject * childBoxObject; - childDOMXULElement->GetBoxObject(&childBoxObject); + childDOMXULElement->GetBoxObject(&childBoxObject); PRInt32 x,y; childBoxObject->GetX(&x); @@ -235,9 +255,6 @@ NS_IMETHODIMP nsScrollBoxObject::ScrollToElement(nsIDOMElement *child) rect.x = NSToIntRound(x * pixelsToTwips); rect.y = NSToIntRound(y * pixelsToTwips); - // get the scrolled box - box->GetChildBox(&scrolledBox); - // TODO: make sure the child is inside the box // get our current info @@ -297,13 +314,11 @@ NS_IMETHODIMP nsScrollBoxObject::EnsureElementIsVisible(nsIDOMElement *child) float pixelsToTwips = 0.0; pixelsToTwips = context->PixelsToTwips(); - // get our box - nsIFrame* frame = GetFrame(); - nsIBox* box; - CallQueryInterface(frame, &box); + nsIBox* scrolledBox = GetScrolledBox(this); + if (!scrolledBox) + return NS_ERROR_FAILURE; nsRect rect, crect; - nsIBox* scrolledBox; nsCOMPtr childDOMXULElement (do_QueryInterface(child)); nsIBoxObject * childBoxObject; childDOMXULElement->GetBoxObject(&childBoxObject); @@ -319,9 +334,6 @@ NS_IMETHODIMP nsScrollBoxObject::EnsureElementIsVisible(nsIDOMElement *child) rect.width = NSToIntRound(width * pixelsToTwips); rect.height = NSToIntRound(height * pixelsToTwips); - // get the scrolled box - box->GetChildBox(&scrolledBox); - // TODO: make sure the child is inside the box // get our current info @@ -378,12 +390,15 @@ nsScrollBoxObject::GetScrollableView() if (!frame) return nsnull; - nsIScrollableView* scrollingView; - if (NS_SUCCEEDED(CallQueryInterface(frame->GetView(), &scrollingView))) { - return scrollingView; - } + nsIScrollableFrame* scrollFrame; + if (NS_FAILED(CallQueryInterface(frame, &scrollFrame))) + return nsnull; - return nsnull; + nsIScrollableView* scrollingView; + if (NS_FAILED(scrollFrame->GetScrollableView(frame->GetPresContext(), &scrollingView))) + return nsnull; + + return scrollingView; } nsresult diff --git a/toolkit/content/xul.css b/toolkit/content/xul.css index b1160e33e2a2..6b5301822076 100644 --- a/toolkit/content/xul.css +++ b/toolkit/content/xul.css @@ -838,6 +838,7 @@ scrollbar[value="hidden"] { scrollbox { -moz-binding: url("chrome://global/content/bindings/scrollbox.xml#scrollbox"); + overflow:hidden ! important; } arrowscrollbox { diff --git a/xpfe/global/resources/content/xul.css b/xpfe/global/resources/content/xul.css index fb72f95f3486..8232a429d65a 100644 --- a/xpfe/global/resources/content/xul.css +++ b/xpfe/global/resources/content/xul.css @@ -731,6 +731,8 @@ scrollbar[value="hidden"] { scrollbox { -moz-binding: url("chrome://global/content/bindings/scrollbox.xml#scrollbox"); + /* This makes it scrollable! */ + overflow:hidden ! important; } arrowscrollbox {