2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 18:30:37 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1999-08-20 02:16:23 +04:00
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
1999-08-20 02:16:23 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1999-08-20 02:16:23 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-29 00:14:13 +04:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:40:37 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Contributor(s):
|
2004-04-18 18:30:37 +04:00
|
|
|
* Pierre Phaneuf <pp@ludusdesign.com>
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 18:30:37 +04:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-29 00:14:13 +04:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-18 18:30:37 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-29 00:14:13 +04:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-18 18:30:37 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-08-20 02:16:23 +04:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsHTMLParts.h"
|
|
|
|
#include "nsIPresContext.h"
|
2001-12-18 01:39:59 +03:00
|
|
|
#include "nsHTMLReflowCommand.h"
|
1999-08-20 02:16:23 +04:00
|
|
|
#include "nsIDeviceContext.h"
|
|
|
|
#include "nsPageFrame.h"
|
|
|
|
#include "nsViewsCID.h"
|
2000-01-25 09:35:27 +03:00
|
|
|
#include "nsIServiceManager.h"
|
1999-08-20 02:16:23 +04:00
|
|
|
#include "nsIView.h"
|
|
|
|
#include "nsIViewManager.h"
|
|
|
|
#include "nsHTMLContainerFrame.h"
|
|
|
|
#include "nsIScrollableView.h"
|
|
|
|
#include "nsWidgetsCID.h"
|
|
|
|
#include "nsGfxScrollFrame.h"
|
|
|
|
#include "nsLayoutAtoms.h"
|
|
|
|
#include "nsXULAtoms.h"
|
|
|
|
#include "nsHTMLAtoms.h"
|
|
|
|
#include "nsINameSpaceManager.h"
|
|
|
|
#include "nsISupportsArray.h"
|
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsIFontMetrics.h"
|
1999-10-12 04:16:06 +04:00
|
|
|
#include "nsIDocumentObserver.h"
|
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsIScrollPositionListener.h"
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
//#include "nsBoxFrame.h"
|
2000-01-25 09:35:27 +03:00
|
|
|
#include "nsIElementFactory.h"
|
2000-03-31 11:02:06 +04:00
|
|
|
#include "nsBoxLayoutState.h"
|
2000-05-10 17:13:39 +04:00
|
|
|
#include "nsINodeInfo.h"
|
2000-07-14 03:00:59 +04:00
|
|
|
#include "nsIScrollbarFrame.h"
|
|
|
|
#include "nsIScrollbarMediator.h"
|
2002-07-27 00:57:24 +04:00
|
|
|
#include "nsITextControlFrame.h"
|
2000-08-04 02:42:36 +04:00
|
|
|
#include "nsIDOMHTMLTextAreaElement.h"
|
1999-08-20 02:16:23 +04:00
|
|
|
|
2002-01-23 05:53:02 +03:00
|
|
|
#include "nsIPrintPreviewContext.h"
|
|
|
|
#include "nsIURI.h"
|
2002-06-21 01:47:59 +04:00
|
|
|
#include "nsGUIEvent.h"
|
1999-08-20 02:16:23 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2003-04-09 15:27:09 +04:00
|
|
|
class nsGfxScrollFrameInner : public nsIScrollPositionListener {
|
1999-10-12 04:16:06 +04:00
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
nsGfxScrollFrameInner(nsGfxScrollFrame* aOuter);
|
|
|
|
virtual ~nsGfxScrollFrameInner();
|
|
|
|
|
|
|
|
// nsIScrollPositionListener
|
|
|
|
|
1999-10-15 08:29:30 +04:00
|
|
|
NS_IMETHOD ScrollPositionWillChange(nsIScrollableView* aScrollable, nscoord aX, nscoord aY);
|
|
|
|
NS_IMETHOD ScrollPositionDidChange(nsIScrollableView* aScrollable, nscoord aX, nscoord aY);
|
1999-10-12 04:16:06 +04:00
|
|
|
|
2003-04-09 15:27:09 +04:00
|
|
|
// This gets called when the 'curpos' attribute on one of the scrollbars changes
|
|
|
|
nsresult CurPosAttributeChanged(nsIPresContext* aPresContext,
|
|
|
|
nsIContent* aChild,
|
|
|
|
PRInt32 aModType);
|
1999-10-12 04:16:06 +04:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
PRBool SetAttribute(nsIBox* aBox, nsIAtom* aAtom, nscoord aSize, PRBool aReflow=PR_TRUE);
|
|
|
|
PRInt32 GetIntegerAttribute(nsIBox* aFrame, nsIAtom* atom, PRInt32 defaultValue);
|
1999-10-12 04:16:06 +04:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
nsresult Layout(nsBoxLayoutState& aState);
|
|
|
|
nsresult LayoutBox(nsBoxLayoutState& aState, nsIBox* aBox, const nsRect& aRect);
|
2003-04-05 15:41:19 +04:00
|
|
|
|
|
|
|
// Like ScrollPositionDidChange, but initiated by this frame rather than from the
|
|
|
|
// scrolling view
|
|
|
|
void InternalScrollPositionDidChange(nscoord aX, nscoord aY);
|
1999-10-12 04:16:06 +04:00
|
|
|
|
2000-05-15 08:12:31 +04:00
|
|
|
PRBool AddRemoveScrollbar (PRBool& aHasScrollbar,
|
2000-04-03 10:26:38 +04:00
|
|
|
nscoord& aXY,
|
|
|
|
nscoord& aSize,
|
|
|
|
nscoord aSbSize,
|
|
|
|
PRBool aOnRightOrBottom,
|
|
|
|
PRBool aAdd);
|
|
|
|
|
2000-05-15 08:12:31 +04:00
|
|
|
PRBool AddRemoveScrollbar(nsBoxLayoutState& aState,
|
|
|
|
nsRect& aScrollAreaSize,
|
|
|
|
PRBool aOnTop,
|
|
|
|
PRBool aHorizontal,
|
|
|
|
PRBool aAdd);
|
|
|
|
|
|
|
|
PRBool AddHorizontalScrollbar (nsBoxLayoutState& aState, nsRect& aScrollAreaSize, PRBool aOnBottom);
|
|
|
|
PRBool AddVerticalScrollbar (nsBoxLayoutState& aState, nsRect& aScrollAreaSize, PRBool aOnRight);
|
2004-03-11 02:52:01 +03:00
|
|
|
void RemoveHorizontalScrollbar(nsBoxLayoutState& aState, nsRect& aScrollAreaSize, PRBool aOnBottom);
|
|
|
|
void RemoveVerticalScrollbar (nsBoxLayoutState& aState, nsRect& aScrollAreaSize, PRBool aOnRight);
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
|
1999-10-26 08:44:41 +04:00
|
|
|
nsIScrollableView* GetScrollableView(nsIPresContext* aPresContext);
|
1999-10-12 04:16:06 +04:00
|
|
|
|
2003-03-24 08:29:45 +03:00
|
|
|
void ScrollbarChanged(nsIPresContext* aPresContext, nscoord aX, nscoord aY, PRUint32 aFlags);
|
1999-10-12 04:16:06 +04:00
|
|
|
|
2000-05-15 08:12:31 +04:00
|
|
|
void SetScrollbarVisibility(nsIBox* aScrollbar, PRBool aVisible);
|
|
|
|
|
2000-07-08 02:24:06 +04:00
|
|
|
NS_IMETHOD GetScrolledSize(nsIPresContext* aPresContext,
|
|
|
|
nscoord *aWidth,
|
|
|
|
nscoord *aHeight) const;
|
2002-01-23 05:53:02 +03:00
|
|
|
void AdjustReflowStateForPrintPreview(nsBoxLayoutState& aState, PRBool& aSetBack);
|
|
|
|
void AdjustReflowStateBack(nsBoxLayoutState& aState, PRBool aSetBack);
|
2000-07-08 02:24:06 +04:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
nsIBox* mHScrollbarBox;
|
|
|
|
nsIBox* mVScrollbarBox;
|
|
|
|
nsIBox* mScrollAreaBox;
|
2003-11-21 13:45:24 +03:00
|
|
|
nsIBox* mScrollCornerBox;
|
1999-10-12 04:16:06 +04:00
|
|
|
nscoord mOnePixel;
|
|
|
|
nsGfxScrollFrame* mOuter;
|
2003-01-09 17:26:32 +03:00
|
|
|
nscoord mMaxElementWidth;
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
|
2004-01-06 02:56:00 +03:00
|
|
|
// The last dir value we saw in AddHorizontalScrollbar. Use PRInt16
|
|
|
|
// so we can fit all the possible values of a PRUint8 and have a -1
|
|
|
|
// value that indicates "not set")
|
|
|
|
PRInt16 mLastDir;
|
|
|
|
|
2001-12-15 02:13:08 +03:00
|
|
|
PRPackedBool mNeverHasVerticalScrollbar;
|
|
|
|
PRPackedBool mNeverHasHorizontalScrollbar;
|
|
|
|
|
|
|
|
PRPackedBool mHasVerticalScrollbar;
|
|
|
|
PRPackedBool mHasHorizontalScrollbar;
|
|
|
|
PRPackedBool mFirstPass;
|
|
|
|
PRPackedBool mIsRoot;
|
|
|
|
PRPackedBool mNeverReflowed;
|
2003-04-05 15:41:19 +04:00
|
|
|
PRPackedBool mViewInitiatedScroll;
|
|
|
|
PRPackedBool mFrameInitiatedScroll;
|
1999-10-12 04:16:06 +04:00
|
|
|
};
|
|
|
|
|
2003-04-09 15:27:09 +04:00
|
|
|
NS_IMPL_ISUPPORTS1(nsGfxScrollFrameInner, nsIScrollPositionListener)
|
1999-10-12 04:16:06 +04:00
|
|
|
|
1999-08-20 02:16:23 +04:00
|
|
|
nsresult
|
2000-03-31 11:02:06 +04:00
|
|
|
NS_NewGfxScrollFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame, nsIDocument* aDocument, PRBool aIsRoot)
|
1999-08-20 02:16:23 +04:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
|
|
|
if (nsnull == aNewFrame) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
2000-03-31 11:02:06 +04:00
|
|
|
nsGfxScrollFrame* it = new (aPresShell) nsGfxScrollFrame(aPresShell, aDocument, aIsRoot);
|
1999-08-20 02:16:23 +04:00
|
|
|
if (nsnull == it) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
*aNewFrame = it;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
nsGfxScrollFrame::nsGfxScrollFrame(nsIPresShell* aShell, nsIDocument* aDocument, PRBool aIsRoot):nsBoxFrame(aShell, aIsRoot)
|
1999-08-20 02:16:23 +04:00
|
|
|
{
|
1999-10-12 04:16:06 +04:00
|
|
|
mInner = new nsGfxScrollFrameInner(this);
|
|
|
|
mInner->AddRef();
|
1999-10-26 08:44:41 +04:00
|
|
|
mPresContext = nsnull;
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
mInner->mIsRoot = PR_FALSE;
|
2000-02-11 00:36:28 +03:00
|
|
|
mInner->mNeverReflowed = PR_TRUE;
|
2003-04-05 15:41:19 +04:00
|
|
|
mInner->mViewInitiatedScroll = PR_FALSE;
|
|
|
|
mInner->mFrameInitiatedScroll = PR_FALSE;
|
2000-03-31 11:02:06 +04:00
|
|
|
SetLayoutManager(nsnull);
|
1999-10-12 04:16:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsGfxScrollFrame::~nsGfxScrollFrame()
|
|
|
|
{
|
|
|
|
mInner->mOuter = nsnull;
|
|
|
|
mInner->Release();
|
1999-10-26 08:44:41 +04:00
|
|
|
mPresContext = nsnull;
|
1999-08-20 02:16:23 +04:00
|
|
|
}
|
|
|
|
|
1999-12-07 06:36:05 +03:00
|
|
|
/**
|
|
|
|
* Set the view that we are scrolling within the scrolling view.
|
|
|
|
*/
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGfxScrollFrame::SetScrolledFrame(nsIPresContext* aPresContext, nsIFrame *aScrolledFrame)
|
|
|
|
{
|
2000-03-31 11:02:06 +04:00
|
|
|
NS_ERROR("Not implemented!");
|
|
|
|
/*
|
|
|
|
mFrames.DestroyFrame(aPresContext, mInner->mScrollAreaBox);
|
|
|
|
mInner->mScrollAreaBox = aScrolledFrame;
|
|
|
|
mFrames.InsertFrame(nsnull, nsnull, mInner->mScrollAreaBox);
|
|
|
|
*/
|
1999-12-07 06:36:05 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the view that we are scrolling within the scrolling view.
|
|
|
|
* @result child view
|
|
|
|
*/
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGfxScrollFrame::GetScrolledFrame(nsIPresContext* aPresContext, nsIFrame *&aScrolledFrame) const
|
|
|
|
{
|
2000-03-31 11:02:06 +04:00
|
|
|
nsIBox* child = nsnull;
|
|
|
|
mInner->mScrollAreaBox->GetChildBox(&child);
|
|
|
|
child->GetFrame(&aScrolledFrame);
|
|
|
|
return NS_OK;
|
1999-12-07 06:36:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get information about whether the vertical and horizontal scrollbars
|
2000-05-14 03:00:53 +04:00
|
|
|
* are currently visible
|
1999-12-07 06:36:05 +03:00
|
|
|
*/
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGfxScrollFrame::GetScrollbarVisibility(nsIPresContext* aPresContext,
|
|
|
|
PRBool *aVerticalVisible,
|
|
|
|
PRBool *aHorizontalVisible) const
|
|
|
|
{
|
|
|
|
*aVerticalVisible = mInner->mHasVerticalScrollbar;
|
|
|
|
*aHorizontalVisible = mInner->mHasHorizontalScrollbar;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-07-27 10:57:32 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGfxScrollFrame::GetScrollableView(nsIPresContext* aContext, nsIScrollableView** aResult)
|
|
|
|
{
|
|
|
|
*aResult = mInner->GetScrollableView(aContext);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-05-14 03:00:53 +04:00
|
|
|
|
2000-05-15 08:12:31 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGfxScrollFrame::GetScrollPosition(nsIPresContext* aContext, nscoord &aX, nscoord& aY) const
|
|
|
|
{
|
|
|
|
nsIScrollableView* s = mInner->GetScrollableView(aContext);
|
|
|
|
return s->GetScrollPosition(aX, aY);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGfxScrollFrame::ScrollTo(nsIPresContext* aContext, nscoord aX, nscoord aY, PRUint32 aFlags)
|
|
|
|
{
|
|
|
|
nsIScrollableView* s = mInner->GetScrollableView(aContext);
|
|
|
|
return s->ScrollTo(aX, aY, aFlags);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Query whether scroll bars should be displayed all the time, never or
|
|
|
|
* only when necessary.
|
|
|
|
* @return current scrollbar selection
|
2003-05-22 05:46:13 +04:00
|
|
|
* XXX roc only 'Auto' is really tested for. This API should be simplified or
|
|
|
|
* eliminated.
|
2000-05-15 08:12:31 +04:00
|
|
|
*/
|
|
|
|
NS_IMETHODIMP
|
2000-05-17 08:45:44 +04:00
|
|
|
nsGfxScrollFrame::GetScrollPreference(nsIPresContext* aPresContext, nsScrollPref* aScrollPreference) const
|
2000-05-15 08:12:31 +04:00
|
|
|
{
|
2003-05-22 05:46:13 +04:00
|
|
|
ScrollbarStyles styles = GetScrollbarStyles();
|
|
|
|
|
|
|
|
if (styles.mHorizontal == NS_STYLE_OVERFLOW_SCROLL &&
|
|
|
|
styles.mVertical == NS_STYLE_OVERFLOW_SCROLL) {
|
|
|
|
*aScrollPreference = AlwaysScroll;
|
|
|
|
} else if (styles.mHorizontal == NS_STYLE_OVERFLOW_SCROLL) {
|
|
|
|
*aScrollPreference = AlwaysScrollHorizontal;
|
|
|
|
} else if (styles.mVertical == NS_STYLE_OVERFLOW_SCROLL) {
|
|
|
|
*aScrollPreference = AlwaysScrollVertical;
|
|
|
|
} else if (styles.mHorizontal == NS_STYLE_OVERFLOW_AUTO ||
|
|
|
|
styles.mVertical == NS_STYLE_OVERFLOW_AUTO) {
|
|
|
|
*aScrollPreference = Auto;
|
|
|
|
} else {
|
|
|
|
*aScrollPreference = NeverScroll;
|
2000-05-15 08:12:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2004-01-09 22:21:20 +03:00
|
|
|
nsMargin nsGfxScrollFrame::GetActualScrollbarSizes() const {
|
|
|
|
nsRect bounds = GetRect();
|
|
|
|
nsRect scrollArea;
|
|
|
|
mInner->mScrollAreaBox->GetBounds(scrollArea);
|
2000-05-15 08:12:31 +04:00
|
|
|
|
2004-01-09 22:21:20 +03:00
|
|
|
return nsMargin(scrollArea.x, scrollArea.y,
|
|
|
|
bounds.width - scrollArea.XMost(),
|
|
|
|
bounds.height - scrollArea.YMost());
|
|
|
|
}
|
|
|
|
|
|
|
|
nsMargin nsGfxScrollFrame::GetDesiredScrollbarSizes(nsBoxLayoutState* aState) {
|
|
|
|
nsMargin result(0, 0, 0, 0);
|
2003-04-22 05:33:14 +04:00
|
|
|
|
2001-12-18 01:51:39 +03:00
|
|
|
if (mInner->mHScrollbarBox) {
|
2004-01-09 22:21:20 +03:00
|
|
|
nsSize size;
|
|
|
|
mInner->mHScrollbarBox->GetPrefSize(*aState, size);
|
|
|
|
#ifdef IBMBIDI
|
|
|
|
if (GetStyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL)
|
|
|
|
result.left = size.width;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
result.right = size.width;
|
2001-12-18 01:51:39 +03:00
|
|
|
}
|
2000-05-15 08:12:31 +04:00
|
|
|
|
2001-12-18 01:51:39 +03:00
|
|
|
if (mInner->mVScrollbarBox) {
|
2004-01-09 22:21:20 +03:00
|
|
|
nsSize size;
|
|
|
|
mInner->mVScrollbarBox->GetPrefSize(*aState, size);
|
|
|
|
// We don't currently support any scripts that would require a scrollbar
|
|
|
|
// at the top. (Are there any?)
|
|
|
|
result.bottom = size.height;
|
2001-12-18 01:51:39 +03:00
|
|
|
}
|
2000-05-15 08:12:31 +04:00
|
|
|
|
2004-01-09 22:21:20 +03:00
|
|
|
return result;
|
2000-05-15 08:12:31 +04:00
|
|
|
}
|
|
|
|
|
2000-05-14 03:00:53 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGfxScrollFrame::SetScrollbarVisibility(nsIPresContext* aPresContext,
|
|
|
|
PRBool aVerticalVisible,
|
|
|
|
PRBool aHorizontalVisible)
|
|
|
|
{
|
|
|
|
mInner->mNeverHasVerticalScrollbar = !aVerticalVisible;
|
|
|
|
mInner->mNeverHasHorizontalScrollbar = !aHorizontalVisible;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-06-07 03:14:11 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGfxScrollFrame::GetScrollbarBox(PRBool aVertical, nsIBox** aResult)
|
|
|
|
{
|
|
|
|
*aResult = aVertical ? mInner->mVScrollbarBox : mInner->mHScrollbarBox;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-05-14 03:00:53 +04:00
|
|
|
|
1999-08-20 02:16:23 +04:00
|
|
|
NS_IMETHODIMP
|
2000-01-22 04:16:50 +03:00
|
|
|
nsGfxScrollFrame::CreateAnonymousContent(nsIPresContext* aPresContext,
|
|
|
|
nsISupportsArray& aAnonymousChildren)
|
1999-08-20 02:16:23 +04:00
|
|
|
{
|
2003-04-22 05:33:14 +04:00
|
|
|
// Don't create scrollbars if we're printing/print previewing
|
|
|
|
// Get rid of this code when printing moves to its own presentation
|
2004-03-03 21:24:20 +03:00
|
|
|
if (aPresContext->IsPaginated()) {
|
2003-04-22 05:33:14 +04:00
|
|
|
// allow scrollbars if this is the child of the viewport, because
|
|
|
|
// we must be the scrollbars for the print preview window
|
2003-06-26 15:30:17 +04:00
|
|
|
nsIFrame* parent = GetParent();
|
2003-10-31 23:19:18 +03:00
|
|
|
if (!parent || parent->GetType() != nsLayoutAtoms::viewportFrame) {
|
2003-04-22 05:33:14 +04:00
|
|
|
SetScrollbarVisibility(aPresContext, PR_FALSE, PR_FALSE);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-12-21 08:36:36 +03:00
|
|
|
nsIPresShell *shell = aPresContext->GetPresShell();
|
2003-04-09 15:27:09 +04:00
|
|
|
nsCOMPtr<nsIDocument> document;
|
|
|
|
if (shell)
|
|
|
|
shell->GetDocument(getter_AddRefs(document));
|
|
|
|
|
2000-08-04 02:42:36 +04:00
|
|
|
// The anonymous <div> used by <inputs> never gets scrollbars.
|
2002-07-27 00:57:24 +04:00
|
|
|
nsCOMPtr<nsITextControlFrame> textFrame(do_QueryInterface(mParent));
|
2000-08-04 02:42:36 +04:00
|
|
|
if (textFrame) {
|
|
|
|
// Make sure we are not a text area.
|
2003-06-26 15:30:17 +04:00
|
|
|
nsCOMPtr<nsIDOMHTMLTextAreaElement> textAreaElement(do_QueryInterface(mParent->GetContent()));
|
2000-08-04 02:42:36 +04:00
|
|
|
if (!textAreaElement) {
|
|
|
|
SetScrollbarVisibility(aPresContext, PR_FALSE, PR_FALSE);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-08-20 02:16:23 +04:00
|
|
|
// create horzontal scrollbar
|
2000-01-25 09:35:27 +03:00
|
|
|
nsresult rv;
|
2001-07-25 11:54:28 +04:00
|
|
|
nsCOMPtr<nsIElementFactory> elementFactory =
|
|
|
|
do_GetService(NS_ELEMENT_FACTORY_CONTRACTID_PREFIX "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", &rv);
|
2000-01-25 09:35:27 +03:00
|
|
|
if (!elementFactory)
|
|
|
|
return NS_ERROR_FAILURE;
|
1999-08-20 02:16:23 +04:00
|
|
|
|
2003-10-22 10:09:48 +04:00
|
|
|
nsINodeInfoManager *nodeInfoManager = nsnull;
|
2003-04-09 15:27:09 +04:00
|
|
|
if (document)
|
2003-10-22 10:09:48 +04:00
|
|
|
nodeInfoManager = document->GetNodeInfoManager();
|
2000-05-10 17:13:39 +04:00
|
|
|
NS_ENSURE_TRUE(nodeInfoManager, NS_ERROR_FAILURE);
|
|
|
|
|
|
|
|
nsCOMPtr<nsINodeInfo> nodeInfo;
|
2004-01-18 13:22:22 +03:00
|
|
|
nodeInfoManager->GetNodeInfo(nsXULAtoms::scrollbar, nsnull,
|
2003-11-05 08:17:07 +03:00
|
|
|
kNameSpaceID_XUL, getter_AddRefs(nodeInfo));
|
2000-05-10 17:13:39 +04:00
|
|
|
|
2003-05-22 05:46:13 +04:00
|
|
|
ScrollbarStyles styles = GetScrollbarStyles();
|
2003-11-21 13:45:24 +03:00
|
|
|
PRBool canHaveHorizontal = styles.mHorizontal == NS_STYLE_OVERFLOW_AUTO
|
|
|
|
|| styles.mHorizontal == NS_STYLE_OVERFLOW_SCROLL;
|
|
|
|
if (canHaveHorizontal) {
|
2003-05-22 05:46:13 +04:00
|
|
|
nsCOMPtr<nsIContent> content;
|
|
|
|
elementFactory->CreateInstanceByTag(nodeInfo, getter_AddRefs(content));
|
|
|
|
content->SetAttr(kNameSpaceID_None, nsXULAtoms::orient,
|
|
|
|
NS_LITERAL_STRING("horizontal"), PR_FALSE);
|
|
|
|
aAnonymousChildren.AppendElement(content);
|
|
|
|
}
|
2003-04-09 15:17:42 +04:00
|
|
|
|
2003-11-21 13:45:24 +03:00
|
|
|
PRBool canHaveVertical = styles.mVertical == NS_STYLE_OVERFLOW_AUTO
|
|
|
|
|| styles.mVertical == NS_STYLE_OVERFLOW_SCROLL;
|
|
|
|
if (canHaveVertical) {
|
2003-05-22 05:46:13 +04:00
|
|
|
nsCOMPtr<nsIContent> content;
|
|
|
|
elementFactory->CreateInstanceByTag(nodeInfo, getter_AddRefs(content));
|
|
|
|
content->SetAttr(kNameSpaceID_None, nsXULAtoms::orient,
|
|
|
|
NS_LITERAL_STRING("vertical"), PR_FALSE);
|
|
|
|
aAnonymousChildren.AppendElement(content);
|
|
|
|
}
|
2003-04-09 15:17:42 +04:00
|
|
|
|
2003-11-21 13:45:24 +03:00
|
|
|
if (canHaveHorizontal && canHaveVertical) {
|
2004-01-18 13:22:22 +03:00
|
|
|
nodeInfoManager->GetNodeInfo(nsXULAtoms::scrollcorner, nsnull,
|
2003-11-21 13:45:24 +03:00
|
|
|
kNameSpaceID_XUL, getter_AddRefs(nodeInfo));
|
|
|
|
nsCOMPtr<nsIContent> content;
|
|
|
|
elementFactory->CreateInstanceByTag(nodeInfo, getter_AddRefs(content));
|
|
|
|
aAnonymousChildren.AppendElement(content);
|
|
|
|
}
|
|
|
|
|
1999-08-20 02:16:23 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsGfxScrollFrame::Destroy(nsIPresContext* aPresContext)
|
1999-08-20 02:16:23 +04:00
|
|
|
|
|
|
|
{
|
2002-07-09 08:30:28 +04:00
|
|
|
nsIScrollableView *view = mInner->GetScrollableView(aPresContext);
|
|
|
|
NS_ASSERTION(view, "unexpected null pointer");
|
|
|
|
if (view)
|
|
|
|
view->RemoveScrollPositionListener(mInner);
|
2000-03-31 11:02:06 +04:00
|
|
|
return nsBoxFrame::Destroy(aPresContext);
|
1999-08-20 02:16:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsGfxScrollFrame::Init(nsIPresContext* aPresContext,
|
1999-08-20 02:16:23 +04:00
|
|
|
nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aStyleContext,
|
1999-08-20 02:16:23 +04:00
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
1999-11-24 09:03:41 +03:00
|
|
|
mPresContext = aPresContext;
|
2003-11-21 13:45:24 +03:00
|
|
|
nsresult rv = nsBoxFrame::Init(aPresContext, aContent, aParent, aStyleContext,
|
|
|
|
aPrevInFlow);
|
1999-08-20 02:16:23 +04:00
|
|
|
return rv;
|
|
|
|
}
|
2003-04-09 00:50:57 +04:00
|
|
|
|
|
|
|
void nsGfxScrollFrame::ReloadChildFrames(nsIPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
mInner->mScrollAreaBox = nsnull;
|
|
|
|
mInner->mHScrollbarBox = nsnull;
|
|
|
|
mInner->mVScrollbarBox = nsnull;
|
2003-11-21 13:45:24 +03:00
|
|
|
mInner->mScrollCornerBox = nsnull;
|
2003-04-09 00:50:57 +04:00
|
|
|
|
2004-01-09 17:20:53 +03:00
|
|
|
nsIFrame* frame = GetFirstChild(nsnull);
|
2003-04-09 00:50:57 +04:00
|
|
|
while (frame) {
|
|
|
|
PRBool understood = PR_FALSE;
|
|
|
|
|
|
|
|
nsIBox* box = nsnull;
|
|
|
|
frame->QueryInterface(NS_GET_IID(nsIBox), (void**)&box);
|
|
|
|
if (box) {
|
2003-10-31 23:19:18 +03:00
|
|
|
if (frame->GetType() == nsLayoutAtoms::scrollFrame) {
|
2003-04-09 00:50:57 +04:00
|
|
|
NS_ASSERTION(!mInner->mScrollAreaBox, "Found multiple scroll areas?");
|
|
|
|
mInner->mScrollAreaBox = box;
|
|
|
|
understood = PR_TRUE;
|
|
|
|
} else {
|
2003-06-26 15:30:17 +04:00
|
|
|
nsIContent* content = frame->GetContent();
|
2003-04-09 00:50:57 +04:00
|
|
|
if (content) {
|
|
|
|
nsAutoString value;
|
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttr(kNameSpaceID_None,
|
|
|
|
nsXULAtoms::orient, value)) {
|
|
|
|
// probably a scrollbar then
|
|
|
|
if (value.EqualsIgnoreCase("horizontal")) {
|
|
|
|
NS_ASSERTION(!mInner->mHScrollbarBox, "Found multiple horizontal scrollbars?");
|
|
|
|
mInner->mHScrollbarBox = box;
|
|
|
|
} else {
|
|
|
|
NS_ASSERTION(!mInner->mVScrollbarBox, "Found multiple vertical scrollbars?");
|
|
|
|
mInner->mVScrollbarBox = box;
|
|
|
|
}
|
|
|
|
understood = PR_TRUE;
|
2003-11-21 13:45:24 +03:00
|
|
|
} else {
|
|
|
|
// probably a scrollcorner
|
|
|
|
NS_ASSERTION(!mInner->mScrollCornerBox, "Found multiple scrollcorners");
|
|
|
|
mInner->mScrollCornerBox = box;
|
|
|
|
understood = PR_TRUE;
|
2003-04-09 00:50:57 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_ASSERTION(understood, "What is this frame doing here?");
|
|
|
|
|
2003-06-26 15:30:17 +04:00
|
|
|
frame = frame->GetNextSibling();
|
2003-04-09 00:50:57 +04:00
|
|
|
}
|
|
|
|
}
|
1999-08-20 02:16:23 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsGfxScrollFrame::SetInitialChildList(nsIPresContext* aPresContext,
|
1999-08-20 02:16:23 +04:00
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aChildList)
|
|
|
|
{
|
2000-03-31 11:02:06 +04:00
|
|
|
nsresult rv = nsBoxFrame::SetInitialChildList(aPresContext, aListName,
|
1999-08-20 02:16:23 +04:00
|
|
|
aChildList);
|
|
|
|
|
2003-04-09 00:50:57 +04:00
|
|
|
ReloadChildFrames(aPresContext);
|
1999-08-20 02:16:23 +04:00
|
|
|
|
1999-10-12 04:16:06 +04:00
|
|
|
// listen for scroll events.
|
1999-11-24 09:03:41 +03:00
|
|
|
mInner->GetScrollableView(aPresContext)->AddScrollPositionListener(mInner);
|
1999-08-20 02:16:23 +04:00
|
|
|
|
1999-10-12 04:16:06 +04:00
|
|
|
return rv;
|
1999-08-20 02:16:23 +04:00
|
|
|
}
|
|
|
|
|
2000-05-15 08:12:31 +04:00
|
|
|
|
1999-08-20 02:16:23 +04:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsGfxScrollFrame::AppendFrames(nsIPresContext* aPresContext,
|
2000-05-15 08:12:31 +04:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aFrameList)
|
1999-08-20 02:16:23 +04:00
|
|
|
{
|
2003-04-09 00:50:57 +04:00
|
|
|
nsresult rv = nsBoxFrame::AppendFrames(aPresContext,
|
|
|
|
aPresShell,
|
|
|
|
aListName,
|
|
|
|
aFrameList);
|
|
|
|
ReloadChildFrames(aPresContext);
|
|
|
|
return rv;
|
1999-08-20 02:16:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsGfxScrollFrame::InsertFrames(nsIPresContext* aPresContext,
|
2000-05-15 08:12:31 +04:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aPrevFrame,
|
|
|
|
nsIFrame* aFrameList)
|
1999-08-20 02:16:23 +04:00
|
|
|
{
|
2003-04-09 00:50:57 +04:00
|
|
|
nsresult rv = nsBoxFrame::InsertFrames(aPresContext,
|
|
|
|
aPresShell,
|
|
|
|
aListName,
|
|
|
|
aPrevFrame,
|
|
|
|
aFrameList);
|
|
|
|
ReloadChildFrames(aPresContext);
|
|
|
|
return rv;
|
1999-08-20 02:16:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsGfxScrollFrame::RemoveFrame(nsIPresContext* aPresContext,
|
2000-05-15 08:12:31 +04:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aOldFrame)
|
1999-08-20 02:16:23 +04:00
|
|
|
{
|
2003-04-09 00:50:57 +04:00
|
|
|
nsresult rv = nsBoxFrame::RemoveFrame(aPresContext,
|
|
|
|
aPresShell,
|
|
|
|
aListName,
|
|
|
|
aOldFrame);
|
|
|
|
ReloadChildFrames(aPresContext);
|
|
|
|
return rv;
|
1999-08-20 02:16:23 +04:00
|
|
|
}
|
|
|
|
|
2000-05-15 08:12:31 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGfxScrollFrame::ReplaceFrame(nsIPresContext* aPresContext,
|
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aOldFrame,
|
|
|
|
nsIFrame* aNewFrame)
|
|
|
|
{
|
2003-04-09 00:50:57 +04:00
|
|
|
nsresult rv = nsBoxFrame::ReplaceFrame(aPresContext,
|
|
|
|
aPresShell,
|
|
|
|
aListName,
|
|
|
|
aOldFrame,
|
|
|
|
aNewFrame);
|
|
|
|
ReloadChildFrames(aPresContext);
|
|
|
|
return rv;
|
2000-05-15 08:12:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1999-08-20 02:16:23 +04:00
|
|
|
NS_IMETHODIMP
|
2000-03-31 11:02:06 +04:00
|
|
|
nsGfxScrollFrame::GetPadding(nsMargin& aMargin)
|
1999-08-20 02:16:23 +04:00
|
|
|
{
|
2000-03-31 11:02:06 +04:00
|
|
|
aMargin.SizeTo(0,0,0,0);
|
|
|
|
return NS_OK;
|
1999-08-20 02:16:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-09-19 16:35:19 +04:00
|
|
|
nsGfxScrollFrame::Paint(nsIPresContext* aPresContext,
|
2000-03-31 11:02:06 +04:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect,
|
2001-09-19 16:35:19 +04:00
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
PRUint32 aFlags)
|
1999-08-20 02:16:23 +04:00
|
|
|
{
|
2002-01-08 17:58:52 +03:00
|
|
|
nsresult result;
|
|
|
|
|
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
// Paint our children
|
2002-02-15 17:48:12 +03:00
|
|
|
result = nsBoxFrame::Paint(aPresContext, aRenderingContext, aDirtyRect,aWhichLayer);
|
2002-01-08 17:58:52 +03:00
|
|
|
return result;
|
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
1999-08-20 02:16:23 +04:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGfxScrollFrame::GetContentAndOffsetsFromPoint(nsIPresContext* aCX,
|
|
|
|
const nsPoint& aPoint,
|
|
|
|
nsIContent ** aNewContent,
|
|
|
|
PRInt32& aContentOffset,
|
|
|
|
PRInt32& aContentOffsetEnd,
|
|
|
|
PRBool& aBeginFrameContent)
|
|
|
|
{
|
|
|
|
if (! mInner)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
1999-10-12 04:16:06 +04:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
nsIFrame* frame = nsnull;
|
|
|
|
mInner->mScrollAreaBox->GetFrame(&frame);
|
2002-08-27 00:55:30 +04:00
|
|
|
nsPoint point(aPoint);
|
|
|
|
//we need to translate the coordinates to the inner
|
2003-06-29 07:43:05 +04:00
|
|
|
nsIView *view = GetClosestView();
|
2002-08-27 00:55:30 +04:00
|
|
|
if (!view)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2003-06-29 07:43:05 +04:00
|
|
|
nsIView *innerView = GetClosestView();
|
2002-08-27 00:55:30 +04:00
|
|
|
while (view != innerView && innerView)
|
|
|
|
{
|
2003-06-29 07:43:05 +04:00
|
|
|
point -= innerView->GetPosition();
|
|
|
|
innerView = innerView->GetParent();
|
2002-08-27 00:55:30 +04:00
|
|
|
}
|
1999-10-12 04:16:06 +04:00
|
|
|
|
2002-08-27 00:55:30 +04:00
|
|
|
return frame->GetContentAndOffsetsFromPoint(aCX, point, aNewContent, aContentOffset, aContentOffsetEnd, aBeginFrameContent);
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
1999-10-12 04:16:06 +04:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
PRIntn
|
|
|
|
nsGfxScrollFrame::GetSkipSides() const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
1999-10-12 04:16:06 +04:00
|
|
|
|
2003-10-31 23:19:18 +03:00
|
|
|
nsIAtom*
|
|
|
|
nsGfxScrollFrame::GetType() const
|
2000-03-31 11:02:06 +04:00
|
|
|
{
|
2003-10-31 23:19:18 +03:00
|
|
|
return nsLayoutAtoms::scrollFrame;
|
1999-08-20 02:16:23 +04:00
|
|
|
}
|
|
|
|
|
2000-05-15 08:12:31 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGfxScrollFrame::GetAscent(nsBoxLayoutState& aState, nscoord& aAscent)
|
|
|
|
{
|
|
|
|
aAscent = 0;
|
|
|
|
nsresult rv = mInner->mScrollAreaBox->GetAscent(aState, aAscent);
|
|
|
|
nsMargin m(0,0,0,0);
|
|
|
|
GetBorderAndPadding(m);
|
|
|
|
aAscent += m.top;
|
|
|
|
GetMargin(m);
|
|
|
|
aAscent += m.top;
|
|
|
|
GetInset(m);
|
|
|
|
aAscent += m.top;
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2003-05-22 05:46:13 +04:00
|
|
|
nsGfxScrollFrame::ScrollbarStyles
|
|
|
|
nsGfxScrollFrame::GetScrollbarStyles() const
|
|
|
|
{
|
2004-04-13 06:56:03 +04:00
|
|
|
PRUint8 overflow;
|
2004-04-22 23:33:56 +04:00
|
|
|
if (GetParent() && GetParent()->GetType() == nsLayoutAtoms::viewportFrame &&
|
|
|
|
// Make sure we're actually the root scrollframe
|
2004-04-23 00:58:32 +04:00
|
|
|
GetParent()->GetFirstChild(nsnull) ==
|
|
|
|
NS_STATIC_CAST(const nsIFrame*, this)) {
|
2004-04-13 06:56:03 +04:00
|
|
|
overflow = GetPresContext()->GetViewportOverflowOverride();
|
|
|
|
} else {
|
|
|
|
overflow = GetStyleDisplay()->mOverflow;
|
|
|
|
}
|
|
|
|
|
2003-05-22 05:46:13 +04:00
|
|
|
switch (overflow) {
|
|
|
|
case NS_STYLE_OVERFLOW_SCROLL:
|
|
|
|
case NS_STYLE_OVERFLOW_HIDDEN:
|
|
|
|
case NS_STYLE_OVERFLOW_VISIBLE:
|
|
|
|
case NS_STYLE_OVERFLOW_AUTO:
|
|
|
|
return ScrollbarStyles(overflow, overflow);
|
|
|
|
case NS_STYLE_OVERFLOW_SCROLLBARS_NONE:
|
2004-04-13 06:56:03 +04:00
|
|
|
// This isn't quite right. The scrollframe will still be scrollable using keys.
|
|
|
|
// This can happen when HTML or BODY has propagated this style to the viewport.
|
2003-05-22 05:46:13 +04:00
|
|
|
return ScrollbarStyles(NS_STYLE_OVERFLOW_HIDDEN, NS_STYLE_OVERFLOW_HIDDEN);
|
|
|
|
case NS_STYLE_OVERFLOW_SCROLLBARS_VERTICAL:
|
|
|
|
return ScrollbarStyles(NS_STYLE_OVERFLOW_HIDDEN, NS_STYLE_OVERFLOW_SCROLL);
|
|
|
|
case NS_STYLE_OVERFLOW_SCROLLBARS_HORIZONTAL:
|
|
|
|
return ScrollbarStyles(NS_STYLE_OVERFLOW_SCROLL, NS_STYLE_OVERFLOW_HIDDEN);
|
|
|
|
default:
|
|
|
|
NS_NOTREACHED("invalid overflow value");
|
|
|
|
return ScrollbarStyles(NS_STYLE_OVERFLOW_HIDDEN, NS_STYLE_OVERFLOW_HIDDEN);
|
|
|
|
}
|
|
|
|
}
|
1999-08-20 02:16:23 +04:00
|
|
|
|
1999-10-12 04:16:06 +04:00
|
|
|
NS_IMETHODIMP
|
2000-03-31 11:02:06 +04:00
|
|
|
nsGfxScrollFrame::GetPrefSize(nsBoxLayoutState& aState, nsSize& aSize)
|
1999-10-12 04:16:06 +04:00
|
|
|
{
|
2000-03-31 11:02:06 +04:00
|
|
|
PropagateDebug(aState);
|
1999-08-20 02:16:23 +04:00
|
|
|
|
2003-05-22 05:46:13 +04:00
|
|
|
ScrollbarStyles styles = GetScrollbarStyles();
|
1999-08-20 02:16:23 +04:00
|
|
|
|
2002-10-01 05:23:47 +04:00
|
|
|
nsSize vSize(0,0);
|
2003-04-22 05:33:14 +04:00
|
|
|
if (mInner->mVScrollbarBox &&
|
2003-05-22 05:46:13 +04:00
|
|
|
styles.mVertical == NS_STYLE_OVERFLOW_SCROLL) {
|
2000-03-31 11:02:06 +04:00
|
|
|
mInner->mVScrollbarBox->GetPrefSize(aState, vSize);
|
|
|
|
nsBox::AddMargin(mInner->mVScrollbarBox, vSize);
|
|
|
|
}
|
|
|
|
|
2002-10-01 05:23:47 +04:00
|
|
|
nsSize hSize(0,0);
|
2003-04-22 05:33:14 +04:00
|
|
|
if (mInner->mHScrollbarBox &&
|
2003-05-22 05:46:13 +04:00
|
|
|
styles.mHorizontal == NS_STYLE_OVERFLOW_SCROLL) {
|
2000-03-31 11:02:06 +04:00
|
|
|
mInner->mHScrollbarBox->GetPrefSize(aState, hSize);
|
|
|
|
nsBox::AddMargin(mInner->mHScrollbarBox, hSize);
|
2002-10-01 05:23:47 +04:00
|
|
|
}
|
1999-08-20 02:16:23 +04:00
|
|
|
|
2004-03-13 05:51:16 +03:00
|
|
|
// If one of the width and height is constrained,
|
2002-10-01 05:23:47 +04:00
|
|
|
// do smarter preferred size checking in case the scrolled frame is a block.
|
2004-03-13 05:51:16 +03:00
|
|
|
//
|
|
|
|
// Details: We're going to pass our width (or height) constraint
|
|
|
|
// down to nsBoxToBlockAdaptor. Then when we call
|
|
|
|
// mScrollAreaBox->GetPrefSize below, it will reflow the scrolled
|
|
|
|
// block with this width (or height) constraint, and report the resulting
|
|
|
|
// height (or width) of the block. So if possible we'll be sized exactly to the
|
|
|
|
// height (or width) of the block, which is what we want because 'overflow'
|
|
|
|
// should not affect sizing...
|
|
|
|
|
|
|
|
// Push current constraint. We'll restore it when we're done.
|
2002-10-01 05:23:47 +04:00
|
|
|
nsSize oldConstrainedSize;
|
|
|
|
aState.GetScrolledBlockSizeConstraint(oldConstrainedSize);
|
2004-03-13 05:51:16 +03:00
|
|
|
|
2002-10-02 02:53:43 +04:00
|
|
|
const nsHTMLReflowState* HTMLState = aState.GetReflowState();
|
2004-03-13 05:51:16 +03:00
|
|
|
// This stores the computed width and height, if available.
|
2002-10-02 02:53:43 +04:00
|
|
|
nsSize computedSize(NS_INTRINSICSIZE, NS_INTRINSICSIZE);
|
2004-03-13 05:51:16 +03:00
|
|
|
// This stores the maximum width and height we can be, if available.
|
|
|
|
// This is what we use to constrain the block reflow.
|
|
|
|
nsSize computedMax(NS_INTRINSICSIZE, NS_INTRINSICSIZE);
|
2002-10-02 02:53:43 +04:00
|
|
|
if (HTMLState != nsnull) {
|
2004-03-13 05:51:16 +03:00
|
|
|
computedSize = nsSize(HTMLState->mComputedWidth, HTMLState->mComputedHeight);
|
|
|
|
// If we know the computed size, then that's the effective maximum
|
|
|
|
computedMax = computedSize;
|
2004-03-27 05:44:26 +03:00
|
|
|
// One could imagine using other constraints in computedMax, but it doesn't
|
|
|
|
// really work. See bug 237622.
|
|
|
|
|
2004-03-13 05:51:16 +03:00
|
|
|
// Pass a constraint to the block if we have at least one constraint
|
|
|
|
// and our size is not fixed
|
|
|
|
if (((computedSize.width == NS_INTRINSICSIZE)
|
|
|
|
|| (computedSize.height == NS_INTRINSICSIZE))
|
|
|
|
&& (computedMax.width != NS_INTRINSICSIZE
|
|
|
|
|| computedMax.height != NS_INTRINSICSIZE)) {
|
2002-10-02 02:53:43 +04:00
|
|
|
// adjust constraints in case we have scrollbars
|
2004-03-13 05:51:16 +03:00
|
|
|
if (computedMax.width != NS_INTRINSICSIZE) {
|
|
|
|
computedMax.width = PR_MAX(0, computedMax.width - vSize.width);
|
2002-10-02 02:53:43 +04:00
|
|
|
}
|
2004-03-13 05:51:16 +03:00
|
|
|
if (computedMax.height != NS_INTRINSICSIZE) {
|
|
|
|
computedMax.height = PR_MAX(0, computedMax.height - hSize.height);
|
2002-10-02 02:53:43 +04:00
|
|
|
}
|
2004-03-13 05:51:16 +03:00
|
|
|
// For now, constrained height seems to just confuse things because
|
|
|
|
// various places in the block code assume constrained height => printing.
|
|
|
|
// Disable height constraint.
|
|
|
|
aState.SetScrolledBlockSizeConstraint(nsSize(computedMax.width, NS_INTRINSICSIZE));
|
2002-10-02 02:53:43 +04:00
|
|
|
} else {
|
|
|
|
aState.SetScrolledBlockSizeConstraint(nsSize(-1,-1));
|
2002-10-01 05:23:47 +04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
aState.SetScrolledBlockSizeConstraint(nsSize(-1,-1));
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
2002-10-02 02:53:43 +04:00
|
|
|
|
2002-10-01 05:23:47 +04:00
|
|
|
nsresult rv = mInner->mScrollAreaBox->GetPrefSize(aState, aSize);
|
2004-03-13 05:51:16 +03:00
|
|
|
|
|
|
|
// Restore old constraint.
|
2002-10-01 05:23:47 +04:00
|
|
|
aState.SetScrolledBlockSizeConstraint(oldConstrainedSize);
|
|
|
|
|
2004-03-13 05:51:16 +03:00
|
|
|
// If our height is not constrained, and we will need a horizontal
|
|
|
|
// scrollbar, then add space for the scrollbar to our desired height.
|
2003-05-22 05:46:13 +04:00
|
|
|
if (computedSize.height == NS_INTRINSICSIZE
|
2004-03-13 05:51:16 +03:00
|
|
|
&& computedMax.width != NS_INTRINSICSIZE
|
|
|
|
&& aSize.width > computedMax.width
|
2003-05-22 05:46:13 +04:00
|
|
|
&& mInner->mHScrollbarBox
|
|
|
|
&& styles.mHorizontal == NS_STYLE_OVERFLOW_AUTO) {
|
|
|
|
// Add height of horizontal scrollbar which will be needed
|
|
|
|
mInner->mHScrollbarBox->GetPrefSize(aState, hSize);
|
|
|
|
nsBox::AddMargin(mInner->mHScrollbarBox, hSize);
|
|
|
|
}
|
|
|
|
|
2004-03-13 05:51:16 +03:00
|
|
|
// If our width is not constrained, and we will need a vertical
|
|
|
|
// scrollbar, then add space for the scrollbar to our desired width.
|
2003-05-22 05:46:13 +04:00
|
|
|
if (computedSize.width == NS_INTRINSICSIZE
|
2004-03-13 05:51:16 +03:00
|
|
|
&& computedMax.height != NS_INTRINSICSIZE
|
|
|
|
&& aSize.height > computedMax.height
|
2003-05-22 05:46:13 +04:00
|
|
|
&& mInner->mVScrollbarBox
|
|
|
|
&& styles.mVertical == NS_STYLE_OVERFLOW_AUTO) {
|
|
|
|
// Add width of vertical scrollbar which will be needed
|
|
|
|
mInner->mVScrollbarBox->GetPrefSize(aState, vSize);
|
|
|
|
nsBox::AddMargin(mInner->mVScrollbarBox, vSize);
|
2002-10-01 05:23:47 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsBox::AddMargin(mInner->mScrollAreaBox, aSize);
|
|
|
|
|
|
|
|
aSize.width += vSize.width;
|
|
|
|
aSize.height += hSize.height;
|
1999-08-20 02:16:23 +04:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
AddBorderAndPadding(aSize);
|
|
|
|
AddInset(aSize);
|
|
|
|
nsIBox::AddCSSPrefSize(aState, this, aSize);
|
1999-08-20 02:16:23 +04:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
return rv;
|
|
|
|
}
|
1999-08-20 02:16:23 +04:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGfxScrollFrame::GetMinSize(nsBoxLayoutState& aState, nsSize& aSize)
|
|
|
|
{
|
|
|
|
PropagateDebug(aState);
|
1999-08-20 02:16:23 +04:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
nsresult rv = mInner->mScrollAreaBox->GetMinSize(aState, aSize);
|
2003-05-22 05:46:13 +04:00
|
|
|
|
|
|
|
ScrollbarStyles styles = GetScrollbarStyles();
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2003-04-22 05:33:14 +04:00
|
|
|
if (mInner->mVScrollbarBox &&
|
2003-05-22 05:46:13 +04:00
|
|
|
styles.mVertical == NS_STYLE_OVERFLOW_SCROLL) {
|
2000-03-31 11:02:06 +04:00
|
|
|
nsSize vSize(0,0);
|
|
|
|
mInner->mVScrollbarBox->GetMinSize(aState, vSize);
|
|
|
|
AddMargin(mInner->mVScrollbarBox, vSize);
|
|
|
|
aSize.width += vSize.width;
|
|
|
|
if (aSize.height < vSize.height)
|
|
|
|
aSize.height = vSize.height;
|
|
|
|
}
|
|
|
|
|
2003-04-22 05:33:14 +04:00
|
|
|
if (mInner->mHScrollbarBox &&
|
2003-05-22 05:46:13 +04:00
|
|
|
styles.mHorizontal == NS_STYLE_OVERFLOW_SCROLL) {
|
2000-03-31 11:02:06 +04:00
|
|
|
nsSize hSize(0,0);
|
|
|
|
mInner->mHScrollbarBox->GetMinSize(aState, hSize);
|
|
|
|
AddMargin(mInner->mHScrollbarBox, hSize);
|
|
|
|
aSize.height += hSize.height;
|
|
|
|
if (aSize.width < hSize.width)
|
|
|
|
aSize.width = hSize.width;
|
1999-10-12 04:16:06 +04:00
|
|
|
}
|
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
AddBorderAndPadding(aSize);
|
|
|
|
AddInset(aSize);
|
|
|
|
nsIBox::AddCSSMinSize(aState, this, aSize);
|
|
|
|
return rv;
|
1999-10-12 04:16:06 +04:00
|
|
|
}
|
|
|
|
|
1999-11-18 22:40:52 +03:00
|
|
|
NS_IMETHODIMP
|
2000-03-31 11:02:06 +04:00
|
|
|
nsGfxScrollFrame::GetMaxSize(nsBoxLayoutState& aState, nsSize& aSize)
|
1999-11-18 22:40:52 +03:00
|
|
|
{
|
2000-03-31 11:02:06 +04:00
|
|
|
PropagateDebug(aState);
|
|
|
|
|
|
|
|
aSize.width = NS_INTRINSICSIZE;
|
|
|
|
aSize.height = NS_INTRINSICSIZE;
|
1999-11-18 22:40:52 +03:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
AddBorderAndPadding(aSize);
|
|
|
|
AddInset(aSize);
|
|
|
|
nsIBox::AddCSSMaxSize(aState, this, aSize);
|
|
|
|
return NS_OK;
|
1999-11-18 22:40:52 +03:00
|
|
|
}
|
1999-10-12 04:16:06 +04:00
|
|
|
|
2000-04-05 04:19:00 +04:00
|
|
|
NS_IMETHODIMP
|
2001-10-29 04:43:59 +03:00
|
|
|
nsGfxScrollFrame::Reflow(nsIPresContext* aPresContext,
|
2000-04-05 04:19:00 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
2000-04-21 18:59:47 +04:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsGfxScrollFrame", aReflowState.reason);
|
2001-11-14 16:40:03 +03:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
|
2000-05-02 06:28:41 +04:00
|
|
|
|
|
|
|
// if there is a max element request then set it to -1 so we can see if it gets set
|
2003-01-09 17:26:32 +03:00
|
|
|
if (aDesiredSize.mComputeMEW)
|
2000-05-02 06:28:41 +04:00
|
|
|
{
|
2003-01-09 17:26:32 +03:00
|
|
|
aDesiredSize.mMaxElementWidth = -1;
|
2000-05-02 06:28:41 +04:00
|
|
|
}
|
|
|
|
|
2000-04-05 04:19:00 +04:00
|
|
|
nsresult rv = nsBoxFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
|
|
|
|
2000-05-02 06:28:41 +04:00
|
|
|
// if it was set then cache it. Otherwise set it.
|
2003-01-09 17:26:32 +03:00
|
|
|
if (aDesiredSize.mComputeMEW)
|
2000-04-05 04:19:00 +04:00
|
|
|
{
|
2000-05-02 06:28:41 +04:00
|
|
|
// if not set then use the cached size. If set then set it.
|
2003-01-09 17:26:32 +03:00
|
|
|
if (aDesiredSize.mMaxElementWidth == -1)
|
|
|
|
aDesiredSize.mMaxElementWidth = mInner->mMaxElementWidth;
|
2000-05-02 06:28:41 +04:00
|
|
|
else
|
2003-01-09 17:26:32 +03:00
|
|
|
mInner->mMaxElementWidth = aDesiredSize.mMaxElementWidth;
|
2000-05-02 06:28:41 +04:00
|
|
|
}
|
|
|
|
|
2002-05-29 02:50:43 +04:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
2000-04-05 04:19:00 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2003-12-10 06:43:39 +03:00
|
|
|
nsGfxScrollFrame*
|
|
|
|
nsGfxScrollFrame::GetScrollFrameForPort(nsIFrame* aPort) {
|
|
|
|
NS_ASSERTION(aPort, "no port");
|
|
|
|
nsIFrame* parent = aPort->GetParent();
|
|
|
|
if (!parent)
|
|
|
|
return nsnull;
|
|
|
|
nsIScrollableFrame* scFrame =
|
|
|
|
(nsCOMPtr<nsIScrollableFrame>(do_QueryInterface(parent)));
|
|
|
|
return NS_STATIC_CAST(nsGfxScrollFrame*, scFrame);
|
|
|
|
}
|
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
NS_IMETHODIMP_(nsrefcnt)
|
|
|
|
nsGfxScrollFrame::AddRef(void)
|
1999-10-12 04:16:06 +04:00
|
|
|
{
|
2000-03-31 11:02:06 +04:00
|
|
|
return NS_OK;
|
1999-10-12 04:16:06 +04:00
|
|
|
}
|
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
NS_IMETHODIMP_(nsrefcnt)
|
|
|
|
nsGfxScrollFrame::Release(void)
|
1999-10-12 04:16:06 +04:00
|
|
|
{
|
2000-03-31 11:02:06 +04:00
|
|
|
return NS_OK;
|
1999-10-12 04:16:06 +04:00
|
|
|
}
|
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef NS_DEBUG
|
1999-10-12 04:16:06 +04:00
|
|
|
NS_IMETHODIMP
|
2001-11-14 04:33:42 +03:00
|
|
|
nsGfxScrollFrame::GetFrameName(nsAString& aResult) const
|
1999-10-12 04:16:06 +04:00
|
|
|
{
|
2001-11-14 04:33:42 +03:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("GfxScroll"), aResult);
|
1999-10-12 04:16:06 +04:00
|
|
|
}
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|
1999-10-12 04:16:06 +04:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
NS_INTERFACE_MAP_BEGIN(nsGfxScrollFrame)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIAnonymousContentCreator)
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIFrameDebug)
|
|
|
|
#endif
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIScrollableFrame)
|
2003-04-09 00:50:57 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIScrollableViewProvider)
|
2000-03-31 11:02:06 +04:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(nsBoxFrame)
|
|
|
|
|
1999-10-12 04:16:06 +04:00
|
|
|
|
|
|
|
|
|
|
|
//-------------------- Inner ----------------------
|
|
|
|
|
2003-11-21 13:45:24 +03:00
|
|
|
nsGfxScrollFrameInner::nsGfxScrollFrameInner(nsGfxScrollFrame* aOuter)
|
|
|
|
: mHScrollbarBox(nsnull),
|
|
|
|
mVScrollbarBox(nsnull),
|
|
|
|
mScrollAreaBox(nsnull),
|
|
|
|
mScrollCornerBox(nsnull),
|
|
|
|
mOnePixel(20),
|
2004-01-06 02:56:00 +03:00
|
|
|
mOuter(aOuter),
|
|
|
|
mMaxElementWidth(0),
|
|
|
|
mLastDir(-1),
|
|
|
|
mNeverHasVerticalScrollbar(PR_FALSE),
|
|
|
|
mNeverHasHorizontalScrollbar(PR_FALSE),
|
2003-11-21 13:45:24 +03:00
|
|
|
mHasVerticalScrollbar(PR_FALSE),
|
2004-01-06 02:56:00 +03:00
|
|
|
mHasHorizontalScrollbar(PR_FALSE),
|
|
|
|
mFirstPass(PR_FALSE)
|
1999-10-12 04:16:06 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
1999-10-15 08:29:30 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGfxScrollFrameInner::ScrollPositionWillChange(nsIScrollableView* aScrollable, nscoord aX, nscoord aY)
|
|
|
|
{
|
|
|
|
// Do nothing.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2003-04-05 15:41:19 +04:00
|
|
|
/**
|
|
|
|
* Called when someone (external or this frame) moves the scroll area.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
nsGfxScrollFrameInner::InternalScrollPositionDidChange(nscoord aX, nscoord aY)
|
|
|
|
{
|
|
|
|
if (mVScrollbarBox)
|
|
|
|
SetAttribute(mVScrollbarBox, nsXULAtoms::curpos, aY);
|
|
|
|
|
|
|
|
if (mHScrollbarBox)
|
|
|
|
SetAttribute(mHScrollbarBox, nsXULAtoms::curpos, aX);
|
|
|
|
}
|
|
|
|
|
1999-10-12 04:16:06 +04:00
|
|
|
/**
|
|
|
|
* Called if something externally moves the scroll area
|
|
|
|
* This can happen if the user pages up down or uses arrow keys
|
|
|
|
* So what we need to do up adjust the scrollbars to match.
|
|
|
|
*/
|
|
|
|
NS_IMETHODIMP
|
1999-10-15 08:29:30 +04:00
|
|
|
nsGfxScrollFrameInner::ScrollPositionDidChange(nsIScrollableView* aScrollable, nscoord aX, nscoord aY)
|
1999-10-12 04:16:06 +04:00
|
|
|
{
|
2003-04-05 15:41:19 +04:00
|
|
|
NS_ASSERTION(!mViewInitiatedScroll, "Cannot reenter ScrollPositionDidChange");
|
|
|
|
|
|
|
|
mViewInitiatedScroll = PR_TRUE;
|
|
|
|
|
|
|
|
InternalScrollPositionDidChange(aX, aY);
|
|
|
|
|
|
|
|
mViewInitiatedScroll = PR_FALSE;
|
|
|
|
|
|
|
|
return NS_OK;
|
1999-10-12 04:16:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2003-04-09 15:27:09 +04:00
|
|
|
nsGfxScrollFrame::CurPosAttributeChanged(nsIPresContext* aPresContext,
|
|
|
|
nsIContent* aChild,
|
|
|
|
PRInt32 aModType)
|
|
|
|
{
|
|
|
|
return mInner->CurPosAttributeChanged(aPresContext, aChild, aModType);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsGfxScrollFrameInner::CurPosAttributeChanged(nsIPresContext* aPresContext,
|
|
|
|
nsIContent* aContent,
|
|
|
|
PRInt32 aModType)
|
1999-10-12 04:16:06 +04:00
|
|
|
{
|
2003-05-22 05:46:13 +04:00
|
|
|
NS_ASSERTION(aContent, "aContent must not be null");
|
|
|
|
|
2003-04-05 15:41:19 +04:00
|
|
|
// Attribute changes on the scrollbars happen in one of three ways:
|
|
|
|
// 1) The scrollbar changed the attribute in response to some user event
|
|
|
|
// 2) We changed the attribute in response to a ScrollPositionDidChange
|
|
|
|
// callback from the scrolling view
|
|
|
|
// 3) We changed the attribute to adjust the scrollbars for the start
|
|
|
|
// of a smooth scroll operation
|
|
|
|
//
|
|
|
|
// In case 2), we don't need to scroll the view because the scrolling
|
|
|
|
// has already happened. In case 3) we don't need to scroll because
|
|
|
|
// we're just adjusting the scrollbars back to the correct setting
|
|
|
|
// for the view.
|
|
|
|
//
|
|
|
|
// We used to detect this case implicitly because we'd compare the
|
|
|
|
// scrollbar attributes with the view's current scroll position and
|
|
|
|
// bail out if they were equal. But that approach is fragile; it can
|
|
|
|
// fail when, for example, the view scrolls horizontally and
|
|
|
|
// vertically simultaneously; we'll get here when only the vertical
|
|
|
|
// attribute has been set, so the attributes and the view scroll
|
|
|
|
// position don't yet agree, and we'd tell the view to scroll to the
|
|
|
|
// new vertical position and the old horizontal position! Even worse
|
|
|
|
// things could happen when smooth scrolling got involved ... crashes
|
|
|
|
// and other terrors.
|
|
|
|
if (mViewInitiatedScroll || mFrameInitiatedScroll) return NS_OK;
|
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
nsIFrame* hframe = nsnull;
|
2003-05-22 05:46:13 +04:00
|
|
|
if (mHScrollbarBox)
|
|
|
|
mHScrollbarBox->GetFrame(&hframe);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
|
|
|
nsIFrame* vframe = nsnull;
|
2003-05-22 05:46:13 +04:00
|
|
|
if (mVScrollbarBox)
|
|
|
|
mVScrollbarBox->GetFrame(&vframe);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2003-06-29 07:43:05 +04:00
|
|
|
nsIContent* vcontent = vframe ? vframe->GetContent() : nsnull;
|
|
|
|
nsIContent* hcontent = hframe ? hframe->GetContent() : nsnull;
|
1999-10-12 04:16:06 +04:00
|
|
|
|
2003-06-29 07:43:05 +04:00
|
|
|
if (hcontent == aContent || vcontent == aContent)
|
1999-10-12 04:16:06 +04:00
|
|
|
{
|
|
|
|
nscoord x = 0;
|
|
|
|
nscoord y = 0;
|
|
|
|
|
Landing changes Vidur made while the tree was closed for beta1 work, here's a list of the changes. r=me
[1] Cutting down the size of content. Made nsIJSScriptObject inherit from nsIScriptObjectOwner
[2] Cutting down the size of content. Made nsITextContent inherit from nsIContent.
[3] Cutting down the size of content. Moved implementation of nsIDOMReceiver to nsListenerManager. This is not true aggregation since it isn't transitive, but it's OK for now. It will be necessary for nsListenerManager to have a reference to its content in the future anyway, so the transitivity could be done.
dom/public/nsDOMPropEnums.h,v - bug 12559
dom/public/nsIJSScriptObject.h,v - [1]
dom/public/html/MANIFEST,v - bug 12559
dom/public/html/Makefile.in,v - bug 12559
dom/public/html/makefile.win,v - bug 12559
dom/public/html/nsIDOMHTMLInputElement.h,v - bug 17544
dom/public/idl/html/HTMLAnchorElement.idl,v - bug 12559
dom/public/idl/html/HTMLAreaElement.idl,v - bug 12559
dom/public/idl/html/HTMLInputElement.idl,v - bug 17544
dom/src/base/nsGlobalWindow.cpp,v - bug 30700
dom/src/base/nsGlobalWindow.h,v - [1]
dom/src/base/nsLocation.cpp,v - [1]
dom/src/html/nsJSHTMLAnchorElement.cpp,v - bug 12559
dom/src/html/nsJSHTMLAreaElement.cpp,v - bug 12559
dom/src/html/nsJSHTMLInputElement.cpp,v - bug 17544
layout/base/public/nsIDocument.h,v - bug 27953
layout/base/public/nsITextContent.h,v - [2]
layout/base/src/nsCommentNode.cpp,v - [2]
layout/base/src/nsDocument.cpp,v - bug 27953
layout/base/src/nsDocument.h,v - bug 27953
layout/base/src/nsDocumentViewer.cpp,v - bug 27953
layout/base/src/nsGenericDOMDataNode.cpp,v - [3]
layout/base/src/nsGenericDOMDataNode.h,v - [3]
layout/base/src/nsGenericElement.cpp,v - [3]
layout/base/src/nsGenericElement.h,v - [3]
layout/base/src/nsNameSpaceManager.cpp,v - bug 7834
layout/base/src/nsStyleContext.cpp,v - outline property shouldn't reflow
layout/base/src/nsTextNode.cpp,v - [2]
layout/events/src/nsEventListenerManager.cpp,v - [3]
layout/events/src/nsEventListenerManager.h,v - [3]
layout/html/base/src/nsGfxScrollFrame.cpp,v - nsString->nsAutoString
layout/html/content/src/nsAttributeContent.cpp,v - [2]
layout/html/content/src/nsHTMLAnchorElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLAppletElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLAreaElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBRElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBaseElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBaseFontElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBodyElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLButtonElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDListElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDelElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDirectoryElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDivElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLEmbedElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFieldSetElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFontElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFormElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFrameElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFrameSetElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHRElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHeadElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHeadingElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHtmlElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLIFrameElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLImageElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLInputElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLInsElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLIsIndexElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLIElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLabelElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLayerElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLegendElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLinkElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLMapElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLMenuElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLMetaElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLModElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLOListElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLObjectElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLOptGroupElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLOptionElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLParagraphElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLParamElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLPreElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLQuoteElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLScriptElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLSelectElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLSpacerElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLSpanElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLStyleElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableCaptionElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableCellElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableColElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableColGroupElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableRowElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableSectionElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTextAreaElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTitleElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLUListElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLWBRElement.cpp,v - [1][3]
layout/html/document/src/nsHTMLDocument.cpp,v - bug 27953
layout/html/document/src/nsHTMLDocument.h,v - bug 27953
layout/xml/content/src/nsXMLCDATASection.cpp,v - [1][2]
layout/xml/content/src/nsXMLDocumentType.cpp,v - [1][2]
layout/xml/content/src/nsXMLElement.h,v - [1][2]
layout/xml/content/src/nsXMLEntity.cpp,v - [1][2]
layout/xml/content/src/nsXMLNotation.cpp,v - [1][2]
layout/xml/content/src/nsXMLProcessingInstruction.cpp,v - [1][2]
layout/xul/base/src/nsBoxFrame.cpp,v - nsString->nsAutoString
layout/xul/base/src/nsSliderFrame.cpp,v - nsString->nsAutoString
netwerk/protocol/http/src/nsHTTPRequest.cpp,v - nsString->nsAutoString
rdf/content/src/nsXULDocument.cpp,v - bug 27953
rdf/content/src/nsXULDocument.h,v - bug 27953
rdf/content/src/nsXULElement.h,v - [1]
xpcom/base/IIDS.h,v - bug 12559
2000-03-17 16:27:00 +03:00
|
|
|
nsAutoString value;
|
2003-05-22 05:46:13 +04:00
|
|
|
if (hcontent && NS_CONTENT_ATTR_HAS_VALUE == hcontent->GetAttr(kNameSpaceID_None, nsXULAtoms::curpos, value))
|
1999-10-12 04:16:06 +04:00
|
|
|
{
|
|
|
|
PRInt32 error;
|
|
|
|
|
|
|
|
// convert it to an integer
|
|
|
|
x = value.ToInteger(&error);
|
|
|
|
}
|
|
|
|
|
2003-05-22 05:46:13 +04:00
|
|
|
if (vcontent && NS_CONTENT_ATTR_HAS_VALUE == vcontent->GetAttr(kNameSpaceID_None, nsXULAtoms::curpos, value))
|
1999-10-12 04:16:06 +04:00
|
|
|
{
|
|
|
|
PRInt32 error;
|
|
|
|
|
|
|
|
// convert it to an integer
|
|
|
|
y = value.ToInteger(&error);
|
|
|
|
}
|
|
|
|
|
2002-09-26 01:29:33 +04:00
|
|
|
// Make sure the scrollbars indeed moved before firing the event.
|
|
|
|
// I think it is OK to prevent the call to ScrollbarChanged()
|
|
|
|
// if we didn't actually move. The following check is the first
|
|
|
|
// thing ScrollbarChanged() does anyway, before deciding to move
|
|
|
|
// the scrollbars.
|
|
|
|
nscoord curPosX=0, curPosY=0;
|
2000-04-25 11:10:48 +04:00
|
|
|
nsIScrollableView* s = GetScrollableView(mOuter->mPresContext);
|
2002-09-26 01:29:33 +04:00
|
|
|
if (s) {
|
|
|
|
s->GetScrollPosition(curPosX, curPosY);
|
|
|
|
if ((x*mOnePixel) == curPosX && (y*mOnePixel) == curPosY)
|
|
|
|
return NS_OK;
|
2003-05-22 05:46:13 +04:00
|
|
|
|
|
|
|
PRBool isSmooth = aContent->HasAttr(kNameSpaceID_None, nsXULAtoms::smooth);
|
2002-09-26 01:29:33 +04:00
|
|
|
|
2003-03-24 08:29:45 +03:00
|
|
|
if (isSmooth) {
|
|
|
|
// Make sure an attribute-setting callback occurs even if the view didn't actually move yet
|
|
|
|
// We need to make sure other listeners see that the scroll position is not (yet)
|
|
|
|
// what they thought it was.
|
|
|
|
s->GetScrollPosition(curPosX, curPosY);
|
2003-04-05 15:41:19 +04:00
|
|
|
|
|
|
|
NS_ASSERTION(!mFrameInitiatedScroll, "Unexpected reentry");
|
|
|
|
// Make sure we don't do anything in when the view calls us back for this
|
|
|
|
// scroll operation.
|
|
|
|
mFrameInitiatedScroll = PR_TRUE;
|
|
|
|
InternalScrollPositionDidChange(curPosX, curPosY);
|
|
|
|
mFrameInitiatedScroll = PR_FALSE;
|
2003-03-24 08:29:45 +03:00
|
|
|
}
|
2003-04-05 15:41:19 +04:00
|
|
|
ScrollbarChanged(mOuter->mPresContext, x*mOnePixel, y*mOnePixel, isSmooth ? NS_VMREFRESH_SMOOTHSCROLL : 0);
|
2003-03-24 08:29:45 +03:00
|
|
|
|
2002-11-14 23:00:13 +03:00
|
|
|
// Fire the onScroll event now that we have scrolled
|
2003-12-21 08:36:36 +03:00
|
|
|
nsIPresShell *presShell = mOuter->mPresContext->GetPresShell();
|
2003-05-22 05:46:13 +04:00
|
|
|
if (presShell) {
|
2004-01-12 11:25:18 +03:00
|
|
|
nsScrollbarEvent event(NS_SCROLL_EVENT);
|
2002-11-14 23:00:13 +03:00
|
|
|
nsEventStatus status = nsEventStatus_eIgnore;
|
2003-05-22 05:46:13 +04:00
|
|
|
// note if hcontent is non-null then hframe must be non-null.
|
|
|
|
// likewise for vcontent and vframe. Thus targetFrame will always
|
|
|
|
// be non-null in here.
|
|
|
|
nsIFrame* targetFrame =
|
2003-06-29 07:43:05 +04:00
|
|
|
hcontent == aContent ? hframe : vframe;
|
2002-11-14 23:00:13 +03:00
|
|
|
presShell->HandleEventWithTarget(&event, targetFrame,
|
2003-05-22 05:46:13 +04:00
|
|
|
aContent,
|
2002-11-14 23:00:13 +03:00
|
|
|
NS_EVENT_FLAG_INIT, &status);
|
|
|
|
}
|
2002-09-26 01:29:33 +04:00
|
|
|
}
|
1999-10-12 04:16:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIScrollableView*
|
1999-10-26 08:44:41 +04:00
|
|
|
nsGfxScrollFrameInner::GetScrollableView(nsIPresContext* aPresContext)
|
1999-10-12 04:16:06 +04:00
|
|
|
{
|
2000-03-31 11:02:06 +04:00
|
|
|
nsIFrame* frame = nsnull;
|
|
|
|
mScrollAreaBox->GetFrame(&frame);
|
2003-06-29 07:43:05 +04:00
|
|
|
nsIView* view = frame->GetView();
|
2003-04-09 00:50:57 +04:00
|
|
|
if (!view) return nsnull;
|
|
|
|
|
|
|
|
nsIScrollableView* scrollingView;
|
2003-09-27 08:18:26 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
nsresult result =
|
|
|
|
#endif
|
|
|
|
CallQueryInterface(view, &scrollingView);
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),
|
|
|
|
"assertion gfx scrollframe does not contain a scrollframe");
|
1999-10-12 04:16:06 +04:00
|
|
|
return scrollingView;
|
|
|
|
}
|
|
|
|
|
2000-05-15 08:12:31 +04:00
|
|
|
PRBool
|
|
|
|
nsGfxScrollFrameInner::AddHorizontalScrollbar(nsBoxLayoutState& aState, nsRect& aScrollAreaSize, PRBool aOnTop)
|
1999-08-20 02:16:23 +04:00
|
|
|
{
|
2001-12-18 01:51:39 +03:00
|
|
|
if (!mHScrollbarBox)
|
|
|
|
return PR_TRUE;
|
|
|
|
|
2001-04-12 03:04:11 +04:00
|
|
|
#ifdef IBMBIDI
|
2003-05-15 07:42:21 +04:00
|
|
|
const nsStyleVisibility* vis = mOuter->GetStyleVisibility();
|
2001-12-18 01:51:39 +03:00
|
|
|
|
2004-01-06 02:56:00 +03:00
|
|
|
// Scroll the view horizontally if:
|
|
|
|
// 1) We are creating the scrollbar for the first time and the
|
|
|
|
// horizontal scroll position of the view is 0 or
|
|
|
|
// 2) The display direction is changed
|
|
|
|
PRBool needScroll;
|
|
|
|
if (mLastDir == -1) {
|
|
|
|
// Creating the scrollbar the first time
|
|
|
|
nscoord curPosX = 0, curPosY = 0;
|
|
|
|
nsIScrollableView* s = GetScrollableView(mOuter->mPresContext);
|
|
|
|
if (s) {
|
|
|
|
s->GetScrollPosition(curPosX, curPosY);
|
|
|
|
}
|
|
|
|
needScroll = (curPosX == 0);
|
|
|
|
} else {
|
|
|
|
needScroll = (mLastDir != vis->mDirection);
|
|
|
|
}
|
|
|
|
if (needScroll) {
|
2001-12-18 01:51:39 +03:00
|
|
|
SetAttribute(mHScrollbarBox, nsXULAtoms::curpos,
|
|
|
|
(NS_STYLE_DIRECTION_LTR == vis->mDirection) ? 0 : 0x7FFFFFFF);
|
2001-04-12 03:04:11 +04:00
|
|
|
}
|
2004-01-06 02:56:00 +03:00
|
|
|
mLastDir = vis->mDirection;
|
2001-04-12 03:04:11 +04:00
|
|
|
#endif // IBMBIDI
|
2001-12-18 01:51:39 +03:00
|
|
|
|
|
|
|
return AddRemoveScrollbar(aState, aScrollAreaSize, aOnTop, PR_TRUE, PR_TRUE);
|
2000-05-15 08:12:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsGfxScrollFrameInner::AddVerticalScrollbar(nsBoxLayoutState& aState, nsRect& aScrollAreaSize, PRBool aOnRight)
|
|
|
|
{
|
2001-12-18 01:51:39 +03:00
|
|
|
if (!mVScrollbarBox)
|
|
|
|
return PR_TRUE;
|
|
|
|
|
|
|
|
return AddRemoveScrollbar(aState, aScrollAreaSize, aOnRight, PR_FALSE, PR_TRUE);
|
2000-05-15 08:12:31 +04:00
|
|
|
}
|
|
|
|
|
2004-03-11 02:52:01 +03:00
|
|
|
void
|
2000-05-15 08:12:31 +04:00
|
|
|
nsGfxScrollFrameInner::RemoveHorizontalScrollbar(nsBoxLayoutState& aState, nsRect& aScrollAreaSize, PRBool aOnTop)
|
|
|
|
{
|
2004-03-11 02:52:01 +03:00
|
|
|
// removing a scrollbar should always fit
|
|
|
|
#ifdef DEBUG
|
|
|
|
PRBool result =
|
|
|
|
#endif
|
|
|
|
AddRemoveScrollbar(aState, aScrollAreaSize, aOnTop, PR_TRUE, PR_FALSE);
|
|
|
|
NS_ASSERTION(result, "Removing horizontal scrollbar failed to fit??");
|
2000-05-15 08:12:31 +04:00
|
|
|
}
|
|
|
|
|
2004-03-11 02:52:01 +03:00
|
|
|
void
|
2000-05-15 08:12:31 +04:00
|
|
|
nsGfxScrollFrameInner::RemoveVerticalScrollbar(nsBoxLayoutState& aState, nsRect& aScrollAreaSize, PRBool aOnRight)
|
|
|
|
{
|
2004-03-11 02:52:01 +03:00
|
|
|
// removing a scrollbar should always fit
|
|
|
|
#ifdef DEBUG
|
|
|
|
PRBool result =
|
|
|
|
#endif
|
|
|
|
AddRemoveScrollbar(aState, aScrollAreaSize, aOnRight, PR_FALSE, PR_FALSE);
|
|
|
|
NS_ASSERTION(result, "Removing vertical scrollbar failed to fit??");
|
2000-05-15 08:12:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsGfxScrollFrameInner::AddRemoveScrollbar(nsBoxLayoutState& aState, nsRect& aScrollAreaSize, PRBool aOnTop, PRBool aHorizontal, PRBool aAdd)
|
|
|
|
{
|
|
|
|
if (aHorizontal) {
|
2002-10-24 07:11:53 +04:00
|
|
|
if (mNeverHasHorizontalScrollbar || !mHScrollbarBox)
|
2000-05-15 08:12:31 +04:00
|
|
|
return PR_FALSE;
|
|
|
|
|
|
|
|
nsSize hSize;
|
|
|
|
mHScrollbarBox->GetPrefSize(aState, hSize);
|
|
|
|
nsBox::AddMargin(mHScrollbarBox, hSize);
|
|
|
|
|
2004-01-09 22:21:20 +03:00
|
|
|
SetScrollbarVisibility(mHScrollbarBox, aAdd);
|
2000-05-15 08:12:31 +04:00
|
|
|
|
2001-12-15 02:13:08 +03:00
|
|
|
PRBool hasHorizontalScrollbar;
|
|
|
|
PRBool fit = AddRemoveScrollbar(hasHorizontalScrollbar, aScrollAreaSize.y, aScrollAreaSize.height, hSize.height, aOnTop, aAdd);
|
|
|
|
mHasHorizontalScrollbar = hasHorizontalScrollbar; // because mHasHorizontalScrollbar is a PRPackedBool
|
2000-05-15 08:12:31 +04:00
|
|
|
if (!fit)
|
|
|
|
SetScrollbarVisibility(mHScrollbarBox, !aAdd);
|
|
|
|
|
|
|
|
return fit;
|
|
|
|
} else {
|
2002-10-24 07:11:53 +04:00
|
|
|
if (mNeverHasVerticalScrollbar || !mVScrollbarBox)
|
2000-05-15 08:12:31 +04:00
|
|
|
return PR_FALSE;
|
|
|
|
|
|
|
|
nsSize vSize;
|
|
|
|
mVScrollbarBox->GetPrefSize(aState, vSize);
|
2004-01-09 22:21:20 +03:00
|
|
|
nsBox::AddMargin(mVScrollbarBox, vSize);
|
2000-05-15 08:12:31 +04:00
|
|
|
|
2004-01-09 22:21:20 +03:00
|
|
|
SetScrollbarVisibility(mVScrollbarBox, aAdd);
|
2000-05-15 08:12:31 +04:00
|
|
|
|
2001-12-15 02:13:08 +03:00
|
|
|
PRBool hasVerticalScrollbar;
|
|
|
|
PRBool fit = AddRemoveScrollbar(hasVerticalScrollbar, aScrollAreaSize.x, aScrollAreaSize.width, vSize.width, aOnTop, aAdd);
|
|
|
|
mHasVerticalScrollbar = hasVerticalScrollbar; // because mHasVerticalScrollbar is a PRPackedBool
|
2000-05-15 08:12:31 +04:00
|
|
|
if (!fit)
|
|
|
|
SetScrollbarVisibility(mVScrollbarBox, !aAdd);
|
|
|
|
|
|
|
|
return fit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsGfxScrollFrameInner::AddRemoveScrollbar(PRBool& aHasScrollbar, nscoord& aXY, nscoord& aSize, nscoord aSbSize, PRBool aRightOrBottom, PRBool aAdd)
|
|
|
|
{
|
1999-10-12 04:16:06 +04:00
|
|
|
nscoord size = aSize;
|
|
|
|
|
|
|
|
if (size != NS_INTRINSICSIZE) {
|
2000-04-03 10:26:38 +04:00
|
|
|
if (aAdd) {
|
1999-10-12 04:16:06 +04:00
|
|
|
size -= aSbSize;
|
2000-05-15 08:12:31 +04:00
|
|
|
if (!aRightOrBottom && size >= 0)
|
2000-04-03 10:26:38 +04:00
|
|
|
aXY += aSbSize;
|
|
|
|
} else {
|
1999-10-12 04:16:06 +04:00
|
|
|
size += aSbSize;
|
2000-04-03 10:26:38 +04:00
|
|
|
if (!aRightOrBottom)
|
|
|
|
aXY -= aSbSize;
|
|
|
|
}
|
1999-10-12 04:16:06 +04:00
|
|
|
}
|
|
|
|
|
2000-05-15 08:12:31 +04:00
|
|
|
// not enough room? Yes? Return true.
|
1999-10-12 04:16:06 +04:00
|
|
|
if (size >= aSbSize) {
|
|
|
|
aHasScrollbar = aAdd;
|
|
|
|
aSize = size;
|
2000-05-15 08:12:31 +04:00
|
|
|
return PR_TRUE;
|
1999-08-20 02:16:23 +04:00
|
|
|
}
|
|
|
|
|
2002-08-21 12:56:58 +04:00
|
|
|
aHasScrollbar = PR_FALSE;
|
2000-05-15 08:12:31 +04:00
|
|
|
return PR_FALSE;
|
1999-08-20 02:16:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2000-03-31 11:02:06 +04:00
|
|
|
nsGfxScrollFrameInner::LayoutBox(nsBoxLayoutState& aState, nsIBox* aBox, const nsRect& aRect)
|
1999-08-20 02:16:23 +04:00
|
|
|
{
|
2000-03-31 11:02:06 +04:00
|
|
|
return mOuter->LayoutChildAt(aState, aBox, aRect);
|
|
|
|
}
|
1999-08-20 02:16:23 +04:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
NS_IMETHODIMP
|
2000-07-08 02:24:06 +04:00
|
|
|
nsGfxScrollFrame::DoLayout(nsBoxLayoutState& aState)
|
2000-03-31 11:02:06 +04:00
|
|
|
{
|
2000-04-25 11:10:48 +04:00
|
|
|
PRUint32 flags = 0;
|
|
|
|
aState.GetLayoutFlags(flags);
|
2000-03-31 11:02:06 +04:00
|
|
|
nsresult rv = mInner->Layout(aState);
|
2000-04-25 11:10:48 +04:00
|
|
|
aState.SetLayoutFlags(flags);
|
|
|
|
|
2000-07-08 02:24:06 +04:00
|
|
|
nsBox::DoLayout(aState);
|
2000-03-31 11:02:06 +04:00
|
|
|
return rv;
|
1999-08-20 02:16:23 +04:00
|
|
|
}
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2002-01-23 05:53:02 +03:00
|
|
|
/**
|
|
|
|
* When reflowing a HTML document where the content model is being created
|
|
|
|
* The nsGfxScrollFrame will get an Initial reflow when the body is opened by the content sink.
|
|
|
|
* But there isn't enough content to really reflow very much of the document
|
|
|
|
* so it never needs to do layout for the scrollbars
|
|
|
|
*
|
|
|
|
* So later other reflows happen and these are Incremental reflows, and then the scrollbars
|
|
|
|
* get reflowed. The important point here is that when they reflowed the ReflowState inside the
|
|
|
|
* BoxLayoutState contains an "Incremental" reason and never a "Initial" reason.
|
|
|
|
*
|
|
|
|
* When it reflows for Print Preview, the content model is already full constructed and it lays
|
|
|
|
* out the entire document at that time. When it returns back here it discovers it needs scrollbars
|
|
|
|
* and this is a problem because the ReflowState inside the BoxLayoutState still has a "Initial"
|
|
|
|
* reason and if it does a Layout it is essentially asking everything to reflow yet again with
|
|
|
|
* an "Initial" reason. This causes a lot of problems especially for tables.
|
|
|
|
*
|
|
|
|
* The solution for this is to change the ReflowState's reason from Initial to Resize and let
|
|
|
|
* all the frames do what is necessary for a resize refow. Now, we only need to do this when
|
|
|
|
* it is doing PrintPreview and we need only do it for HTML documents and NOT chrome.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
nsGfxScrollFrameInner::AdjustReflowStateForPrintPreview(nsBoxLayoutState& aState, PRBool& aSetBack)
|
|
|
|
{
|
|
|
|
aSetBack = PR_FALSE;
|
|
|
|
PRBool isChrome;
|
|
|
|
PRBool isInitialPP = nsBoxFrame::IsInitialReflowForPrintPreview(aState, isChrome);
|
|
|
|
if (isInitialPP && !isChrome) {
|
|
|
|
// I know you shouldn't, but we cast away the "const" here
|
|
|
|
nsHTMLReflowState* reflowState = (nsHTMLReflowState*)aState.GetReflowState();
|
|
|
|
reflowState->reason = eReflowReason_Resize;
|
|
|
|
aSetBack = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets reflow state back to Initial when we are done.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
nsGfxScrollFrameInner::AdjustReflowStateBack(nsBoxLayoutState& aState, PRBool aSetBack)
|
|
|
|
{
|
|
|
|
// I know you shouldn't, but we cast away the "const" here
|
|
|
|
nsHTMLReflowState* reflowState = (nsHTMLReflowState*)aState.GetReflowState();
|
|
|
|
if (aSetBack && reflowState->reason == eReflowReason_Resize) {
|
|
|
|
reflowState->reason = eReflowReason_Initial;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-08-20 02:16:23 +04:00
|
|
|
/**
|
|
|
|
* Reflow the scroll area if it needs it and return its size. Also determine if the reflow will
|
|
|
|
* cause any of the scrollbars to need to be reflowed.
|
|
|
|
*/
|
2000-03-31 11:02:06 +04:00
|
|
|
nsresult
|
|
|
|
nsGfxScrollFrameInner::Layout(nsBoxLayoutState& aState)
|
1999-08-20 02:16:23 +04:00
|
|
|
{
|
2000-04-03 10:26:38 +04:00
|
|
|
//TODO make bidi code set these from preferences
|
|
|
|
|
|
|
|
// if true places the vertical scrollbar on the right false puts it on the left.
|
|
|
|
PRBool scrollBarRight = PR_TRUE;
|
|
|
|
|
|
|
|
// if true places the horizontal scrollbar on the bottom false puts it on the top.
|
|
|
|
PRBool scrollBarBottom = PR_TRUE;
|
|
|
|
|
2001-04-12 03:04:11 +04:00
|
|
|
#ifdef IBMBIDI
|
2003-05-15 07:42:21 +04:00
|
|
|
const nsStyleVisibility* vis = mOuter->GetStyleVisibility();
|
2001-06-01 02:19:43 +04:00
|
|
|
|
2001-04-12 03:04:11 +04:00
|
|
|
//
|
|
|
|
// Direction Style from this->GetStyleData()
|
2001-06-01 02:19:43 +04:00
|
|
|
// now in (vis->mDirection)
|
2001-04-12 03:04:11 +04:00
|
|
|
// ------------------
|
|
|
|
// NS_STYLE_DIRECTION_LTR : LTR or Default
|
|
|
|
// NS_STYLE_DIRECTION_RTL
|
|
|
|
// NS_STYLE_DIRECTION_INHERIT
|
|
|
|
//
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (vis->mDirection == NS_STYLE_DIRECTION_RTL){
|
2001-04-12 03:04:11 +04:00
|
|
|
// if true places the vertical scrollbar on the right false puts it on the left.
|
|
|
|
scrollBarRight = PR_FALSE;
|
|
|
|
|
|
|
|
// if true places the horizontal scrollbar on the bottom false puts it on the top.
|
|
|
|
scrollBarBottom = PR_TRUE;
|
|
|
|
}
|
|
|
|
nsHTMLReflowState* reflowState = (nsHTMLReflowState*)aState.GetReflowState();
|
|
|
|
#endif // IBMBIDI
|
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
nsIFrame* frame = nsnull;
|
|
|
|
mOuter->GetFrame(&frame);
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
// get the content rect
|
|
|
|
nsRect clientRect(0,0,0,0);
|
|
|
|
mOuter->GetClientRect(clientRect);
|
|
|
|
|
|
|
|
// the scroll area size starts off as big as our content area
|
|
|
|
nsRect scrollAreaRect(clientRect);
|
|
|
|
|
2004-03-11 02:52:01 +03:00
|
|
|
/**************
|
|
|
|
Our basic strategy here is to first try laying out the content with
|
|
|
|
the scrollbars in their current state. We're hoping that that will
|
|
|
|
just "work"; the content will overflow wherever there's a scrollbar
|
|
|
|
already visible. If that does work, then there's no need to lay out
|
|
|
|
the scrollarea. Otherwise we fix up the scrollbars; first we add a
|
|
|
|
vertical one to scroll the content if necessary, or remove it if
|
|
|
|
it's not needed. Then we reflow the content if the scrollbar
|
|
|
|
changed. Then we add a horizontal scrollbar if necessary (or
|
|
|
|
remove if not needed), and if that changed, we reflow the content
|
|
|
|
again. At this point, any scrollbars that are needed to scroll the
|
|
|
|
content have been added.
|
|
|
|
|
|
|
|
In the second phase we check to see if any scrollbars are too small
|
|
|
|
to display, and if so, we remove them. We check the horizontal
|
|
|
|
scrollbar first; removing it might make room for the vertical
|
|
|
|
scrollbar, and if we have room for just one scrollbar we'll save
|
|
|
|
the vertical one.
|
|
|
|
|
|
|
|
Finally we position and size the scrollbars and scrollcorner (the
|
|
|
|
square that is needed in the corner of the window when two
|
|
|
|
scrollbars are visible), and reflow any fixed position views
|
|
|
|
(if we're the viewport and we added or removed a scrollbar).
|
|
|
|
**************/
|
|
|
|
|
2003-05-22 05:46:13 +04:00
|
|
|
nsGfxScrollFrame::ScrollbarStyles styles = mOuter->GetScrollbarStyles();
|
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
// Look at our style do we always have vertical or horizontal scrollbars?
|
2003-05-22 05:46:13 +04:00
|
|
|
if (styles.mHorizontal == NS_STYLE_OVERFLOW_SCROLL)
|
2000-03-31 11:02:06 +04:00
|
|
|
mHasHorizontalScrollbar = PR_TRUE;
|
2003-05-22 05:46:13 +04:00
|
|
|
if (styles.mVertical == NS_STYLE_OVERFLOW_SCROLL)
|
2000-03-31 11:02:06 +04:00
|
|
|
mHasVerticalScrollbar = PR_TRUE;
|
|
|
|
|
2000-05-15 08:12:31 +04:00
|
|
|
if (mHasHorizontalScrollbar)
|
|
|
|
AddHorizontalScrollbar(aState, scrollAreaRect, scrollBarBottom);
|
1999-08-20 02:16:23 +04:00
|
|
|
|
2000-05-15 08:12:31 +04:00
|
|
|
if (mHasVerticalScrollbar)
|
|
|
|
AddVerticalScrollbar(aState, scrollAreaRect, scrollBarRight);
|
|
|
|
|
2001-04-17 05:45:38 +04:00
|
|
|
nsRect oldScrollAreaBounds;
|
|
|
|
mScrollAreaBox->GetClientRect(oldScrollAreaBounds);
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
// layout our the scroll area
|
|
|
|
LayoutBox(aState, mScrollAreaBox, scrollAreaRect);
|
|
|
|
|
|
|
|
// now look at the content area and see if we need scrollbars or not
|
|
|
|
PRBool needsLayout = PR_FALSE;
|
|
|
|
nsSize scrolledContentSize(0,0);
|
|
|
|
|
|
|
|
// if we have 'auto' scrollbars look at the vertical case
|
2003-05-22 05:46:13 +04:00
|
|
|
if (styles.mVertical != NS_STYLE_OVERFLOW_SCROLL) {
|
2000-03-31 11:02:06 +04:00
|
|
|
// get the area frame is the scrollarea
|
2000-07-08 02:24:06 +04:00
|
|
|
GetScrolledSize(aState.GetPresContext(),&scrolledContentSize.width, &scrolledContentSize.height);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
|
|
|
// There are two cases to consider
|
|
|
|
if (scrolledContentSize.height <= scrollAreaRect.height
|
2003-05-22 05:46:13 +04:00
|
|
|
|| styles.mVertical != NS_STYLE_OVERFLOW_AUTO) {
|
2000-03-31 11:02:06 +04:00
|
|
|
if (mHasVerticalScrollbar) {
|
|
|
|
// We left room for the vertical scrollbar, but it's not needed;
|
|
|
|
// remove it.
|
2004-03-11 02:52:01 +03:00
|
|
|
RemoveVerticalScrollbar(aState, scrollAreaRect, scrollBarRight);
|
|
|
|
needsLayout = PR_TRUE;
|
|
|
|
SetAttribute(mVScrollbarBox, nsXULAtoms::curpos, 0);
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!mHasVerticalScrollbar) {
|
|
|
|
// We didn't leave room for the vertical scrollbar, but it turns
|
|
|
|
// out we needed it
|
2000-05-15 08:12:31 +04:00
|
|
|
if (AddVerticalScrollbar(aState, scrollAreaRect, scrollBarRight))
|
2000-03-31 11:02:06 +04:00
|
|
|
needsLayout = PR_TRUE;
|
1999-08-20 02:16:23 +04:00
|
|
|
}
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
1999-08-20 02:16:23 +04:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
// ok layout at the right size
|
|
|
|
if (needsLayout) {
|
|
|
|
nsBoxLayoutState resizeState(aState);
|
|
|
|
resizeState.SetLayoutReason(nsBoxLayoutState::Resize);
|
2002-01-23 05:53:02 +03:00
|
|
|
PRBool setBack;
|
|
|
|
AdjustReflowStateForPrintPreview(aState, setBack);
|
2000-03-31 11:02:06 +04:00
|
|
|
LayoutBox(resizeState, mScrollAreaBox, scrollAreaRect);
|
2002-01-23 05:53:02 +03:00
|
|
|
AdjustReflowStateBack(aState, setBack);
|
2000-05-15 08:12:31 +04:00
|
|
|
needsLayout = PR_FALSE;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
}
|
1999-08-20 02:16:23 +04:00
|
|
|
|
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
// if scrollbars are auto look at the horizontal case
|
2003-05-22 05:46:13 +04:00
|
|
|
if (styles.mHorizontal != NS_STYLE_OVERFLOW_SCROLL)
|
2000-03-31 11:02:06 +04:00
|
|
|
{
|
|
|
|
// get the area frame is the scrollarea
|
2000-07-08 02:24:06 +04:00
|
|
|
GetScrolledSize(aState.GetPresContext(),&scrolledContentSize.width, &scrolledContentSize.height);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
|
|
|
// if the child is wider that the scroll area
|
|
|
|
// and we don't have a scrollbar add one.
|
|
|
|
if (scrolledContentSize.width > scrollAreaRect.width
|
2003-05-22 05:46:13 +04:00
|
|
|
&& styles.mHorizontal == NS_STYLE_OVERFLOW_AUTO) {
|
2000-03-31 11:02:06 +04:00
|
|
|
|
|
|
|
if (!mHasHorizontalScrollbar) {
|
2000-05-15 08:12:31 +04:00
|
|
|
// no scrollbar?
|
|
|
|
if (AddHorizontalScrollbar(aState, scrollAreaRect, scrollBarBottom))
|
2000-03-31 11:02:06 +04:00
|
|
|
needsLayout = PR_TRUE;
|
2000-05-15 08:12:31 +04:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
// if we added a horizonal scrollbar and we did not have a vertical
|
|
|
|
// there is a chance that by adding the horizonal scrollbar we will
|
|
|
|
// suddenly need a vertical scrollbar. Is a special case but its
|
|
|
|
// important.
|
2000-04-27 01:01:57 +04:00
|
|
|
//if (!mHasVerticalScrollbar && scrolledContentSize.height > scrollAreaRect.height - sbSize.height)
|
2000-10-29 02:17:53 +04:00
|
|
|
// printf("****Gfx Scrollbar Special case hit!!*****\n");
|
2000-04-03 10:26:38 +04:00
|
|
|
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
}
|
2001-04-12 03:04:11 +04:00
|
|
|
#ifdef IBMBIDI
|
2003-05-15 07:42:21 +04:00
|
|
|
const nsStyleVisibility* ourVis = frame->GetStyleVisibility();
|
2001-06-01 02:19:43 +04:00
|
|
|
|
|
|
|
if (NS_STYLE_DIRECTION_RTL == ourVis->mDirection) {
|
2002-07-27 00:57:24 +04:00
|
|
|
nsCOMPtr<nsITextControlFrame> textControl(
|
2001-04-12 03:04:11 +04:00
|
|
|
do_QueryInterface(mOuter->mParent) );
|
|
|
|
if (textControl) {
|
|
|
|
needsLayout = PR_TRUE;
|
|
|
|
reflowState->mRightEdge = scrolledContentSize.width;
|
|
|
|
mScrollAreaBox->MarkDirty(aState);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // IBMBIDI
|
2000-03-31 11:02:06 +04:00
|
|
|
} else {
|
|
|
|
// if the area is smaller or equal to and we have a scrollbar then
|
|
|
|
// remove it.
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
if (mHasHorizontalScrollbar) {
|
2004-03-11 02:52:01 +03:00
|
|
|
RemoveHorizontalScrollbar(aState, scrollAreaRect, scrollBarBottom);
|
|
|
|
needsLayout = PR_TRUE;
|
|
|
|
SetAttribute(mHScrollbarBox, nsXULAtoms::curpos, 0);
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-08-20 02:16:23 +04:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
// we only need to set the rect. The inner child stays the same size.
|
|
|
|
if (needsLayout) {
|
|
|
|
nsBoxLayoutState resizeState(aState);
|
|
|
|
resizeState.SetLayoutReason(nsBoxLayoutState::Resize);
|
2002-01-23 05:53:02 +03:00
|
|
|
PRBool setBack;
|
|
|
|
AdjustReflowStateForPrintPreview(aState, setBack);
|
2000-04-03 10:26:38 +04:00
|
|
|
LayoutBox(resizeState, mScrollAreaBox, scrollAreaRect);
|
2002-01-23 05:53:02 +03:00
|
|
|
AdjustReflowStateBack(aState, setBack);
|
2000-05-15 08:12:31 +04:00
|
|
|
needsLayout = PR_FALSE;
|
2001-04-12 03:04:11 +04:00
|
|
|
#ifdef IBMBIDI
|
|
|
|
reflowState->mRightEdge = NS_UNCONSTRAINEDSIZE;
|
|
|
|
#endif // IBMBIDI
|
1999-11-19 18:33:29 +03:00
|
|
|
}
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2000-07-08 02:24:06 +04:00
|
|
|
GetScrolledSize(aState.GetPresContext(),&scrolledContentSize.width, &scrolledContentSize.height);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
|
|
|
nsIPresContext* presContext = aState.GetPresContext();
|
|
|
|
float p2t;
|
|
|
|
presContext->GetScaledPixelsToTwips(&p2t);
|
|
|
|
mOnePixel = NSIntPixelsToTwips(1, p2t);
|
2003-05-15 07:42:21 +04:00
|
|
|
const nsStyleFont* font = mOuter->GetStyleFont();
|
2000-03-31 11:02:06 +04:00
|
|
|
const nsFont& f = font->mFont;
|
|
|
|
nsCOMPtr<nsIFontMetrics> fm;
|
|
|
|
presContext->GetMetricsFor(f, getter_AddRefs(fm));
|
|
|
|
nscoord fontHeight = 1;
|
2001-05-15 07:12:08 +04:00
|
|
|
NS_ASSERTION(fm,"FontMetrics is null assuming fontHeight == 1");
|
|
|
|
if (fm)
|
|
|
|
fm->GetHeight(fontHeight);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2004-03-11 02:52:01 +03:00
|
|
|
// get the preferred size of the scrollbars
|
|
|
|
nsSize hSize(0,0);
|
|
|
|
nsSize vSize(0,0);
|
|
|
|
nsSize hMinSize(0,0);
|
|
|
|
nsSize vMinSize(0,0);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2004-03-11 02:52:01 +03:00
|
|
|
if (mHScrollbarBox && mHasHorizontalScrollbar) {
|
2000-08-04 02:42:36 +04:00
|
|
|
mHScrollbarBox->GetPrefSize(aState, hSize);
|
2004-03-11 02:52:01 +03:00
|
|
|
mHScrollbarBox->GetMinSize(aState, hMinSize);
|
|
|
|
nsBox::AddMargin(mHScrollbarBox, hSize);
|
|
|
|
nsBox::AddMargin(mHScrollbarBox, hMinSize);
|
|
|
|
}
|
|
|
|
if (mVScrollbarBox && mHasVerticalScrollbar) {
|
2000-08-04 02:42:36 +04:00
|
|
|
mVScrollbarBox->GetPrefSize(aState, vSize);
|
2004-03-11 02:52:01 +03:00
|
|
|
mVScrollbarBox->GetMinSize(aState, vMinSize);
|
|
|
|
nsBox::AddMargin(mVScrollbarBox, vSize);
|
|
|
|
nsBox::AddMargin(mVScrollbarBox, vMinSize);
|
|
|
|
}
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2004-03-11 02:52:01 +03:00
|
|
|
// Disable scrollbars that are too small
|
|
|
|
// Disable horizontal scrollbar first. If we have to disable only one
|
|
|
|
// scrollbar, we'd rather keep the vertical scrollbar.
|
2004-03-12 06:35:53 +03:00
|
|
|
// Note that we always give horizontal scrollbars their preferred height,
|
|
|
|
// never their min-height. So check that there's room for the preferred height.
|
2004-03-11 02:52:01 +03:00
|
|
|
if (mHasHorizontalScrollbar &&
|
|
|
|
(hMinSize.width > clientRect.width - vSize.width
|
2004-03-12 06:35:53 +03:00
|
|
|
|| hSize.height > clientRect.height)) {
|
2004-03-11 02:52:01 +03:00
|
|
|
RemoveHorizontalScrollbar(aState, scrollAreaRect, scrollBarBottom);
|
|
|
|
needsLayout = PR_TRUE;
|
|
|
|
SetAttribute(mHScrollbarBox, nsXULAtoms::curpos, 0);
|
|
|
|
// set the scrollbar to zero height to make it go away
|
|
|
|
hSize.height = 0;
|
|
|
|
hMinSize.height = 0;
|
|
|
|
}
|
|
|
|
// Now disable vertical scrollbar if necessary
|
|
|
|
if (mHasVerticalScrollbar &&
|
|
|
|
(vMinSize.height > clientRect.height - hSize.height
|
2004-03-12 06:35:53 +03:00
|
|
|
|| vSize.width > clientRect.width)) {
|
2004-03-11 02:52:01 +03:00
|
|
|
RemoveVerticalScrollbar(aState, scrollAreaRect, scrollBarRight);
|
|
|
|
needsLayout = PR_TRUE;
|
|
|
|
SetAttribute(mVScrollbarBox, nsXULAtoms::curpos, 0);
|
|
|
|
// set the scrollbar to zero width to make it go away
|
|
|
|
vSize.width = 0;
|
|
|
|
vMinSize.width = 0;
|
2000-04-25 11:10:48 +04:00
|
|
|
}
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2004-03-11 02:52:01 +03:00
|
|
|
nscoord maxX = scrolledContentSize.width - scrollAreaRect.width;
|
|
|
|
nscoord maxY = scrolledContentSize.height - scrollAreaRect.height;
|
2000-04-03 10:26:38 +04:00
|
|
|
|
2004-03-11 02:52:01 +03:00
|
|
|
nsIScrollableView* scrollable = GetScrollableView(presContext);
|
|
|
|
scrollable->SetLineHeight(fontHeight);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2004-03-11 02:52:01 +03:00
|
|
|
if (mVScrollbarBox) {
|
2000-04-25 11:10:48 +04:00
|
|
|
SetAttribute(mVScrollbarBox, nsXULAtoms::maxpos, maxY);
|
|
|
|
SetAttribute(mVScrollbarBox, nsXULAtoms::pageincrement, nscoord(scrollAreaRect.height - fontHeight));
|
2002-09-19 02:38:23 +04:00
|
|
|
SetAttribute(mVScrollbarBox, nsXULAtoms::increment, fontHeight);
|
1999-08-20 02:16:23 +04:00
|
|
|
|
2004-03-11 02:52:01 +03:00
|
|
|
nsRect vRect(scrollAreaRect);
|
|
|
|
vRect.width = vSize.width;
|
|
|
|
vRect.x = scrollBarRight ? scrollAreaRect.XMost() : clientRect.x;
|
|
|
|
nsMargin margin;
|
|
|
|
mVScrollbarBox->GetMargin(margin);
|
|
|
|
vRect.Deflate(margin);
|
2000-08-04 02:42:36 +04:00
|
|
|
LayoutBox(aState, mVScrollbarBox, vRect);
|
|
|
|
}
|
2004-03-11 02:52:01 +03:00
|
|
|
|
|
|
|
if (mHScrollbarBox) {
|
2000-04-25 11:10:48 +04:00
|
|
|
SetAttribute(mHScrollbarBox, nsXULAtoms::maxpos, maxX);
|
|
|
|
SetAttribute(mHScrollbarBox, nsXULAtoms::pageincrement, nscoord(float(scrollAreaRect.width)*0.8));
|
2002-09-20 18:50:43 +04:00
|
|
|
SetAttribute(mHScrollbarBox, nsXULAtoms::increment, 10*mOnePixel);
|
2000-04-25 11:10:48 +04:00
|
|
|
|
2004-03-11 02:52:01 +03:00
|
|
|
nsRect hRect(scrollAreaRect);
|
|
|
|
hRect.height = hSize.height;
|
|
|
|
hRect.y = scrollBarBottom ? scrollAreaRect.YMost() : clientRect.y;
|
|
|
|
nsMargin margin;
|
|
|
|
mHScrollbarBox->GetMargin(margin);
|
|
|
|
hRect.Deflate(margin);
|
2000-08-04 02:42:36 +04:00
|
|
|
LayoutBox(aState, mHScrollbarBox, hRect);
|
2000-04-25 11:10:48 +04:00
|
|
|
}
|
2000-05-15 08:12:31 +04:00
|
|
|
|
|
|
|
// we only need to set the rect. The inner child stays the same size.
|
|
|
|
if (needsLayout) {
|
|
|
|
nsBoxLayoutState resizeState(aState);
|
|
|
|
resizeState.SetLayoutReason(nsBoxLayoutState::Resize);
|
|
|
|
LayoutBox(resizeState, mScrollAreaBox, scrollAreaRect);
|
|
|
|
needsLayout = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
2003-11-21 13:45:24 +03:00
|
|
|
// place the scrollcorner
|
|
|
|
if (mScrollCornerBox) {
|
|
|
|
nsRect r(0, 0, 0, 0);
|
|
|
|
if (clientRect.x != scrollAreaRect.x) {
|
|
|
|
// scrollbar (if any) on left
|
|
|
|
r.x = clientRect.x;
|
|
|
|
r.width = scrollAreaRect.x - clientRect.x;
|
|
|
|
NS_ASSERTION(r.width >= 0, "Scroll area should be inside client rect");
|
|
|
|
} else {
|
|
|
|
// scrollbar (if any) on right
|
|
|
|
r.x = scrollAreaRect.XMost();
|
|
|
|
r.width = clientRect.XMost() - scrollAreaRect.XMost();
|
|
|
|
NS_ASSERTION(r.width >= 0, "Scroll area should be inside client rect");
|
|
|
|
}
|
|
|
|
if (clientRect.y != scrollAreaRect.y) {
|
|
|
|
// scrollbar (if any) on top
|
|
|
|
r.y = clientRect.y;
|
|
|
|
r.height = scrollAreaRect.y - clientRect.y;
|
|
|
|
NS_ASSERTION(r.height >= 0, "Scroll area should be inside client rect");
|
|
|
|
} else {
|
|
|
|
// scrollbar (if any) on bottom
|
|
|
|
r.y = scrollAreaRect.YMost();
|
|
|
|
r.height = clientRect.YMost() - scrollAreaRect.YMost();
|
|
|
|
NS_ASSERTION(r.height >= 0, "Scroll area should be inside client rect");
|
|
|
|
}
|
|
|
|
LayoutBox(aState, mScrollCornerBox, r);
|
|
|
|
}
|
|
|
|
|
2001-04-17 05:45:38 +04:00
|
|
|
// may need to update fixed position children of the viewport,
|
|
|
|
// if the client area changed size because of some dirty reflow
|
|
|
|
// (if the reflow is initial or resize, the fixed children will
|
|
|
|
// be re-laid out anyway)
|
|
|
|
if ((oldScrollAreaBounds.width != scrollAreaRect.width
|
|
|
|
|| oldScrollAreaBounds.height != scrollAreaRect.height)
|
|
|
|
&& nsBoxLayoutState::Dirty == aState.GetLayoutReason()) {
|
2003-06-29 07:43:05 +04:00
|
|
|
nsIFrame* parentFrame = mOuter->GetParent();
|
2001-04-17 05:45:38 +04:00
|
|
|
if (parentFrame) {
|
2003-10-31 23:19:18 +03:00
|
|
|
if (parentFrame->GetType() == nsLayoutAtoms::viewportFrame) {
|
2001-04-17 05:45:38 +04:00
|
|
|
// Usually there are no fixed children, so don't do anything unless there's
|
|
|
|
// at least one fixed child
|
2004-01-09 17:20:53 +03:00
|
|
|
if (parentFrame->GetFirstChild(nsLayoutAtoms::fixedList)) {
|
2001-04-17 05:45:38 +04:00
|
|
|
// force a reflow of the fixed children
|
2003-12-21 08:36:36 +03:00
|
|
|
nsFrame::CreateAndPostReflowCommand(mOuter->mPresContext->PresShell(),
|
|
|
|
parentFrame,
|
2001-12-18 01:39:59 +03:00
|
|
|
eReflowType_UserDefined, nsnull, nsnull, nsLayoutAtoms::fixedList);
|
2001-04-17 05:45:38 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-04-25 11:10:48 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
2001-04-17 05:45:38 +04:00
|
|
|
}
|
1999-08-20 02:16:23 +04:00
|
|
|
|
|
|
|
void
|
2003-03-24 08:29:45 +03:00
|
|
|
nsGfxScrollFrameInner::ScrollbarChanged(nsIPresContext* aPresContext, nscoord aX, nscoord aY, PRUint32 aFlags)
|
1999-08-20 02:16:23 +04:00
|
|
|
{
|
1999-10-26 08:44:41 +04:00
|
|
|
nsIScrollableView* scrollable = GetScrollableView(aPresContext);
|
2003-03-24 08:29:45 +03:00
|
|
|
scrollable->ScrollTo(aX, aY, aFlags);
|
2000-10-29 02:17:53 +04:00
|
|
|
// printf("scrolling to: %d, %d\n", aX, aY);
|
1999-08-20 02:16:23 +04:00
|
|
|
}
|
|
|
|
|
1999-10-12 04:16:06 +04:00
|
|
|
nsGfxScrollFrameInner::~nsGfxScrollFrameInner()
|
|
|
|
{
|
1999-08-20 02:16:23 +04:00
|
|
|
}
|
|
|
|
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
/**
|
|
|
|
* Returns whether it actually needed to change the attribute
|
|
|
|
*/
|
|
|
|
PRBool
|
2000-03-31 11:02:06 +04:00
|
|
|
nsGfxScrollFrameInner::SetAttribute(nsIBox* aBox, nsIAtom* aAtom, nscoord aSize, PRBool aReflow)
|
1999-08-20 02:16:23 +04:00
|
|
|
{
|
|
|
|
// convert to pixels
|
|
|
|
aSize /= mOnePixel;
|
|
|
|
|
1999-10-12 04:16:06 +04:00
|
|
|
// only set the attribute if it changed.
|
1999-08-20 02:16:23 +04:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
PRInt32 current = GetIntegerAttribute(aBox, aAtom, -1);
|
1999-10-12 04:16:06 +04:00
|
|
|
if (current != aSize)
|
|
|
|
{
|
2000-03-31 11:02:06 +04:00
|
|
|
nsIFrame* frame = nsnull;
|
|
|
|
aBox->GetFrame(&frame);
|
2001-08-02 16:12:53 +04:00
|
|
|
nsAutoString newValue;
|
|
|
|
newValue.AppendInt(aSize);
|
2003-06-29 07:43:05 +04:00
|
|
|
frame->GetContent()->SetAttr(kNameSpaceID_None, aAtom, newValue, aReflow);
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
return PR_TRUE;
|
1999-10-12 04:16:06 +04:00
|
|
|
}
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
|
|
|
|
return PR_FALSE;
|
1999-08-20 02:16:23 +04:00
|
|
|
}
|
|
|
|
|
2000-07-08 02:24:06 +04:00
|
|
|
/**
|
|
|
|
* Gets the size of the area that lies inside the scrollbars but clips the scrolled frame
|
|
|
|
*/
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGfxScrollFrameInner::GetScrolledSize(nsIPresContext* aPresContext,
|
|
|
|
nscoord *aWidth,
|
|
|
|
nscoord *aHeight) const
|
|
|
|
{
|
|
|
|
|
|
|
|
// our scrolled size is the size of our scrolled view.
|
|
|
|
nsIBox* child = nsnull;
|
|
|
|
mScrollAreaBox->GetChildBox(&child);
|
|
|
|
nsIFrame* frame;
|
|
|
|
child->GetFrame(&frame);
|
2003-06-29 07:43:05 +04:00
|
|
|
nsIView* view = frame->GetView();
|
2000-07-08 02:24:06 +04:00
|
|
|
NS_ASSERTION(view,"Scrolled frame must have a view!!!");
|
|
|
|
|
2003-06-29 07:43:05 +04:00
|
|
|
nsRect rect = view->GetBounds();
|
|
|
|
nsSize size(rect.width, rect.height);
|
|
|
|
|
2000-07-08 02:24:06 +04:00
|
|
|
nsBox::AddMargin(child, size);
|
|
|
|
nsBox::AddBorderAndPadding(mScrollAreaBox, size);
|
|
|
|
nsBox::AddInset(mScrollAreaBox, size);
|
|
|
|
|
|
|
|
*aWidth = size.width;
|
|
|
|
*aHeight = size.height;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-05-15 08:12:31 +04:00
|
|
|
void
|
|
|
|
nsGfxScrollFrameInner::SetScrollbarVisibility(nsIBox* aScrollbar, PRBool aVisible)
|
|
|
|
{
|
2002-10-24 07:11:53 +04:00
|
|
|
if (!aScrollbar)
|
|
|
|
return;
|
|
|
|
|
2000-07-14 03:00:59 +04:00
|
|
|
nsCOMPtr<nsIScrollbarFrame> scrollbar(do_QueryInterface(aScrollbar));
|
|
|
|
if (scrollbar) {
|
|
|
|
// See if we have a mediator.
|
|
|
|
nsCOMPtr<nsIScrollbarMediator> mediator;
|
|
|
|
scrollbar->GetScrollbarMediator(getter_AddRefs(mediator));
|
|
|
|
if (mediator) {
|
|
|
|
// Inform the mediator of the visibility change.
|
|
|
|
mediator->VisibilityChanged(aVisible);
|
|
|
|
}
|
|
|
|
}
|
2000-05-15 08:12:31 +04:00
|
|
|
}
|
|
|
|
|
1999-10-12 04:16:06 +04:00
|
|
|
PRInt32
|
2000-03-31 11:02:06 +04:00
|
|
|
nsGfxScrollFrameInner::GetIntegerAttribute(nsIBox* aBox, nsIAtom* atom, PRInt32 defaultValue)
|
1999-08-20 02:16:23 +04:00
|
|
|
{
|
2000-03-31 11:02:06 +04:00
|
|
|
nsIFrame* frame = nsnull;
|
|
|
|
aBox->GetFrame(&frame);
|
|
|
|
|
2003-06-29 07:43:05 +04:00
|
|
|
nsIContent* content = frame->GetContent();
|
1999-08-20 02:16:23 +04:00
|
|
|
|
Landing changes Vidur made while the tree was closed for beta1 work, here's a list of the changes. r=me
[1] Cutting down the size of content. Made nsIJSScriptObject inherit from nsIScriptObjectOwner
[2] Cutting down the size of content. Made nsITextContent inherit from nsIContent.
[3] Cutting down the size of content. Moved implementation of nsIDOMReceiver to nsListenerManager. This is not true aggregation since it isn't transitive, but it's OK for now. It will be necessary for nsListenerManager to have a reference to its content in the future anyway, so the transitivity could be done.
dom/public/nsDOMPropEnums.h,v - bug 12559
dom/public/nsIJSScriptObject.h,v - [1]
dom/public/html/MANIFEST,v - bug 12559
dom/public/html/Makefile.in,v - bug 12559
dom/public/html/makefile.win,v - bug 12559
dom/public/html/nsIDOMHTMLInputElement.h,v - bug 17544
dom/public/idl/html/HTMLAnchorElement.idl,v - bug 12559
dom/public/idl/html/HTMLAreaElement.idl,v - bug 12559
dom/public/idl/html/HTMLInputElement.idl,v - bug 17544
dom/src/base/nsGlobalWindow.cpp,v - bug 30700
dom/src/base/nsGlobalWindow.h,v - [1]
dom/src/base/nsLocation.cpp,v - [1]
dom/src/html/nsJSHTMLAnchorElement.cpp,v - bug 12559
dom/src/html/nsJSHTMLAreaElement.cpp,v - bug 12559
dom/src/html/nsJSHTMLInputElement.cpp,v - bug 17544
layout/base/public/nsIDocument.h,v - bug 27953
layout/base/public/nsITextContent.h,v - [2]
layout/base/src/nsCommentNode.cpp,v - [2]
layout/base/src/nsDocument.cpp,v - bug 27953
layout/base/src/nsDocument.h,v - bug 27953
layout/base/src/nsDocumentViewer.cpp,v - bug 27953
layout/base/src/nsGenericDOMDataNode.cpp,v - [3]
layout/base/src/nsGenericDOMDataNode.h,v - [3]
layout/base/src/nsGenericElement.cpp,v - [3]
layout/base/src/nsGenericElement.h,v - [3]
layout/base/src/nsNameSpaceManager.cpp,v - bug 7834
layout/base/src/nsStyleContext.cpp,v - outline property shouldn't reflow
layout/base/src/nsTextNode.cpp,v - [2]
layout/events/src/nsEventListenerManager.cpp,v - [3]
layout/events/src/nsEventListenerManager.h,v - [3]
layout/html/base/src/nsGfxScrollFrame.cpp,v - nsString->nsAutoString
layout/html/content/src/nsAttributeContent.cpp,v - [2]
layout/html/content/src/nsHTMLAnchorElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLAppletElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLAreaElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBRElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBaseElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBaseFontElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLBodyElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLButtonElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDListElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDelElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDirectoryElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLDivElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLEmbedElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFieldSetElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFontElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFormElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFrameElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLFrameSetElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHRElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHeadElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHeadingElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLHtmlElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLIFrameElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLImageElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLInputElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLInsElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLIsIndexElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLIElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLabelElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLayerElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLegendElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLLinkElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLMapElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLMenuElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLMetaElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLModElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLOListElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLObjectElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLOptGroupElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLOptionElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLParagraphElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLParamElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLPreElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLQuoteElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLScriptElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLSelectElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLSpacerElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLSpanElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLStyleElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableCaptionElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableCellElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableColElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableColGroupElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableRowElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTableSectionElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTextAreaElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLTitleElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLUListElement.cpp,v - [1][3]
layout/html/content/src/nsHTMLWBRElement.cpp,v - [1][3]
layout/html/document/src/nsHTMLDocument.cpp,v - bug 27953
layout/html/document/src/nsHTMLDocument.h,v - bug 27953
layout/xml/content/src/nsXMLCDATASection.cpp,v - [1][2]
layout/xml/content/src/nsXMLDocumentType.cpp,v - [1][2]
layout/xml/content/src/nsXMLElement.h,v - [1][2]
layout/xml/content/src/nsXMLEntity.cpp,v - [1][2]
layout/xml/content/src/nsXMLNotation.cpp,v - [1][2]
layout/xml/content/src/nsXMLProcessingInstruction.cpp,v - [1][2]
layout/xul/base/src/nsBoxFrame.cpp,v - nsString->nsAutoString
layout/xul/base/src/nsSliderFrame.cpp,v - nsString->nsAutoString
netwerk/protocol/http/src/nsHTTPRequest.cpp,v - nsString->nsAutoString
rdf/content/src/nsXULDocument.cpp,v - bug 27953
rdf/content/src/nsXULDocument.h,v - bug 27953
rdf/content/src/nsXULElement.h,v - [1]
xpcom/base/IIDS.h,v - bug 12559
2000-03-17 16:27:00 +03:00
|
|
|
nsAutoString value;
|
2001-08-17 12:14:14 +04:00
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttr(kNameSpaceID_None, atom, value))
|
1999-10-12 04:16:06 +04:00
|
|
|
{
|
|
|
|
PRInt32 error;
|
1999-08-20 02:16:23 +04:00
|
|
|
|
1999-10-12 04:16:06 +04:00
|
|
|
// convert it to an integer
|
|
|
|
defaultValue = value.ToInteger(&error);
|
|
|
|
}
|
1999-08-20 02:16:23 +04:00
|
|
|
|
1999-10-12 04:16:06 +04:00
|
|
|
return defaultValue;
|
1999-08-20 02:16:23 +04:00
|
|
|
}
|
|
|
|
|
1999-10-12 04:16:06 +04:00
|
|
|
nsresult
|
2000-03-31 11:02:06 +04:00
|
|
|
nsGfxScrollFrame::GetContentOf(nsIContent** aContent)
|
1999-08-20 02:16:23 +04:00
|
|
|
{
|
2003-06-29 07:43:05 +04:00
|
|
|
*aContent = GetContent();
|
|
|
|
NS_IF_ADDREF(*aContent);
|
|
|
|
return NS_OK;
|
1999-08-20 02:16:23 +04:00
|
|
|
}
|