Integrated Gfx scrollbars.

git-svn-id: svn://10.0.0.236/trunk@50385 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
evaughan%netscape.com 1999-10-12 00:16:06 +00:00
parent 6d6b3023f8
commit b6c93b5c5c
26 changed files with 5525 additions and 1875 deletions

File diff suppressed because it is too large Load Diff

View File

@ -22,6 +22,7 @@
#include "nslayout.h"
#include "nsIPresContext.h"
#include "nsCOMPtr.h"
#include "nsIStyleContext.h"
class nsIDocument;
struct nsFrameItems;
@ -544,46 +545,43 @@ protected:
nsIFrame* GetFloaterContainingBlock(nsIPresContext* aPresContext,
nsIFrame* aFrame);
nsresult BuildBlockScrollFrame (nsIPresContext* aPresContext,
nsFrameConstructorState& aState,
nsIContent* aContent,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aNewFrame,
PRBool aProcessChildren,
PRBool aIsAbsolutelyPositioned,
PRBool aIsFixedPositioned,
PRBool aCreateBlock);
nsresult BuildBoxScrollFrame (nsIPresContext* aPresContext,
nsFrameConstructorState& aState,
nsIContent* aContent,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aNewFrame,
PRBool aProcessChildren,
PRBool aIsAbsolutelyPositioned,
PRBool aIsFixedPositioned,
PRBool aCreateBlock);
nsresult
BuildScrollFrame (nsIPresContext* aPresContext,
BuildScrollFrame (nsIPresContext* aPresContext,
nsFrameConstructorState& aState,
nsIContent* aContent,
nsIStyleContext* aContentStyle,
nsIFrame* aScrolledFrame,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aNewFrame,
PRBool aProcessChildren,
PRBool aIsAbsolutelyPositioned,
PRBool aIsFixedPositioned,
PRBool aCreateBlock);
nsIStyleContext*& aScrolledChildStyle);
nsresult
BeginBuildingScrollFrame (nsIPresContext* aPresContext,
nsFrameConstructorState& aState,
nsIContent* aContent,
nsIStyleContext* aContentStyle,
nsIFrame* aParentFrame,
nsIAtom* aScrolledPseudo,
nsIDocument* aDocument,
nsIFrame*& aNewFrame,
nsCOMPtr<nsIStyleContext>& aScrolledChildStyle,
nsIFrame*& aScrollableFrame);
nsresult
FinishBuildingScrollFrame(nsIPresContext* aPresContext,
nsFrameConstructorState& aState,
nsIContent* aContent,
nsIFrame* aScrollFrame,
nsIFrame* aScrolledFrame,
nsIStyleContext* scrolledPseudoStyle);
nsresult
BuildGfxScrollFrame (nsIPresContext* aPresContext,
BuildGfxScrollFrame (nsIPresContext* PresContext,
nsFrameConstructorState& aState,
nsIContent* aContent,
nsIDocument* aDocument,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aNewFrame,
@ -591,14 +589,13 @@ BuildGfxScrollFrame (nsIPresContext* aPresContext,
nsresult
InitializeScrollFrame(nsIPresContext* aPresContext,
InitializeSelectFrame(nsIPresContext* aPresContext,
nsFrameConstructorState& aState,
nsIFrame* scrollFrame,
nsIFrame* scrolledFrame,
nsIContent* aContent,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
PRBool aProcessChildren,
PRBool aIsAbsolutelyPositioned,
PRBool aIsFixedPositioned,
PRBool aCreateBlock);

File diff suppressed because it is too large Load Diff

View File

@ -21,9 +21,10 @@
#include "nsHTMLContainerFrame.h"
#include "nsIAnonymousContentCreator.h"
#include "nsIDocumentObserver.h"
#include "nsIBox.h"
class nsISupportsArray;
class nsGfxScrollFrameInner;
/**
* The scroll frame creates and manages the scrolling view
@ -36,9 +37,9 @@ class nsISupportsArray;
*/
class nsGfxScrollFrame : public nsHTMLContainerFrame,
public nsIAnonymousContentCreator,
public nsIDocumentObserver {
public nsIBox {
public:
friend nsresult NS_NewGfxScrollFrame(nsIFrame** aNewFrame);
friend nsresult NS_NewGfxScrollFrame(nsIFrame** aNewFrame, nsIDocument* aDocument);
NS_IMETHOD Init(nsIPresContext& aPresContext,
nsIContent* aContent,
@ -46,6 +47,9 @@ public:
nsIStyleContext* aContext,
nsIFrame* aPrevInFlow);
virtual ~nsGfxScrollFrame();
// Called to set the one and only child frame. Returns NS_ERROR_INVALID_ARG
// if the child frame is NULL, and NS_ERROR_UNEXPECTED if the child list
// contains more than one frame
@ -86,8 +90,12 @@ public:
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer);
// added for anonymous content support
// nsIAnonymousContentCreator
NS_IMETHOD CreateAnonymousContent(nsISupportsArray& aAnonymousItems);
// nsIBox methods
NS_IMETHOD GetBoxInfo(nsIPresContext& aPresContext, const nsHTMLReflowState& aReflowState, nsBoxInfo& aSize);
NS_IMETHOD Dirty(const nsHTMLReflowState& aReflowState, nsIFrame*& aIncrementalChild);
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef(void) { return NS_OK; }
NS_IMETHOD_(nsrefcnt) Release(void) { return NS_OK; }
@ -101,155 +109,13 @@ public:
NS_IMETHOD GetFrameName(nsString& aResult) const;
// nsIDocumentObserver
NS_IMETHOD BeginUpdate(nsIDocument *aDocument) { return NS_OK; }
NS_IMETHOD EndUpdate(nsIDocument *aDocument) { return NS_OK; }
NS_IMETHOD BeginLoad(nsIDocument *aDocument) { return NS_OK; }
NS_IMETHOD EndLoad(nsIDocument *aDocument) { return NS_OK; }
NS_IMETHOD BeginReflow(nsIDocument *aDocument,
nsIPresShell* aShell) { return NS_OK; }
NS_IMETHOD EndReflow(nsIDocument *aDocument,
nsIPresShell* aShell) { return NS_OK; }
NS_IMETHOD ContentChanged(nsIDocument* aDoc,
nsIContent* aContent,
nsISupports* aSubContent) { return NS_OK; }
NS_IMETHOD ContentStatesChanged(nsIDocument* aDocument,
nsIContent* aContent1,
nsIContent* aContent2) { return NS_OK; }
NS_IMETHOD AttributeChanged(nsIDocument *aDocument,
nsIContent* aContent,
nsIAtom* aAttribute,
PRInt32 aHint);
NS_IMETHOD ContentAppended(nsIDocument *aDocument,
nsIContent* aContainer,
PRInt32 aNewIndexInContainer) { return NS_OK; }
NS_IMETHOD ContentInserted(nsIDocument *aDocument,
nsIContent* aContainer,
nsIContent* aChild,
PRInt32 aIndexInContainer) { return NS_OK; }
NS_IMETHOD ContentReplaced(nsIDocument *aDocument,
nsIContent* aContainer,
nsIContent* aOldChild,
nsIContent* aNewChild,
PRInt32 aIndexInContainer);
NS_IMETHOD ContentRemoved(nsIDocument *aDocument,
nsIContent* aContainer,
nsIContent* aChild,
PRInt32 aIndexInContainer);
NS_IMETHOD StyleSheetAdded(nsIDocument *aDocument,
nsIStyleSheet* aStyleSheet) { return NS_OK; }
NS_IMETHOD StyleSheetRemoved(nsIDocument *aDocument,
nsIStyleSheet* aStyleSheet) { return NS_OK; }
NS_IMETHOD StyleSheetDisabledStateChanged(nsIDocument *aDocument,
nsIStyleSheet* aStyleSheet,
PRBool aDisabled) { return NS_OK; }
NS_IMETHOD StyleRuleChanged(nsIDocument *aDocument,
nsIStyleSheet* aStyleSheet,
nsIStyleRule* aStyleRule,
PRInt32 aHint) { return NS_OK; }
NS_IMETHOD StyleRuleAdded(nsIDocument *aDocument,
nsIStyleSheet* aStyleSheet,
nsIStyleRule* aStyleRule) { return NS_OK; }
NS_IMETHOD StyleRuleRemoved(nsIDocument *aDocument,
nsIStyleSheet* aStyleSheet,
nsIStyleRule* aStyleRule) { return NS_OK; }
NS_IMETHOD DocumentWillBeDestroyed(nsIDocument *aDocument) { return NS_OK; }
protected:
nsGfxScrollFrame();
nsGfxScrollFrame(nsIDocument* aDocument);
virtual PRIntn GetSkipSides() const;
virtual void ScrollbarChanged(nscoord aX, nscoord aY);
private:
void SetAttribute(nsIFrame* aFrame, nsIAtom* aAtom, nscoord aSize);
nsresult CalculateChildTotalSize(nsIFrame* aKidFrame,
nsHTMLReflowMetrics& aKidReflowMetrics);
nsresult GetFrameSize( nsIFrame* aFrame,
nsSize& aSize);
nsresult SetFrameSize( nsIFrame* aFrame,
nsSize aSize);
nsresult CalculateScrollAreaSize(nsIPresContext& aPresContext,
const nsHTMLReflowState& aReflowState,
const nsSize& aSbSize,
nsSize& aScrollAreaSize);
void SetScrollbarVisibility(nsIFrame* aScrollbar, PRBool aVisible);
void DetermineReflowNeed(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus,
PRBool& aHscrollbarNeedsReflow,
PRBool& aVscrollbarNeedsReflow,
PRBool& aScrollAreaNeedsReflow,
nsIFrame*& aIncrementalChild);
void ReflowScrollbars( nsIPresContext& aPresContext,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus,
PRBool& aHscrollbarNeedsReflow,
PRBool& aVscrollbarNeedsReflow,
PRBool& aScrollBarResized,
nsIFrame*& aIncrementalChild);
void ReflowScrollbar( nsIPresContext& aPresContext,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus,
PRBool& aScrollBarResized,
nsIFrame* aScrollBarFrame,
nsIFrame*& aIncrementalChild);
nsresult ReflowFrame( nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus,
nsIFrame* aFrame,
const nsSize& aAvailable,
const nsSize& aComputed,
PRBool& aResized,
nsIFrame*& aIncrementalChild);
void ReflowScrollArea( nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus,
PRBool& aHscrollbarNeedsReflow,
PRBool& aVscrollbarNeedsReflow,
PRBool& aScrollAreaNeedsReflow,
nsIFrame*& aIncrementalChild);
void LayoutChildren(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState);
void GetScrollbarDimensions(nsIPresContext& aPresContext,
nsSize& aSbSize);
void AddRemoveScrollbar (PRBool& aHasScrollbar, nscoord& aSize, nscoord aSbSize, PRBool aAdd);
void AddHorizontalScrollbar (const nsSize& aSbSize, nsSize& aScrollAreaSize);
void AddVerticalScrollbar (const nsSize& aSbSize, nsSize& aScrollAreaSize);
void RemoveHorizontalScrollbar(const nsSize& aSbSize, nsSize& aScrollAreaSize);
void RemoveVerticalScrollbar (const nsSize& aSbSize, nsSize& aScrollAreaSize);
nsIScrollableView* GetScrollableView();
void GetScrolledContentSize(nsSize& aSize);
nsIFrame* mHScrollbarFrame;
nsIFrame* mVScrollbarFrame;
nsIFrame* mScrollAreaFrame;
PRBool mHasVerticalScrollbar;
PRBool mHasHorizontalScrollbar;
nscoord mOnePixel;
friend nsGfxScrollFrameInner;
nsGfxScrollFrameInner* mInner;
};
#endif /* nsScrollFrame_h___ */

File diff suppressed because it is too large Load Diff

View File

@ -21,9 +21,10 @@
#include "nsHTMLContainerFrame.h"
#include "nsIAnonymousContentCreator.h"
#include "nsIDocumentObserver.h"
#include "nsIBox.h"
class nsISupportsArray;
class nsGfxScrollFrameInner;
/**
* The scroll frame creates and manages the scrolling view
@ -36,9 +37,9 @@ class nsISupportsArray;
*/
class nsGfxScrollFrame : public nsHTMLContainerFrame,
public nsIAnonymousContentCreator,
public nsIDocumentObserver {
public nsIBox {
public:
friend nsresult NS_NewGfxScrollFrame(nsIFrame** aNewFrame);
friend nsresult NS_NewGfxScrollFrame(nsIFrame** aNewFrame, nsIDocument* aDocument);
NS_IMETHOD Init(nsIPresContext& aPresContext,
nsIContent* aContent,
@ -46,6 +47,9 @@ public:
nsIStyleContext* aContext,
nsIFrame* aPrevInFlow);
virtual ~nsGfxScrollFrame();
// Called to set the one and only child frame. Returns NS_ERROR_INVALID_ARG
// if the child frame is NULL, and NS_ERROR_UNEXPECTED if the child list
// contains more than one frame
@ -86,8 +90,12 @@ public:
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer);
// added for anonymous content support
// nsIAnonymousContentCreator
NS_IMETHOD CreateAnonymousContent(nsISupportsArray& aAnonymousItems);
// nsIBox methods
NS_IMETHOD GetBoxInfo(nsIPresContext& aPresContext, const nsHTMLReflowState& aReflowState, nsBoxInfo& aSize);
NS_IMETHOD Dirty(const nsHTMLReflowState& aReflowState, nsIFrame*& aIncrementalChild);
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef(void) { return NS_OK; }
NS_IMETHOD_(nsrefcnt) Release(void) { return NS_OK; }
@ -101,155 +109,13 @@ public:
NS_IMETHOD GetFrameName(nsString& aResult) const;
// nsIDocumentObserver
NS_IMETHOD BeginUpdate(nsIDocument *aDocument) { return NS_OK; }
NS_IMETHOD EndUpdate(nsIDocument *aDocument) { return NS_OK; }
NS_IMETHOD BeginLoad(nsIDocument *aDocument) { return NS_OK; }
NS_IMETHOD EndLoad(nsIDocument *aDocument) { return NS_OK; }
NS_IMETHOD BeginReflow(nsIDocument *aDocument,
nsIPresShell* aShell) { return NS_OK; }
NS_IMETHOD EndReflow(nsIDocument *aDocument,
nsIPresShell* aShell) { return NS_OK; }
NS_IMETHOD ContentChanged(nsIDocument* aDoc,
nsIContent* aContent,
nsISupports* aSubContent) { return NS_OK; }
NS_IMETHOD ContentStatesChanged(nsIDocument* aDocument,
nsIContent* aContent1,
nsIContent* aContent2) { return NS_OK; }
NS_IMETHOD AttributeChanged(nsIDocument *aDocument,
nsIContent* aContent,
nsIAtom* aAttribute,
PRInt32 aHint);
NS_IMETHOD ContentAppended(nsIDocument *aDocument,
nsIContent* aContainer,
PRInt32 aNewIndexInContainer) { return NS_OK; }
NS_IMETHOD ContentInserted(nsIDocument *aDocument,
nsIContent* aContainer,
nsIContent* aChild,
PRInt32 aIndexInContainer) { return NS_OK; }
NS_IMETHOD ContentReplaced(nsIDocument *aDocument,
nsIContent* aContainer,
nsIContent* aOldChild,
nsIContent* aNewChild,
PRInt32 aIndexInContainer);
NS_IMETHOD ContentRemoved(nsIDocument *aDocument,
nsIContent* aContainer,
nsIContent* aChild,
PRInt32 aIndexInContainer);
NS_IMETHOD StyleSheetAdded(nsIDocument *aDocument,
nsIStyleSheet* aStyleSheet) { return NS_OK; }
NS_IMETHOD StyleSheetRemoved(nsIDocument *aDocument,
nsIStyleSheet* aStyleSheet) { return NS_OK; }
NS_IMETHOD StyleSheetDisabledStateChanged(nsIDocument *aDocument,
nsIStyleSheet* aStyleSheet,
PRBool aDisabled) { return NS_OK; }
NS_IMETHOD StyleRuleChanged(nsIDocument *aDocument,
nsIStyleSheet* aStyleSheet,
nsIStyleRule* aStyleRule,
PRInt32 aHint) { return NS_OK; }
NS_IMETHOD StyleRuleAdded(nsIDocument *aDocument,
nsIStyleSheet* aStyleSheet,
nsIStyleRule* aStyleRule) { return NS_OK; }
NS_IMETHOD StyleRuleRemoved(nsIDocument *aDocument,
nsIStyleSheet* aStyleSheet,
nsIStyleRule* aStyleRule) { return NS_OK; }
NS_IMETHOD DocumentWillBeDestroyed(nsIDocument *aDocument) { return NS_OK; }
protected:
nsGfxScrollFrame();
nsGfxScrollFrame(nsIDocument* aDocument);
virtual PRIntn GetSkipSides() const;
virtual void ScrollbarChanged(nscoord aX, nscoord aY);
private:
void SetAttribute(nsIFrame* aFrame, nsIAtom* aAtom, nscoord aSize);
nsresult CalculateChildTotalSize(nsIFrame* aKidFrame,
nsHTMLReflowMetrics& aKidReflowMetrics);
nsresult GetFrameSize( nsIFrame* aFrame,
nsSize& aSize);
nsresult SetFrameSize( nsIFrame* aFrame,
nsSize aSize);
nsresult CalculateScrollAreaSize(nsIPresContext& aPresContext,
const nsHTMLReflowState& aReflowState,
const nsSize& aSbSize,
nsSize& aScrollAreaSize);
void SetScrollbarVisibility(nsIFrame* aScrollbar, PRBool aVisible);
void DetermineReflowNeed(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus,
PRBool& aHscrollbarNeedsReflow,
PRBool& aVscrollbarNeedsReflow,
PRBool& aScrollAreaNeedsReflow,
nsIFrame*& aIncrementalChild);
void ReflowScrollbars( nsIPresContext& aPresContext,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus,
PRBool& aHscrollbarNeedsReflow,
PRBool& aVscrollbarNeedsReflow,
PRBool& aScrollBarResized,
nsIFrame*& aIncrementalChild);
void ReflowScrollbar( nsIPresContext& aPresContext,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus,
PRBool& aScrollBarResized,
nsIFrame* aScrollBarFrame,
nsIFrame*& aIncrementalChild);
nsresult ReflowFrame( nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus,
nsIFrame* aFrame,
const nsSize& aAvailable,
const nsSize& aComputed,
PRBool& aResized,
nsIFrame*& aIncrementalChild);
void ReflowScrollArea( nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus,
PRBool& aHscrollbarNeedsReflow,
PRBool& aVscrollbarNeedsReflow,
PRBool& aScrollAreaNeedsReflow,
nsIFrame*& aIncrementalChild);
void LayoutChildren(nsIPresContext& aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState);
void GetScrollbarDimensions(nsIPresContext& aPresContext,
nsSize& aSbSize);
void AddRemoveScrollbar (PRBool& aHasScrollbar, nscoord& aSize, nscoord aSbSize, PRBool aAdd);
void AddHorizontalScrollbar (const nsSize& aSbSize, nsSize& aScrollAreaSize);
void AddVerticalScrollbar (const nsSize& aSbSize, nsSize& aScrollAreaSize);
void RemoveHorizontalScrollbar(const nsSize& aSbSize, nsSize& aScrollAreaSize);
void RemoveVerticalScrollbar (const nsSize& aSbSize, nsSize& aScrollAreaSize);
nsIScrollableView* GetScrollableView();
void GetScrolledContentSize(nsSize& aSize);
nsIFrame* mHScrollbarFrame;
nsIFrame* mVScrollbarFrame;
nsIFrame* mScrollAreaFrame;
PRBool mHasVerticalScrollbar;
PRBool mHasHorizontalScrollbar;
nscoord mOnePixel;
friend nsGfxScrollFrameInner;
nsGfxScrollFrameInner* mInner;
};
#endif /* nsScrollFrame_h___ */

View File

@ -36,6 +36,7 @@
#include "nsIWebShell.h"
#include "nsIBox.h"
/*
static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID);
static NS_DEFINE_IID(kWidgetCID, NS_CHILD_CID);
@ -46,6 +47,20 @@ static NS_DEFINE_IID(kIViewIID, NS_IVIEW_IID);
static NS_DEFINE_IID(kScrollViewIID, NS_ISCROLLABLEVIEW_IID);
static NS_DEFINE_IID(kAreaFrameIID, NS_IAREAFRAME_IID);
*/
static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID);
static NS_DEFINE_IID(kWidgetCID, NS_CHILD_CID);
static NS_DEFINE_IID(kScrollPortViewCID, NS_SCROLL_PORT_VIEW_CID);
static NS_DEFINE_IID(kViewCID, NS_VIEW_CID);
static NS_DEFINE_IID(kIViewIID, NS_IVIEW_IID);
static NS_DEFINE_IID(kScrollViewIID, NS_ISCROLLABLEVIEW_IID);
static NS_DEFINE_IID(kAreaFrameIID, NS_IAREAFRAME_IID);
//----------------------------------------------------------------------
nsresult
@ -65,6 +80,8 @@ NS_NewScrollPortFrame(nsIFrame** aNewFrame)
nsScrollPortFrame::nsScrollPortFrame()
{
mIncremental = PR_FALSE;
mNeedsRecalc = PR_TRUE;
}
NS_IMETHODIMP
@ -234,12 +251,16 @@ nsScrollPortFrame::CreateScrollingView(nsIPresContext& aPresContext)
nsIViewManager* viewManager;
parentView->GetViewManager(viewManager);
// Create the scrolling view
nsresult rv = nsComponentManager::CreateInstance(kScrollingViewCID,
nsresult rv = nsComponentManager::CreateInstance(kScrollPortViewCID,
nsnull,
kIViewIID,
(void **)&view);
if (NS_OK == rv) {
@ -381,6 +402,22 @@ nsScrollPortFrame::Reflow(nsIPresContext& aPresContext,
// Reflow the child and get its desired size. Let it be as high as it
// wants
const nsMargin& border = aReflowState.mComputedBorderPadding;
// we only worry about our border. Out scrolled frame worries about the padding.
// so lets remove the padding and add it to our computed size.
nsMargin padding = aReflowState.mComputedPadding;
if (aReflowState.mComputedWidth != NS_INTRINSICSIZE)
((nscoord&)aReflowState.mComputedWidth) += padding.left + padding.right;
if (aReflowState.mComputedHeight != NS_INTRINSICSIZE)
((nscoord&)aReflowState.mComputedHeight) += padding.top + padding.bottom;
((nsMargin&)aReflowState.mComputedPadding) = nsMargin(0,0,0,0);
((nsMargin&)aReflowState.mComputedBorderPadding) -= padding;
nscoord theHeight;
nsIBox* box;
nsresult result = kidFrame->QueryInterface(kIBoxIID, (void**)&box);
@ -394,24 +431,14 @@ nsScrollPortFrame::Reflow(nsIPresContext& aPresContext,
kidFrame, kidReflowSize);
nsHTMLReflowMetrics kidDesiredSize(aDesiredSize.maxElementSize);
/*
if (mIncremental) {
kidReflowState.reason = eReflowReason_Incremental;
mIncremental = PR_FALSE;
}
*/
kidReflowState.mComputedWidth = aReflowState.mComputedWidth;
// if the computed width is not intrinsic make sure we subtract out the child's borders.
// if (kidReflowState.mComputedWidth != NS_INTRINSICSIZE)
// kidReflowState.mComputedWidth -= aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right;
kidReflowState.mComputedHeight = theHeight;
//if (kidReflowState.mComputedHeight != NS_INTRINSICSIZE)
// kidReflowState.mComputedHeight -= aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right;
ReflowChild(kidFrame, aPresContext, kidDesiredSize, kidReflowState,
aStatus);
@ -419,10 +446,9 @@ nsScrollPortFrame::Reflow(nsIPresContext& aPresContext,
NS_ASSERTION(NS_FRAME_IS_COMPLETE(aStatus), "bad status");
CalculateChildTotalSize(kidFrame, kidDesiredSize);
// Place and size the child.
nscoord x = aReflowState.mComputedBorderPadding.left;
nscoord y = aReflowState.mComputedBorderPadding.top;
nscoord x = border.left;
nscoord y = border.top;
// Compute our desired size
if (aReflowState.mComputedWidth == NS_INTRINSICSIZE)
@ -433,7 +459,7 @@ nsScrollPortFrame::Reflow(nsIPresContext& aPresContext,
if (aDesiredSize.width > kidDesiredSize.width)
kidDesiredSize.width = aDesiredSize.width;
aDesiredSize.width += aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right;
aDesiredSize.width += border.left + border.right;
// Compute our desired size
if (aReflowState.mComputedHeight == NS_INTRINSICSIZE)
@ -444,10 +470,12 @@ nsScrollPortFrame::Reflow(nsIPresContext& aPresContext,
if (aDesiredSize.height > kidDesiredSize.height)
kidDesiredSize.height = aDesiredSize.height;
aDesiredSize.height += aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom;
aDesiredSize.height += border.top + border.bottom;
nsRect rect(x, y, kidDesiredSize.width, kidDesiredSize.height);
kidFrame->SetRect(rect);
//printf("width=%d, height=%d\n", kidDesiredSize.width, kidDesiredSize.height);
if (nsnull != aDesiredSize.maxElementSize) {
nscoord maxWidth = aDesiredSize.maxElementSize->width;
@ -461,6 +489,17 @@ nsScrollPortFrame::Reflow(nsIPresContext& aPresContext,
aDesiredSize.ascent = aDesiredSize.height;
aDesiredSize.descent = 0;
/*
if (aReflowState.mComputedWidth != NS_INTRINSICSIZE)
((nscoord&)aReflowState.mComputedWidth) -= (padding.left + padding.right);
if (aReflowState.mComputedHeight != NS_INTRINSICSIZE)
((nscoord&)aReflowState.mComputedHeight) -= (padding.top + padding.bottom);
((nsMargin&)aReflowState.mComputedPadding) = padding;
((nsMargin&)aReflowState.mComputedBorderPadding) += padding;
*/
NS_FRAME_TRACE_MSG(NS_FRAME_TRACE_CALLS,
("exit nsScrollPortFrame::Reflow: status=%d width=%d height=%d",
aStatus, aDesiredSize.width, aDesiredSize.height));
@ -473,7 +512,7 @@ nsScrollPortFrame::Paint(nsIPresContext& aPresContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer)
{
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) {
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) {
// Only paint the border and background if we're visible
const nsStyleDisplay* display = (const nsStyleDisplay*)
mStyleContext->GetStyleData(eStyleStruct_Display);
@ -490,8 +529,10 @@ nsScrollPortFrame::Paint(nsIPresContext& aPresContext,
}
// Paint our children
return nsContainerFrame::Paint(aPresContext, aRenderingContext, aDirtyRect,
nsresult rv = nsContainerFrame::Paint(aPresContext, aRenderingContext, aDirtyRect,
aWhichLayer);
return rv;
}
PRIntn
@ -515,19 +556,119 @@ nsScrollPortFrame::GetFrameName(nsString& aResult) const
return MakeFrameName("Scroll", aResult);
}
/*
/**
* Goes though each child asking for its size to determine our size. Returns our box size minus our border.
* This method is defined in nsIBox interface.
*/
NS_IMETHODIMP
nsScrollPortFrame::GetBoxInfo(nsIPresContext& aPresContext, const nsHTMLReflowState& aReflowState, nsBoxInfo& aSize)
{
nsresult rv;
nsIBox ibox = nsnull;
rv = mScrollAreaFrame->QueryInterface(nsIBox::GetIID(), (void**)&ibox))
ibox->GetBoxInfo(aPresContext, aReflowState, aSize);
NS_ASSERTION(NS_SUCCEEDED(rv),"Scrollport must implement box!!");
nsresult rv;
aSize.clear();
if (mNeedsRecalc) {
nsIFrame* childFrame = mFrames.FirstChild();
// get the size of the child. This is the min, max, preferred, and spring constant
// it does not include its border.
rv = GetChildBoxInfo(aPresContext, aReflowState, childFrame, mSpring);
NS_ASSERTION(rv == NS_OK,"failed to child box info");
if (NS_FAILED(rv))
return rv;
// add in the child's margin and border/padding if there is one.
const nsStyleSpacing* spacing;
rv = childFrame->GetStyleData(eStyleStruct_Spacing,
(const nsStyleStruct*&) spacing);
NS_ASSERTION(rv == NS_OK,"failed to get spacing info");
if (NS_FAILED(rv))
return rv;
nsMargin margin(0,0,0,0);
spacing->GetMargin(margin);
nsSize m(margin.left+margin.right,margin.top+margin.bottom);
mSpring.minSize += m;
mSpring.prefSize += m;
if (mSpring.maxSize.width != NS_INTRINSICSIZE)
mSpring.maxSize.width += m.width;
if (mSpring.maxSize.height != NS_INTRINSICSIZE)
mSpring.maxSize.height += m.height;
spacing->GetBorderPadding(margin);
nsSize b(margin.left+margin.right,margin.top+margin.bottom);
mSpring.minSize += b;
mSpring.prefSize += b;
if (mSpring.maxSize.width != NS_INTRINSICSIZE)
mSpring.maxSize.width += b.width;
if (mSpring.maxSize.height != NS_INTRINSICSIZE)
mSpring.maxSize.height += b.height;
// ok we don't need to calc this guy again
mNeedsRecalc = PR_FALSE;
}
aSize = mSpring;
return rv;
}
nsresult
nsScrollPortFrame::GetChildBoxInfo(nsIPresContext& aPresContext, const nsHTMLReflowState& aReflowState, nsIFrame* aFrame, nsBoxInfo& aSize)
{
aSize.clear();
// see if the frame has IBox interface
// if it does ask it for its BoxSize and we are done
nsIBox* ibox;
if (NS_SUCCEEDED(aFrame->QueryInterface(nsIBox::GetIID(), (void**)&ibox)) && ibox) {
ibox->GetBoxInfo(aPresContext, aReflowState, aSize);
return NS_OK;
}
// start the preferred size as intrinsic
aSize.prefSize.width = NS_INTRINSICSIZE;
aSize.prefSize.height = NS_INTRINSICSIZE;
nsSize kidReflowSize(NS_INTRINSICSIZE, NS_INTRINSICSIZE);
nsHTMLReflowState kidReflowState(aPresContext, aReflowState,
aFrame, kidReflowSize);
nsHTMLReflowMetrics kidDesiredSize(nsnull);
kidReflowState.reason = eReflowReason_Resize;
kidReflowState.mComputedWidth = NS_INTRINSICSIZE;
kidReflowState.mComputedHeight = NS_INTRINSICSIZE;
nsReflowStatus status = NS_FRAME_COMPLETE;
ReflowChild(aFrame, aPresContext, kidDesiredSize, kidReflowState,
status);
NS_ASSERTION(NS_FRAME_IS_COMPLETE(status), "bad status");
const nsStyleSpacing* spacing;
nsresult rv = aFrame->GetStyleData(eStyleStruct_Spacing,
(const nsStyleStruct*&) spacing);
nsMargin border(0,0,0,0);;
spacing->GetBorderPadding(border);
// remove border
kidDesiredSize.width -= (border.left + border.right);
kidDesiredSize.height -= (border.top + border.bottom);
// get the size returned and the it as the preferredsize.
aSize.prefSize.width = kidDesiredSize.width;
aSize.prefSize.height = kidDesiredSize.height;
return NS_OK;
}
NS_IMETHODIMP
nsScrollPortFrame::QueryInterface(REFNSIID aIID, void** aInstancePtr)
@ -550,7 +691,7 @@ nsScrollPortFrame::QueryInterface(REFNSIID aIID, void** aInstancePtr)
NS_IMETHODIMP
nsScrollPortFrame::Dirty(const nsHTMLReflowState& aReflowState, nsIFrame*& incrementalChild)
{
mIncrementalChild = PR_FALSE;
mIncremental = PR_FALSE;
incrementalChild = nsnull;
nsIFrame* frame;
@ -562,28 +703,13 @@ nsScrollPortFrame::Dirty(const nsHTMLReflowState& aReflowState, nsIFrame*& incre
nsIBox* ibox;
if (NS_SUCCEEDED(childFrame->QueryInterface(nsIBox::GetIID(), (void**)&ibox)) && ibox)
ibox->Dirty(aReflowState, incrementalChild);
else
else {
incrementalChild = frame;
// if we found a leaf. Then mark it as being incremental. So when we
// flow it we will flow it incrementally
if (incrementalChild == childFrame)
mIncrementalChild = PR_TRUE;
// if we found a leaf that is not a box. Then mark it as being incremental. So if we are ever
// flowed incremental then we will flow our child incrementally.
mIncremental = PR_TRUE;
}
return NS_OK;
}
NS_IMETHODIMP_(nsrefcnt)
nsScrollPortFrame::AddRef(void)
{
return NS_OK;
}
NS_IMETHODIMP_(nsrefcnt)
nsScrollPortFrame::Release(void)
{
return NS_OK;
}
*/

View File

@ -20,6 +20,7 @@
#define nsScrollPortFrame_h___
#include "nsHTMLContainerFrame.h"
#include "nsIBox.h"
/**
* The scroll frame creates and manages the scrolling view
@ -30,7 +31,7 @@
* Scroll frames don't support incremental changes, i.e. you can't replace
* or remove the scrolled frame
*/
class nsScrollPortFrame : public nsHTMLContainerFrame {
class nsScrollPortFrame : public nsHTMLContainerFrame, public nsIBox {
public:
friend nsresult NS_NewScrollPortFrame(nsIFrame** aNewFrame);
@ -87,6 +88,13 @@ public:
NS_IMETHOD GetFrameName(nsString& aResult) const;
// nsIBox methods
NS_IMETHOD GetBoxInfo(nsIPresContext& aPresContext, const nsHTMLReflowState& aReflowState, nsBoxInfo& aSize);
NS_IMETHOD Dirty(const nsHTMLReflowState& aReflowState, nsIFrame*& aIncrementalChild);
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef(void) { return NS_OK; }
NS_IMETHOD_(nsrefcnt) Release(void) { return NS_OK; }
protected:
nsScrollPortFrame();
virtual PRIntn GetSkipSides() const;
@ -102,6 +110,12 @@ private:
nsresult CalculateChildTotalSize(nsIFrame* aKidFrame,
nsHTMLReflowMetrics& aKidReflowMetrics);
nsresult GetChildBoxInfo(nsIPresContext& aPresContext, const nsHTMLReflowState& aReflowState, nsIFrame* aFrame, nsBoxInfo& aSize);
PRBool mNeedsRecalc;
nsBoxInfo mSpring;
PRBool mIncremental;
};
#endif /* nsScrollPortFrame_h___ */

File diff suppressed because it is too large Load Diff

View File

@ -22,6 +22,7 @@
#include "nslayout.h"
#include "nsIPresContext.h"
#include "nsCOMPtr.h"
#include "nsIStyleContext.h"
class nsIDocument;
struct nsFrameItems;
@ -544,46 +545,43 @@ protected:
nsIFrame* GetFloaterContainingBlock(nsIPresContext* aPresContext,
nsIFrame* aFrame);
nsresult BuildBlockScrollFrame (nsIPresContext* aPresContext,
nsFrameConstructorState& aState,
nsIContent* aContent,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aNewFrame,
PRBool aProcessChildren,
PRBool aIsAbsolutelyPositioned,
PRBool aIsFixedPositioned,
PRBool aCreateBlock);
nsresult BuildBoxScrollFrame (nsIPresContext* aPresContext,
nsFrameConstructorState& aState,
nsIContent* aContent,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aNewFrame,
PRBool aProcessChildren,
PRBool aIsAbsolutelyPositioned,
PRBool aIsFixedPositioned,
PRBool aCreateBlock);
nsresult
BuildScrollFrame (nsIPresContext* aPresContext,
BuildScrollFrame (nsIPresContext* aPresContext,
nsFrameConstructorState& aState,
nsIContent* aContent,
nsIStyleContext* aContentStyle,
nsIFrame* aScrolledFrame,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aNewFrame,
PRBool aProcessChildren,
PRBool aIsAbsolutelyPositioned,
PRBool aIsFixedPositioned,
PRBool aCreateBlock);
nsIStyleContext*& aScrolledChildStyle);
nsresult
BeginBuildingScrollFrame (nsIPresContext* aPresContext,
nsFrameConstructorState& aState,
nsIContent* aContent,
nsIStyleContext* aContentStyle,
nsIFrame* aParentFrame,
nsIAtom* aScrolledPseudo,
nsIDocument* aDocument,
nsIFrame*& aNewFrame,
nsCOMPtr<nsIStyleContext>& aScrolledChildStyle,
nsIFrame*& aScrollableFrame);
nsresult
FinishBuildingScrollFrame(nsIPresContext* aPresContext,
nsFrameConstructorState& aState,
nsIContent* aContent,
nsIFrame* aScrollFrame,
nsIFrame* aScrolledFrame,
nsIStyleContext* scrolledPseudoStyle);
nsresult
BuildGfxScrollFrame (nsIPresContext* aPresContext,
BuildGfxScrollFrame (nsIPresContext* PresContext,
nsFrameConstructorState& aState,
nsIContent* aContent,
nsIDocument* aDocument,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
nsIFrame*& aNewFrame,
@ -591,14 +589,13 @@ BuildGfxScrollFrame (nsIPresContext* aPresContext,
nsresult
InitializeScrollFrame(nsIPresContext* aPresContext,
InitializeSelectFrame(nsIPresContext* aPresContext,
nsFrameConstructorState& aState,
nsIFrame* scrollFrame,
nsIFrame* scrolledFrame,
nsIContent* aContent,
nsIFrame* aParentFrame,
nsIStyleContext* aStyleContext,
PRBool aProcessChildren,
PRBool aIsAbsolutelyPositioned,
PRBool aIsFixedPositioned,
PRBool aCreateBlock);

View File

@ -90,6 +90,11 @@ public:
virtual nsresult MouseMove(nsIDOMEvent* aMouseEvent);
virtual nsresult DragMove(nsIDOMEvent* aMouseEvent) { return NS_OK; }
virtual nsresult HandleEvent(nsIDOMEvent* aEvent) { return NS_OK; }
void DisplayDebugInfoFor(nsIPresContext& aPresContext,
nsPoint& aPoint,
PRInt32& aCursor);
};
/**
@ -116,6 +121,7 @@ public:
void GetDebugInset(nsMargin& inset);
void AdjustChildren(nsIPresContext& aPresContext, nsBoxFrame* aBox);
void UpdatePseudoElements(nsIPresContext& aPresContext);
nsresult GetContentOf(nsIFrame* aFrame, nsIContent** aContent);
// XXX for the moment we can only handle 100 children.
// Should use a dynamic array.
@ -179,7 +185,11 @@ nsBoxFrame::Init(nsIPresContext& aPresContext,
// see if we are a vertical or horizontal box.
nsString value;
mContent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::align, value);
nsCOMPtr<nsIContent> content;
mInner->GetContentOf(this, getter_AddRefs(content));
content->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::align, value);
if (value.EqualsIgnoreCase("vertical"))
mHorizontal = PR_FALSE;
else if (value.EqualsIgnoreCase("horizontal"))
@ -263,7 +273,7 @@ nsBoxFrame::GetRedefinedMinPrefMax(nsIPresContext& aPresContext, nsIFrame* aFra
// get the flexibility
nsCOMPtr<nsIContent> content;
aFrame->GetContent(getter_AddRefs(content));
mInner->GetContentOf(aFrame, getter_AddRefs(content));
PRInt32 error;
nsAutoString value;
@ -272,7 +282,7 @@ nsBoxFrame::GetRedefinedMinPrefMax(nsIPresContext& aPresContext, nsIFrame* aFra
{
value.Trim("%");
// convert to a percent.
aSize.flex = value.ToFloat(&error)/float(100.0);
aSize.flex = value.ToFloat(&error);
}
if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::width, value))
@ -400,7 +410,10 @@ nsBoxFrame::Reflow(nsIPresContext& aPresContext,
mInner->mIsDebug = PR_FALSE;
nsString value;
if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(kNameSpaceID_None, nsXULAtoms::debug, value))
nsCOMPtr<nsIContent> content;
mInner->GetContentOf(this, getter_AddRefs(content));
if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttribute(kNameSpaceID_None, nsXULAtoms::debug, value))
{
mInner->mIsDebug = PR_TRUE;
} else {
@ -679,7 +692,7 @@ nsBoxFrame::FlowChildren(nsIPresContext& aPresContext,
FlowChildAt(childFrame, aPresContext, aDesiredSize, aReflowState, aStatus, mSprings[count], redraw, reason);
// if the child got bigger then adjust our rect and all the children.
ChildResized(aDesiredSize, rect, mSprings[count], resized, changedIndex, finished, count, nextReason);
ChildResized(childFrame, aDesiredSize, rect, mSprings[count], resized, changedIndex, finished, count, nextReason);
}
@ -717,7 +730,7 @@ nsBoxFrame::FlowChildren(nsIPresContext& aPresContext,
}
void
nsBoxFrame::ChildResized(nsHTMLReflowMetrics& aDesiredSize, nsRect& aRect, nsCalculatedBoxInfo& aInfo, PRBool* aResized, nscoord& aChangedIndex, PRBool& aFinished, nscoord aIndex, nsString& aReason)
nsBoxFrame::ChildResized(nsIFrame* aFrame, nsHTMLReflowMetrics& aDesiredSize, nsRect& aRect, nsCalculatedBoxInfo& aInfo, PRBool* aResized, nscoord& aChangedIndex, PRBool& aFinished, nscoord aIndex, nsString& aReason)
{
if (mHorizontal) {
// if we are a horizontal box see if the child will fit inside us.
@ -726,6 +739,7 @@ nsBoxFrame::ChildResized(nsHTMLReflowMetrics& aDesiredSize, nsRect& aRect, nsCal
// ok if the height changed then we need to reflow everyone but us at the new height
// so we will set the changed index to be us. And signal that we need a new pass.
aRect.height = aDesiredSize.height;
// remember we do not need to clear the resized list because changing the height of a horizontal box
@ -745,6 +759,23 @@ nsBoxFrame::ChildResized(nsHTMLReflowMetrics& aDesiredSize, nsRect& aRect, nsCal
// because things flow from left to right top to bottom we know that
// if we get wider that we can set the min size. This will only work
// for width not height. Height must always be recalculated!
// however we must see whether the min size was set in css.
// if it was then this size should not override it.
// add in the css min, max, pref
const nsStylePosition* position;
nsresult rv = aFrame->GetStyleData(eStyleStruct_Position,
(const nsStyleStruct*&) position);
// same for min size. Unfortunately min size is always set to 0. So for now
// we will assume 0 means not set.
if (position->mMinWidth.GetUnit() == eStyleUnit_Coord) {
nscoord min = position->mMinWidth.GetCoordValue();
if (min != 0)
return;
}
aInfo.minSize.width = aDesiredSize.width;
// our width now becomes the new size
@ -770,6 +801,19 @@ nsBoxFrame::ChildResized(nsHTMLReflowMetrics& aDesiredSize, nsRect& aRect, nsCal
// so we will set the changed index to be us. And signal that we need a new pass.
aRect.width = aDesiredSize.width;
// add in the css min, max, pref
const nsStylePosition* position;
nsresult rv = aFrame->GetStyleData(eStyleStruct_Position,
(const nsStyleStruct*&) position);
// same for min size. Unfortunately min size is always set to 0. So for now
// we will assume 0 means not set.
if (position->mMinWidth.GetUnit() == eStyleUnit_Coord) {
nscoord min = position->mMinWidth.GetCoordValue();
if (min != 0)
return;
}
// because things flow from left to right top to bottom we know that
// if we get wider that we can set the min size. This will only work
// for width not height. Height must always be recalculated!
@ -1183,7 +1227,6 @@ nsBoxFrame::AddSize(const nsSize& a, nsSize& b, PRBool largest)
}
void
nsBoxFrame::GetInset(nsMargin& margin)
{
@ -1789,13 +1832,16 @@ nsBoxFrameInner::UpdatePseudoElements(nsIPresContext& aPresContext)
nsCOMPtr<nsIStyleContext> hs;
nsCOMPtr<nsIStyleContext> vs;
nsCOMPtr<nsIContent> content;
GetContentOf(mOuter, getter_AddRefs(content));
nsCOMPtr<nsIAtom> atom ( getter_AddRefs(NS_NewAtom(":-moz-horizontal-box-debug")) );
aPresContext.ProbePseudoStyleContextFor(mOuter->mContent, atom, mOuter->mStyleContext,
aPresContext.ProbePseudoStyleContextFor(content, atom, mOuter->mStyleContext,
PR_FALSE,
getter_AddRefs(hs));
atom = getter_AddRefs(NS_NewAtom(":-moz-vertical-box-debug"));
aPresContext.ProbePseudoStyleContextFor(mOuter->mContent, atom, mOuter->mStyleContext,
aPresContext.ProbePseudoStyleContextFor(content, atom, mOuter->mStyleContext,
PR_FALSE,
getter_AddRefs(vs));
@ -1954,7 +2000,7 @@ void
nsBoxDebugInner::AddListener()
{
nsCOMPtr<nsIContent> content;
mOuter->GetContent(getter_AddRefs(content));
mOuter->mInner->GetContentOf(mOuter, getter_AddRefs(content));
nsCOMPtr<nsIDOMEventReceiver> reciever(do_QueryInterface(content));
@ -1965,17 +2011,223 @@ void
nsBoxDebugInner::RemoveListener()
{
nsCOMPtr<nsIContent> content;
mOuter->GetContent(getter_AddRefs(content));
mOuter->mInner->GetContentOf(mOuter, getter_AddRefs(content));
nsCOMPtr<nsIDOMEventReceiver> reciever(do_QueryInterface(content));
reciever->RemoveEventListenerByIID(NS_STATIC_CAST(nsIDOMMouseMotionListener*,this),kIDOMMouseMotionListenerIID);
}
void
nsBoxDebugInner::DisplayDebugInfoFor(nsIPresContext& aPresContext,
nsPoint& aPoint,
PRInt32& aCursor)
{
nscoord x = aPoint.x;
nscoord y = aPoint.y;
// get it into our coordintate system by subtracting our parents offsets.
nsIFrame* parent = mOuter;
while(parent != nsnull)
{
// if we hit a scrollable view make sure we take into account
// how much we are scrolled.
nsIScrollableView* scrollingView;
nsIView* view;
parent->GetView(&view);
if (view) {
nsresult result = view->QueryInterface(kScrollViewIID, (void**)&scrollingView);
if (NS_SUCCEEDED(result)) {
nscoord xoff = 0;
nscoord yoff = 0;
scrollingView->GetScrollPosition(xoff, yoff);
x += xoff;
y += yoff;
}
}
nsRect r;
parent->GetRect(r);
x -= r.x;
y -= r.y;
parent->GetParent(&parent);
}
nsRect r(0,0,mOuter->mRect.width, mOuter->mRect.height);
if (!r.Contains(nsPoint(x,y)))
return;
int count = 0;
nsIFrame* childFrame = mOuter->mFrames.FirstChild();
while (nsnull != childFrame)
{
nsRect r(0,0,0,0);
childFrame->GetRect(r);
// if we are not in the child. But in the spring above the child.
if (((mOuter->mHorizontal && x >= r.x && x < r.x + r.width && y < r.y) ||
(!mOuter->mHorizontal && y >= r.y && y < r.y + r.height && x < r.x))) {
//printf("y=%d, r.y=%d\n",y,r.y);
aCursor = NS_STYLE_CURSOR_POINTER;
// found it but we already showed it.
if (mDebugChild == childFrame)
return;
nsCOMPtr<nsIContent> content;
mOuter->mInner->GetContentOf(childFrame, getter_AddRefs(content));
nsString id;
content->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::id, id);
char idValue[100];
id.ToCString(idValue,100);
nsString kClass;
content->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::kClass, kClass);
char kClassValue[100];
kClass.ToCString(kClassValue,100);
nsCOMPtr<nsIAtom> tag;
content->GetTag(*getter_AddRefs(tag));
nsString tagString;
tag->ToString(tagString);
char tagValue[100];
tagString.ToCString(tagValue,100);
printf("--------------------\n");
printf("Tag='%s', id='%s' class='%s'\n", tagValue, idValue, kClassValue);
mDebugChild = childFrame;
nsCalculatedBoxInfo aSize;
aSize.prefSize.width = NS_INTRINSICSIZE;
aSize.prefSize.height = NS_INTRINSICSIZE;
aSize.minSize.width = NS_INTRINSICSIZE;
aSize.minSize.height = NS_INTRINSICSIZE;
aSize.maxSize.width = NS_INTRINSICSIZE;
aSize.maxSize.height = NS_INTRINSICSIZE;
aSize.calculatedSize.width = NS_INTRINSICSIZE;
aSize.calculatedSize.height = NS_INTRINSICSIZE;
aSize.flex = -1.0;
// add in the css min, max, pref
const nsStylePosition* position;
nsresult rv = childFrame->GetStyleData(eStyleStruct_Position,
(const nsStyleStruct*&) position);
// see if the width or height was specifically set
if (position->mWidth.GetUnit() == eStyleUnit_Coord) {
aSize.prefSize.width = position->mWidth.GetCoordValue();
}
if (position->mHeight.GetUnit() == eStyleUnit_Coord) {
aSize.prefSize.height = position->mHeight.GetCoordValue();
}
// same for min size. Unfortunately min size is always set to 0. So for now
// we will assume 0 means not set.
if (position->mMinWidth.GetUnit() == eStyleUnit_Coord) {
nscoord min = position->mMinWidth.GetCoordValue();
if (min != 0)
aSize.minSize.width = min;
}
if (position->mMinHeight.GetUnit() == eStyleUnit_Coord) {
nscoord min = position->mMinHeight.GetCoordValue();
if (min != 0)
aSize.minSize.height = min;
}
// and max
if (position->mMaxWidth.GetUnit() == eStyleUnit_Coord) {
nscoord max = position->mMaxWidth.GetCoordValue();
aSize.maxSize.width = max;
}
if (position->mMaxHeight.GetUnit() == eStyleUnit_Coord) {
nscoord max = position->mMaxHeight.GetCoordValue();
aSize.maxSize.height = max;
}
PRInt32 error;
nsAutoString value;
if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttribute(kNameSpaceID_None, nsXULAtoms::flex, value))
{
value.Trim("%");
aSize.flex = value.ToFloat(&error);
}
if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::width, value))
{
float p2t;
aPresContext.GetScaledPixelsToTwips(&p2t);
value.Trim("%");
aSize.prefSize.width = NSIntPixelsToTwips(value.ToInteger(&error), p2t);
}
if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::height, value))
{
float p2t;
aPresContext.GetScaledPixelsToTwips(&p2t);
value.Trim("%");
aSize.prefSize.height = NSIntPixelsToTwips(value.ToInteger(&error), p2t);
}
char min[100];
char pref[100];
char max[100];
char calc[100];
char flex[100];
GetValue(mOuter->mSprings[count].minSize, aSize.minSize, min);
GetValue(mOuter->mSprings[count].prefSize, aSize.prefSize, pref);
GetValue(mOuter->mSprings[count].maxSize, aSize.maxSize, max);
GetValue(mOuter->mSprings[count].calculatedSize, aSize.calculatedSize, calc);
GetValue(mOuter->mSprings[count].flex, aSize.flex, flex);
printf("min%s, pref%s, max%s, actual%s, flex=%s\n",
min,
pref,
max,
calc,
flex
);
break;
}
nsresult rv = childFrame->GetNextSibling(&childFrame);
NS_ASSERTION(rv == NS_OK,"failed to get next child");
count++;
}
}
NS_IMETHODIMP
nsBoxFrame::GetCursor(nsIPresContext& aPresContext,
nsPoint& aPoint,
PRInt32& aCursor)
{
nsresult rv = nsHTMLContainerFrame::GetCursor(aPresContext, aPoint, aCursor);
if (mInner->mDebugInner)
mInner->mDebugInner->DisplayDebugInfoFor(aPresContext, aPoint, aCursor);
return rv;
}
nsresult
nsBoxDebugInner::MouseMove(nsIDOMEvent* aMouseEvent)
{
/*
nsCOMPtr<nsIDOMUIEvent> uiEvent(do_QueryInterface(aMouseEvent));
PRInt32 xPx = 0;
@ -2030,7 +2282,7 @@ nsBoxDebugInner::MouseMove(nsIDOMEvent* aMouseEvent)
return NS_OK;
nsCOMPtr<nsIContent> content;
childFrame->GetContent(getter_AddRefs(content));
mOuter->mInner->GetContentOf(childFrame, getter_AddRefs(content));
nsString id;
content->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::id, id);
@ -2160,8 +2412,25 @@ nsBoxDebugInner::MouseMove(nsIDOMEvent* aMouseEvent)
}
// mDebugChild = nsnull;
*/
return NS_OK;
}
nsresult
nsBoxFrameInner::GetContentOf(nsIFrame* aFrame, nsIContent** aContent)
{
// If we don't have a content node find a parent that does.
while(aFrame != nsnull) {
aFrame->GetContent(aContent);
if (*aContent != nsnull)
return NS_OK;
aFrame->GetParent(&aFrame);
}
NS_ERROR("Can't find a parent with a content node");
return NS_OK;
}

View File

@ -66,6 +66,12 @@ public:
NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint,
nsIFrame** aFrame);
NS_IMETHOD GetCursor(nsIPresContext& aPresContext,
nsPoint& aPoint,
PRInt32& aCursor);
// nsIBox methods
NS_IMETHOD GetBoxInfo(nsIPresContext& aPresContext, const nsHTMLReflowState& aReflowState, nsBoxInfo& aSize);
NS_IMETHOD Dirty(const nsHTMLReflowState& aReflowState, nsIFrame*& aIncrementalChild);
@ -153,7 +159,7 @@ protected:
nsString& aReason);
virtual nsresult PlaceChildren(nsIPresContext& aPresContext, nsRect& boxRect);
virtual void ChildResized(nsHTMLReflowMetrics& aDesiredSize, nsRect& aRect, nsCalculatedBoxInfo& aInfo, PRBool* aResized, nscoord& aChangedIndex, PRBool& aFinished, nscoord aIndex, nsString& aReason);
virtual void ChildResized(nsIFrame* aFrame, nsHTMLReflowMetrics& aDesiredSize, nsRect& aRect, nsCalculatedBoxInfo& aInfo, PRBool* aResized, nscoord& aChangedIndex, PRBool& aFinished, nscoord aIndex, nsString& aReason);
virtual void LayoutChildrenInRect(nsRect& size);
virtual void AddChildSize(nsBoxInfo& aInfo, nsBoxInfo& aChildInfo);
virtual void BoundsCheck(const nsBoxInfo& aBoxInfo, nsRect& aRect);

View File

@ -296,7 +296,7 @@ nsDeckFrame::PlaceChildren(nsIPresContext& aPresContext, nsRect& boxRect)
}
void
nsDeckFrame::ChildResized(nsHTMLReflowMetrics& aDesiredSize, nsRect& aRect, nsCalculatedBoxInfo& aInfo, PRBool* aResized, nscoord& aChangedIndex, PRBool& aFinished, nscoord aIndex, nsString& aReason)
nsDeckFrame::ChildResized(nsIFrame* aFrame, nsHTMLReflowMetrics& aDesiredSize, nsRect& aRect, nsCalculatedBoxInfo& aInfo, PRBool* aResized, nscoord& aChangedIndex, PRBool& aFinished, nscoord aIndex, nsString& aReason)
{
if (aDesiredSize.width > aRect.width) {
aRect.width = aDesiredSize.width;

View File

@ -70,7 +70,7 @@ protected:
virtual nsIFrame* GetSelectedFrame();
virtual nsresult PlaceChildren(nsIPresContext& aPresContext, nsRect& boxRect);
virtual void ChildResized(nsHTMLReflowMetrics& aDesiredSize, nsRect& aRect, nsCalculatedBoxInfo& aInfo, PRBool* aResized, nscoord& aChangedIndex, PRBool& aFinished, nscoord aIndex, nsString& aReason);
virtual void ChildResized(nsIFrame* aFrame, nsHTMLReflowMetrics& aDesiredSize, nsRect& aRect, nsCalculatedBoxInfo& aInfo, PRBool* aResized, nscoord& aChangedIndex, PRBool& aFinished, nscoord aIndex, nsString& aReason);
virtual void LayoutChildrenInRect(nsRect& size);
virtual void AddChildSize(nsBoxInfo& aInfo, nsBoxInfo& aChildInfo);

View File

@ -42,6 +42,7 @@
#include "nsIStyleRule.h"
#include "nsHTMLValue.h"
#include "nsIAnonymousContent.h"
#include "nsIView.h"
static NS_DEFINE_IID(kIAnonymousContentCreatorIID, NS_IANONYMOUS_CONTENT_CREATOR_IID);
static NS_DEFINE_IID(kIStyledContentIID, NS_ISTYLEDCONTENT_IID);
@ -211,21 +212,14 @@ AnonymousElement::QueryInterface(REFNSIID aIID, void** aInstancePtr)
nsresult NS_CreateAnonymousNode(nsIContent* aParent, nsIAtom* aTag, PRInt32 aNameSpaceId, nsCOMPtr<nsIContent>& aNewNode)
{
// get the document
nsCOMPtr<nsIDocument> document;
aParent->GetDocument(*getter_AddRefs(document));
// create the xml element
nsCOMPtr<nsIXMLContent> content;
//NS_NewXMLElement(getter_AddRefs(content), aTag);
content = new AnonymousElement(aTag);
content->SetNameSpaceID(aNameSpaceId);
// set the document
content->SetDocument(document, PR_TRUE);
aNewNode = content;
/*
@ -283,7 +277,7 @@ nsScrollbarFrame::CreateAnonymousContent(nsISupportsArray& aAnonymousChildren)
aAnonymousChildren.AppendElement(content);
NS_CreateAnonymousNode(mContent, nsXULAtoms::slider, nsXULAtoms::nameSpaceID, content);
content->SetAttribute(kNameSpaceID_None, nsXULAtoms::flex, "100%", PR_FALSE);
content->SetAttribute(kNameSpaceID_None, nsXULAtoms::flex, "1", PR_FALSE);
aAnonymousChildren.AppendElement(content);
NS_CreateAnonymousNode(mContent, nsXULAtoms::scrollbarbutton, nsXULAtoms::nameSpaceID, content);
@ -296,6 +290,21 @@ nsScrollbarFrame::CreateAnonymousContent(nsISupportsArray& aAnonymousChildren)
}
NS_IMETHODIMP
nsScrollbarFrame::Init(nsIPresContext& aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
nsIStyleContext* aContext,
nsIFrame* aPrevInFlow)
{
nsresult rv = nsBoxFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
CreateViewForFrame(aPresContext,this,aContext,PR_TRUE);
nsIView* view;
GetView(&view);
view->SetContentTransparency(PR_TRUE);
return rv;
}
NS_IMETHODIMP
nsScrollbarFrame::AttributeChanged(nsIPresContext* aPresContext,

View File

@ -71,6 +71,11 @@ public:
nsGUIEvent * aEvent,
nsEventStatus& aEventStatus);
NS_IMETHOD Init(nsIPresContext& aPresContext,
nsIContent* aContent,
nsIFrame* aParent,
nsIStyleContext* aContext,
nsIFrame* aPrevInFlow);
}; // class nsScrollbarFrame

View File

@ -55,6 +55,8 @@
#include "nsIScrollableView.h"
#include "nsRepeatService.h"
#define DEBUG_SLIDER PR_FALSE
nscoord nsSliderFrame::gChange = 0;
static NS_DEFINE_IID(kIAnonymousContentCreatorIID, NS_IANONYMOUS_CONTENT_CREATOR_IID);
@ -190,7 +192,28 @@ nsSliderFrame::AttributeChanged(nsIPresContext* aPresContext,
// if the current position changes
if (aAttribute == nsXULAtoms::curpos) {
CurrentPositionChanged(aPresContext);
} else if ((aHint != NS_STYLE_HINT_REFLOW) &&
} else if (aAttribute == nsXULAtoms::maxpos) {
// bounds check it.
nsIContent* scrollbar = GetScrollBar();
PRInt32 current = GetCurrentPosition(scrollbar);
PRInt32 max = GetMaxPosition(scrollbar);
if (current < 0 || current > max)
{
if (current < 0)
current = 0;
else if (current > max)
current = max;
char ch[100];
sprintf(ch,"%d", current);
// set the new position but don't notify anyone. We already know
scrollbar->SetAttribute(kNameSpaceID_None, nsXULAtoms::curpos, nsString(ch), PR_FALSE);
}
}
if ((aHint != NS_STYLE_HINT_REFLOW) &&
(aAttribute == nsXULAtoms::maxpos ||
aAttribute == nsXULAtoms::pageincrement ||
aAttribute == nsXULAtoms::increment)) {
@ -202,6 +225,7 @@ nsSliderFrame::AttributeChanged(nsIPresContext* aPresContext,
nsIReflowCommand::StyleChanged);
if (NS_SUCCEEDED(rv))
shell->AppendReflowCommand(reflowCmd);
}
return rv;
@ -410,6 +434,12 @@ nsSliderFrame::Reflow(nsIPresContext& aPresContext,
aDesiredSize.ascent = aDesiredSize.height;
aDesiredSize.descent = 0;
if (DEBUG_SLIDER) {
PRInt32 c = GetCurrentPosition(scrollbar);
PRInt32 m = GetMaxPosition(scrollbar);
printf("Current=%d, max=%d\n",c,m);
}
return NS_OK;
}
@ -485,6 +515,7 @@ nsSliderFrame::HandleEvent(nsIPresContext& aPresContext,
// set it
SetCurrentPosition(scrollbar, thumbFrame, pospx);
//CurrentPositionChanged(&aPresContext);
}
break;
@ -554,6 +585,10 @@ nsSliderFrame::CurrentPositionChanged(nsIPresContext* aPresContext)
// get the current position
PRInt32 curpos = GetCurrentPosition(scrollbar);
// do nothing if the position did not change
if (mCurPos == curpos)
return;
// get our current position and max position from our content node
PRInt32 maxpos = GetMaxPosition(scrollbar);
@ -627,7 +662,8 @@ nsSliderFrame::SetCurrentPosition(nsIContent* scrollbar, nsIFrame* aThumbFrame,
// set the new position
scrollbar->SetAttribute(kNameSpaceID_None, nsXULAtoms::curpos, nsString(ch), PR_TRUE);
// printf("Current Pos=%s\n",ch);
if (DEBUG_SLIDER)
printf("Current Pos=%s\n",ch);
}

View File

@ -382,6 +382,7 @@ nsTitledButtonFrame::UpdateImage(nsIPresContext& aPresContext)
mImageLoader.UpdateURLSpec(&aPresContext, src);
//PRUint32 loadStatus = mImageLoader.GetLoadStatus();
/*
// if the image is the same size only redraw otherwise reflow
PRBool reflow = PR_TRUE;
@ -412,6 +413,7 @@ nsTitledButtonFrame::UpdateImage(nsIPresContext& aPresContext)
}
}
}
*/
}
}

View File

@ -122,7 +122,9 @@ pref("browser.PICS.reenable_for_this_session", false);
pref("browser.PICS.service.http___home_netscape_com_default_rating.service_enabled", true);
pref("browser.PICS.service.http___home_netscape_com_default_rating.s", 0);
// gfx widgets
pref("nglayout.widget.mode", 2);
pref("nglayout.widget.gfxscrollbars", false);
// Smart Browsing prefs
pref("browser.related.enabled", true);

View File

@ -35,4 +35,8 @@
{ 0xc95f1833, 0xc376, 0x11d1, \
{0xb7, 0x21, 0x0, 0x60, 0x8, 0x91, 0xd8, 0xc9}}
#define NS_SCROLL_PORT_VIEW_CID \
{ 0x3b733c91, 0x7223, 0x11d3, \
{ 0xb3, 0x61, 0x0, 0xa0, 0xcc, 0x3c, 0x1c, 0xde }}
#endif // nsViewsCID_h__

View File

@ -28,6 +28,7 @@ DEFINES =-D_IMPL_NS_VIEW -DWIN32_LEAN_AND_MEAN
OBJS = \
.\$(OBJDIR)\nsView.obj \
.\$(OBJDIR)\nsScrollPortView.obj \
.\$(OBJDIR)\nsScrollingView.obj \
.\$(OBJDIR)\nsViewManager.obj \
.\$(OBJDIR)\nsViewFactory.obj \

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,135 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsScrollPortView_h___
#define nsScrollPortView_h___
#include "nsView.h"
#include "nsIScrollableView.h"
class nsISupportsArray;
//this is a class that acts as a container for other views and provides
//automatic management of scrolling of the views it contains.
class nsScrollPortView : public nsView, public nsIScrollableView //, public nsITimerCallback
{
public:
nsScrollPortView();
NS_IMETHOD QueryInterface(REFNSIID aIID,
void** aInstancePtr);
//overrides
NS_IMETHOD Init(nsIViewManager* aManager,
const nsRect &aBounds,
const nsIView *aParent,
const nsViewClip *aClip = nsnull,
nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow);
NS_IMETHOD SetDimensions(nscoord width, nscoord height, PRBool aPaint = PR_TRUE);
NS_IMETHOD SetPosition(nscoord aX, nscoord aY);
// SetVisibility is overriden so that it will set it's components visibility (ClipView,
// CornerView, ScrollBarView's),as well as it's own visibility.
NS_IMETHOD SetVisibility(nsViewVisibility visibility);
NS_IMETHOD SetWidget(nsIWidget *aWidget);
//nsIScrollableView interface
NS_IMETHOD CreateScrollControls(nsNativeWidget aNative = nsnull);
NS_IMETHOD ComputeScrollOffsets(PRBool aAdjustWidgets = PR_TRUE);
NS_IMETHOD GetContainerSize(nscoord *aWidth, nscoord *aHeight) const;
NS_IMETHOD SetScrolledView(nsIView *aScrolledView);
NS_IMETHOD GetScrolledView(nsIView *&aScrolledView) const;
NS_IMETHOD ShowQuality(PRBool aShow);
NS_IMETHOD GetShowQuality(PRBool &aShow) const;
NS_IMETHOD SetQuality(nsContentQuality aQuality);
NS_IMETHOD SetScrollPreference(nsScrollPreference aPref);
NS_IMETHOD GetScrollPreference(nsScrollPreference &aScrollPreference) const;
NS_IMETHOD GetScrollPosition(nscoord &aX, nscoord &aY) const;
NS_IMETHOD ScrollTo(nscoord aX, nscoord aY, PRUint32 aUpdateFlags);
NS_IMETHOD SetControlInsets(const nsMargin &aInsets);
NS_IMETHOD GetControlInsets(nsMargin &aInsets) const;
NS_IMETHOD GetScrollbarVisibility(PRBool *aVerticalVisible,
PRBool *aHorizontalVisible) const;
NS_IMETHOD SetScrollProperties(PRUint32 aProperties);
NS_IMETHOD GetScrollProperties(PRUint32 *aProperties);
NS_IMETHOD SetLineHeight(nscoord aHeight);
NS_IMETHOD GetLineHeight(nscoord *aHeight);
NS_IMETHOD ScrollByLines(PRInt32 aNumLines);
NS_IMETHOD ScrollByPages(PRInt32 aNumPages);
NS_IMETHOD ScrollByWhole(PRBool aTop);
NS_IMETHOD GetClipView(const nsIView** aClipView) const;
NS_IMETHOD AddScrollPositionListener(nsIScrollPositionListener* aListener);
NS_IMETHOD RemoveScrollPositionListener(nsIScrollPositionListener* aListener);
//locals
//void HandleScrollEvent(nsGUIEvent *aEvent, PRUint32 aEventFlags);
// Set the visibility of a nsScrollPortView's component
// @param aView nsScrollPortView component to set visibility for or nsnull.
// @param aViewVisibility new setting for the component view If not the same as the current setting
// @returns the result of calling the SetVisibility on the component.
//nsresult SetComponentVisibility(nsIView* aView, nsViewVisibility aViewVisibility);
// Update the visibility of the nsScrollPortView's components (ClipView, CornerView, ScrollBarView's)
// @param aScrollingViewVisibility Visibility setting of the ScrollingView to consider when
// setting the visibility of the components. If aScrollingViewVisibility == nsViewVisibility_kInherit then
// UpdateComponent has no effect.
// @returns the result of calling SetComponentVisibility for each component.
//nsresult UpdateComponentVisibility(nsViewVisibility aScrollingViewVisibility);
NS_IMETHOD Paint(nsIRenderingContext& rc, const nsRect& rect,
PRUint32 aPaintFlags, PRBool &Result);
private:
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);
protected:
virtual ~nsScrollPortView();
// nsITimerCallback Interface
//virtual void Notify(nsITimer *timer);
//private
void AdjustChildWidgets(nsScrollPortView *aScrolling, nsIView *aView, nscoord aDx, nscoord aDy, float aScale);
//void UpdateScrollControls(PRBool aPaint);
void Scroll(nsIView *aScrolledView, PRInt32 aDx, PRInt32 aDy, float scale, PRUint32 aUpdateFlags);
PRBool CannotBitBlt(nsIView* aScrolledView);
protected:
//nscoord mSizeX, mSizeY;
nscoord mOffsetX, mOffsetY;
nscoord mOffsetXpx, mOffsetYpx;
//nsIView *mClipView;
//nsIView *mVScrollBarView;
//nsIView *mHScrollBarView;
//nsIView *mCornerView;
//nsScrollPreference mScrollPref;
//nsMargin mInsets;
//nsITimer *mScrollingTimer;
//nscoord mScrollingDelta;
PRUint32 mScrollProperties;
nscoord mLineHeight;
nsISupportsArray *mListeners;
};
#endif

View File

@ -26,12 +26,14 @@
#include "nsView.h"
#include "nsViewManager.h"
#include "nsScrollingView.h"
#include "nsScrollPortView.h"
#include "nsIModule.h"
static NS_DEFINE_CID(kCViewManager, NS_VIEW_MANAGER_CID);
static NS_DEFINE_CID(kCView, NS_VIEW_CID);
static NS_DEFINE_CID(kCScrollingView, NS_SCROLLING_VIEW_CID);
static NS_DEFINE_IID(kCScrollPortView, NS_SCROLL_PORT_VIEW_CID);
static NS_DEFINE_CID(kCComponentManager, NS_COMPONENTMANAGER_CID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
@ -85,7 +87,10 @@ nsresult nsViewFactory::CreateInstance(nsISupports *aOuter,
view = new nsView();
} else if (mClassID.Equals(kCScrollingView)) {
view = new nsScrollingView();
} else if (mClassID.Equals(kCScrollPortView)) {
view = new nsScrollPortView();
}
if (nsnull == view)
return NS_ERROR_OUT_OF_MEMORY;
rv = view->QueryInterface(aIID, aResult);
@ -129,7 +134,7 @@ NSGetFactory(nsISupports* serviceMgr,
rv = NS_NewGenericFactory(&factory, &nsViewManagerConstructor);
if (NS_SUCCEEDED(rv))
*aFactory = factory;
} else if (aClass.Equals(kCView) || aClass.Equals(kCScrollingView)) {
} else if (aClass.Equals(kCView) || aClass.Equals(kCScrollingView) || aClass.Equals(kCScrollPortView)) {
nsViewFactory* factory = new nsViewFactory(aClass);
if (nsnull == factory) {
rv = NS_ERROR_OUT_OF_MEMORY;
@ -262,7 +267,7 @@ nsViewModule::GetClassObject(nsIComponentManager *aCompMgr, const nsCID & aClass
rv = factory->QueryInterface(aIID, aFactory);
}
}
else if (aClass.Equals(kCView) || aClass.Equals(kCScrollingView))
else if (aClass.Equals(kCView) || aClass.Equals(kCScrollingView) || aClass.Equals(kCScrollPortView))
{
rv = NS_ERROR_OUT_OF_MEMORY;
nsViewFactory* factory = new nsViewFactory(aClass);
@ -300,6 +305,10 @@ nsViewModule::RegisterSelf(nsIComponentManager *aCompMgr,
rv = aCompMgr->RegisterComponentSpec(kCScrollingView, "Scrolling View",
"component://netscape/scrolling-view",
location, PR_TRUE, PR_TRUE);
if (NS_FAILED(rv)) return rv;
rv = aCompMgr->RegisterComponentSpec(kCScrollPortView, "Scroll Port View",
"component://netscape/scroll-port-view",
location, PR_TRUE, PR_TRUE);
#ifdef DEBUG_dp
printf("done.\n");
#endif
@ -317,6 +326,8 @@ nsViewModule::UnregisterSelf(nsIComponentManager *aCompMgr,
rv = aCompMgr->UnregisterComponentSpec(kCView, location);
if (NS_FAILED(rv)) return rv;
rv = aCompMgr->UnregisterComponentSpec(kCScrollingView, location);
if (NS_FAILED(rv)) return rv;
rv = aCompMgr->UnregisterComponentSpec(kCScrollPortView, location);
return rv;
}

View File

@ -1432,16 +1432,24 @@ NS_IMETHODIMP nsViewManager :: UpdateView(nsIView *aView, const nsRect &aRect, P
// XXX Consolidate this code with the code above...
// if (aView != widgetView)
// {
do
{
// first our position
par->GetPosition(&x, &y);
trect.x += x;
trect.y += y;
// go up parent chain until we hit the widgetView.
// make sure we include the widget view in the calculation
while ((nsnull != par) && (par != widgetView))
{
par->GetParent(par);
if (par == nsnull)
break;
par->GetPosition(&x, &y);
trect.x += x;
trect.y += y;
if (par != widgetView)
par->GetParent(par);
}
while ((nsnull != par) && (par != widgetView));
}
// }
// Add this rect to the widgetView's dirty region.

View File

@ -146,6 +146,7 @@ static NS_DEFINE_CID(kCDeviceContextSpecFactoryCID, NS_DEVICE_CONTEXT_SPEC_FACTO
static NS_DEFINE_IID(kCViewManagerCID, NS_VIEW_MANAGER_CID);
static NS_DEFINE_IID(kCViewCID, NS_VIEW_CID);
static NS_DEFINE_IID(kCScrollingViewCID, NS_SCROLLING_VIEW_CID);
static NS_DEFINE_IID(kCScrollPortViewCID, NS_SCROLL_PORT_VIEW_CID);
// WEB
static NS_DEFINE_IID(kCWebShellCID, NS_WEB_SHELL_CID);
@ -332,6 +333,7 @@ NS_SetupRegistry()
nsComponentManager::RegisterComponentLib(kCViewManagerCID, NULL, NULL, VIEW_DLL, PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponentLib(kCViewCID, NULL, NULL, VIEW_DLL, PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponentLib(kCScrollingViewCID, NULL, NULL, VIEW_DLL, PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponentLib(kCScrollPortViewCID, NULL, NULL, VIEW_DLL, PR_FALSE, PR_FALSE);
// WEB
nsComponentManager::RegisterComponentLib(kCWebShellCID, NULL, NULL, WEB_DLL, PR_FALSE, PR_FALSE);