1999-12-05 02:49:50 +03:00
|
|
|
|
1998-07-16 03:42:14 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The contents of this file are subject to the Netscape 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/NPL/
|
1998-07-16 03:42:14 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03: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.
|
1998-07-16 03:42:14 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
1998-07-16 03:42:14 +04:00
|
|
|
* Communications Corporation. Portions created by Netscape are
|
1999-11-06 06:40:37 +03:00
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
1998-07-16 03:42:14 +04:00
|
|
|
*/
|
1999-02-12 20:45:58 +03:00
|
|
|
#include "nsCOMPtr.h"
|
1998-09-10 21:23:31 +04:00
|
|
|
#include "nsFrameSetFrame.h"
|
1998-09-25 01:37:45 +04:00
|
|
|
#include "nsIHTMLContent.h"
|
1998-07-16 03:42:14 +04:00
|
|
|
#include "nsLeafFrame.h"
|
|
|
|
#include "nsHTMLContainerFrame.h"
|
|
|
|
#include "nsIPresContext.h"
|
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsHTMLIIDs.h"
|
1999-03-09 12:44:27 +03:00
|
|
|
#include "nsIComponentManager.h"
|
1998-07-16 03:42:14 +04:00
|
|
|
#include "nsIStreamListener.h"
|
|
|
|
#include "nsIURL.h"
|
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsIView.h"
|
|
|
|
#include "nsIViewManager.h"
|
|
|
|
#include "nsWidgetsCID.h"
|
|
|
|
#include "nsViewsCID.h"
|
|
|
|
#include "nsHTMLAtoms.h"
|
|
|
|
#include "nsIScrollableView.h"
|
|
|
|
#include "nsStyleCoord.h"
|
1998-09-10 03:30:30 +04:00
|
|
|
#include "nsStyleConsts.h"
|
1998-07-16 03:42:14 +04:00
|
|
|
#include "nsIStyleContext.h"
|
|
|
|
#include "nsIDocumentLoader.h"
|
1998-09-13 06:45:07 +04:00
|
|
|
#include "nsHTMLParts.h"
|
1998-12-04 21:05:30 +03:00
|
|
|
#include "nsILookAndFeel.h"
|
|
|
|
#include "nsWidgetsCID.h"
|
1999-03-09 12:44:27 +03:00
|
|
|
#include "nsIComponentManager.h"
|
2001-07-16 06:40:48 +04:00
|
|
|
#include "nsGUIEvent.h"
|
|
|
|
#include "nsIRenderingContext.h"
|
2001-11-02 05:19:49 +03:00
|
|
|
#include "nsIPrefService.h"
|
|
|
|
#include "nsIPrefBranch.h"
|
|
|
|
#include "nsIPrefBranchInternal.h"
|
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsIDOMMutationEvent.h"
|
|
|
|
#include "nsINameSpaceManager.h"
|
2001-07-16 06:40:48 +04:00
|
|
|
|
1998-07-31 01:25:35 +04:00
|
|
|
// masks for mEdgeVisibility
|
1998-09-03 05:16:27 +04:00
|
|
|
#define LEFT_VIS 0x0001
|
|
|
|
#define RIGHT_VIS 0x0002
|
|
|
|
#define TOP_VIS 0x0004
|
|
|
|
#define BOTTOM_VIS 0x0008
|
|
|
|
#define ALL_VIS 0x000F
|
|
|
|
#define NONE_VIS 0x0000
|
|
|
|
|
2002-04-05 09:42:10 +04:00
|
|
|
static NS_DEFINE_IID(kIFramesetFrameIID, NS_IFRAMESETFRAME_IID);
|
1998-12-04 21:05:30 +03:00
|
|
|
static NS_DEFINE_IID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
|
1998-07-16 03:42:14 +04:00
|
|
|
|
1999-03-10 09:13:35 +03:00
|
|
|
/*******************************************************************************
|
|
|
|
* nsFramesetDrag
|
|
|
|
******************************************************************************/
|
|
|
|
nsFramesetDrag::nsFramesetDrag()
|
|
|
|
{
|
|
|
|
UnSet();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsFramesetDrag::nsFramesetDrag(PRBool aVertical,
|
|
|
|
PRInt32 aIndex,
|
|
|
|
PRInt32 aChange,
|
|
|
|
nsHTMLFramesetFrame* aSource)
|
|
|
|
{
|
|
|
|
mVertical = aVertical;
|
|
|
|
mIndex = aIndex;
|
|
|
|
mChange = aChange;
|
|
|
|
mSource = aSource;
|
|
|
|
}
|
|
|
|
void nsFramesetDrag::Reset(PRBool aVertical,
|
|
|
|
PRInt32 aIndex,
|
|
|
|
PRInt32 aChange,
|
|
|
|
nsHTMLFramesetFrame* aSource)
|
|
|
|
{
|
|
|
|
mVertical = aVertical;
|
|
|
|
mIndex = aIndex;
|
|
|
|
mChange = aChange;
|
|
|
|
mSource = aSource;
|
|
|
|
mActive = PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsFramesetDrag::UnSet()
|
|
|
|
{
|
|
|
|
mVertical = PR_TRUE;
|
|
|
|
mIndex = -1;
|
|
|
|
mChange = 0;
|
|
|
|
mSource = nsnull;
|
|
|
|
mActive = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
1998-07-27 09:59:37 +04:00
|
|
|
/*******************************************************************************
|
|
|
|
* nsHTMLFramesetBorderFrame
|
|
|
|
******************************************************************************/
|
|
|
|
class nsHTMLFramesetBorderFrame : public nsLeafFrame {
|
|
|
|
|
|
|
|
public:
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef DEBUG
|
2001-11-14 04:33:42 +03:00
|
|
|
NS_IMETHOD GetFrameName(nsAString& aResult) const;
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|
1998-07-27 09:59:37 +04:00
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_IMETHOD HandleEvent(nsIPresContext* aPresContext,
|
1998-07-31 01:25:35 +04:00
|
|
|
nsGUIEvent* aEvent,
|
1999-11-24 09:03:41 +03:00
|
|
|
nsEventStatus* aEventStatus);
|
1998-07-31 01:25:35 +04:00
|
|
|
|
1999-10-26 08:44:41 +04:00
|
|
|
NS_IMETHOD GetFrameForPoint(nsIPresContext* aPresContext,
|
|
|
|
const nsPoint& aPoint,
|
2000-03-22 05:43:08 +03:00
|
|
|
nsFramePaintLayer aWhichLayer,
|
1998-11-18 08:25:26 +03:00
|
|
|
nsIFrame** aFrame);
|
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_IMETHOD GetCursor(nsIPresContext* aPresContext,
|
1998-11-18 08:25:26 +03:00
|
|
|
nsPoint& aPoint,
|
|
|
|
PRInt32& aCursor);
|
|
|
|
|
2001-09-19 16:35:19 +04:00
|
|
|
NS_IMETHOD Paint(nsIPresContext* aPresContext,
|
1998-07-27 09:59:37 +04:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
2001-09-19 16:35:19 +04:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
PRUint32 aFlags);
|
1998-07-27 09:59:37 +04:00
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus);
|
1998-07-27 09:59:37 +04:00
|
|
|
|
2001-11-02 05:19:49 +03:00
|
|
|
PRBool GetVisibility() { return mVisibility || mVisibilityOverride; }
|
1998-07-31 01:25:35 +04:00
|
|
|
void SetVisibility(PRBool aVisibility);
|
1998-09-03 05:16:27 +04:00
|
|
|
void SetColor(nscolor aColor);
|
1998-07-31 01:25:35 +04:00
|
|
|
|
1998-07-27 09:59:37 +04:00
|
|
|
protected:
|
1998-12-03 09:31:43 +03:00
|
|
|
nsHTMLFramesetBorderFrame(PRInt32 aWidth, PRBool aVertical, PRBool aVisible);
|
1998-07-27 09:59:37 +04:00
|
|
|
virtual ~nsHTMLFramesetBorderFrame();
|
|
|
|
virtual void GetDesiredSize(nsIPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
1998-10-01 08:46:11 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize);
|
1998-08-06 23:40:37 +04:00
|
|
|
PRInt32 mWidth;
|
2001-11-02 05:19:49 +03:00
|
|
|
PRPackedBool mVertical;
|
|
|
|
PRPackedBool mVisibility;
|
|
|
|
PRPackedBool mVisibilityOverride;
|
1998-09-03 05:16:27 +04:00
|
|
|
nscolor mColor;
|
|
|
|
// the prev and next neighbors are indexes into the row (for a horizontal border) or col (for
|
|
|
|
// a vertical border) of nsHTMLFramesetFrames or nsHTMLFrames
|
|
|
|
PRInt32 mPrevNeighbor;
|
|
|
|
PRInt32 mNextNeighbor;
|
|
|
|
PRBool mCanResize;
|
1998-07-27 09:59:37 +04:00
|
|
|
friend class nsHTMLFramesetFrame;
|
|
|
|
};
|
1998-08-06 02:24:56 +04:00
|
|
|
/*******************************************************************************
|
|
|
|
* nsHTMLFramesetBlankFrame
|
|
|
|
******************************************************************************/
|
|
|
|
class nsHTMLFramesetBlankFrame : public nsLeafFrame {
|
|
|
|
|
|
|
|
public:
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef DEBUG
|
1999-10-26 08:44:41 +04:00
|
|
|
NS_IMETHOD List(nsIPresContext* aPresContext, FILE* out = stdout, PRInt32 aIndent = 0) const;
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|
1998-08-06 02:24:56 +04:00
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_IMETHOD Paint(nsIPresContext* aPresContext,
|
1998-08-06 02:24:56 +04:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
1999-03-10 09:13:35 +03:00
|
|
|
const nsRect& aDirtyRect,
|
2001-09-19 16:35:19 +04:00
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
PRUint32 aFlags);
|
1998-08-06 02:24:56 +04:00
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_IMETHOD Reflow(nsIPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus);
|
1998-08-06 02:24:56 +04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~nsHTMLFramesetBlankFrame();
|
1999-03-10 09:13:35 +03:00
|
|
|
virtual void GetDesiredSize(nsIPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
1999-03-10 09:13:35 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize);
|
1998-08-06 02:24:56 +04:00
|
|
|
friend class nsHTMLFramesetFrame;
|
|
|
|
friend class nsHTMLFrameset;
|
|
|
|
};
|
1998-07-27 09:59:37 +04:00
|
|
|
|
1998-07-16 03:42:14 +04:00
|
|
|
/*******************************************************************************
|
|
|
|
* nsHTMLFramesetFrame
|
|
|
|
******************************************************************************/
|
1998-07-27 09:59:37 +04:00
|
|
|
PRInt32 nsHTMLFramesetFrame::gMaxNumRowColSpecs = 25;
|
1998-09-03 05:16:27 +04:00
|
|
|
PRBool nsHTMLFramesetFrame::gDragInProgress = PR_FALSE;
|
2001-11-02 05:19:49 +03:00
|
|
|
#define kFrameResizePref "layout.frames.force_resizability"
|
|
|
|
#define DEFAULT_BORDER_WIDTH_PX 6
|
1998-07-16 03:42:14 +04:00
|
|
|
|
1998-12-03 09:31:43 +03:00
|
|
|
nsHTMLFramesetFrame::nsHTMLFramesetFrame()
|
|
|
|
: nsHTMLContainerFrame()
|
1998-07-16 03:42:14 +04:00
|
|
|
{
|
1999-04-13 04:56:23 +04:00
|
|
|
mNumRows = 0;
|
|
|
|
mRowSpecs = nsnull;
|
|
|
|
mRowSizes = nsnull;
|
|
|
|
mNumCols = 0;
|
|
|
|
mColSpecs = nsnull;
|
|
|
|
mColSizes = nsnull;
|
|
|
|
mEdgeVisibility = 0;
|
|
|
|
mParentFrameborder = eFrameborder_Yes; // default
|
|
|
|
mParentBorderWidth = -1; // default not set
|
|
|
|
mParentBorderColor = NO_COLOR; // default not set
|
1999-06-11 05:18:50 +04:00
|
|
|
mFirstDragPoint.x = mFirstDragPoint.y = 0;
|
1999-04-13 04:56:23 +04:00
|
|
|
mMinDrag = 0;
|
|
|
|
mNonBorderChildCount = 0;
|
|
|
|
mNonBlankChildCount = 0;
|
|
|
|
mDragger = nsnull;
|
|
|
|
mChildCount = 0;
|
|
|
|
mTopLevelFrameset = nsnull;
|
1999-03-10 09:13:35 +03:00
|
|
|
mEdgeColors.Set(NO_COLOR);
|
2001-04-12 12:16:54 +04:00
|
|
|
mVerBorders = nsnull;
|
|
|
|
mHorBorders = nsnull;
|
2001-10-07 04:19:01 +04:00
|
|
|
mChildTypes = nsnull;
|
|
|
|
mChildFrameborder = nsnull;
|
|
|
|
mChildBorderColors = nsnull;
|
2001-11-02 05:19:49 +03:00
|
|
|
mForceFrameResizability = PR_FALSE;
|
|
|
|
mPrefBranchWeakRef = nsnull;
|
1998-07-16 03:42:14 +04:00
|
|
|
}
|
|
|
|
|
1998-07-20 22:52:40 +04:00
|
|
|
nsHTMLFramesetFrame::~nsHTMLFramesetFrame()
|
|
|
|
{
|
|
|
|
if (mRowSizes) delete [] mRowSizes;
|
|
|
|
if (mRowSpecs) delete [] mRowSpecs;
|
|
|
|
if (mColSizes) delete [] mColSizes;
|
|
|
|
if (mColSpecs) delete [] mColSpecs;
|
2001-04-12 12:16:54 +04:00
|
|
|
if (mVerBorders) delete[] mVerBorders;
|
|
|
|
if (mHorBorders) delete[] mHorBorders;
|
1998-07-20 22:52:40 +04:00
|
|
|
mRowSizes = mColSizes = nsnull;
|
|
|
|
mRowSpecs = mColSpecs = nsnull;
|
2001-11-02 05:19:49 +03:00
|
|
|
nsCOMPtr<nsIPrefBranchInternal> prefBranch(do_QueryReferent(mPrefBranchWeakRef));
|
|
|
|
if (prefBranch) {
|
|
|
|
nsresult rv = prefBranch->RemoveObserver(kFrameResizePref, this);
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "Can't remove frameset as pref branch observer");
|
|
|
|
}
|
|
|
|
mPrefBranchWeakRef = nsnull;
|
1998-07-20 22:52:40 +04:00
|
|
|
}
|
1998-07-16 03:42:14 +04:00
|
|
|
|
1999-03-10 09:13:35 +03:00
|
|
|
nsresult nsHTMLFramesetFrame::QueryInterface(const nsIID& aIID,
|
|
|
|
void** aInstancePtr)
|
1998-09-03 05:16:27 +04:00
|
|
|
{
|
|
|
|
if (NULL == aInstancePtr) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
2002-04-05 09:42:10 +04:00
|
|
|
} else if (aIID.Equals(kIFramesetFrameIID)) {
|
1998-09-03 05:16:27 +04:00
|
|
|
*aInstancePtr = (void*)this;
|
|
|
|
return NS_OK;
|
2001-11-02 05:19:49 +03:00
|
|
|
} else if (aIID.Equals(NS_GET_IID(nsIObserver))) {
|
|
|
|
*aInstancePtr = (void*)this;
|
|
|
|
return NS_OK;
|
1998-09-03 05:16:27 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return nsHTMLContainerFrame::QueryInterface(aIID, aInstancePtr);
|
|
|
|
}
|
|
|
|
|
2001-11-02 05:19:49 +03:00
|
|
|
nsrefcnt nsHTMLFramesetFrame::AddRef(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsrefcnt nsHTMLFramesetFrame::Release(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHTMLFramesetFrame::Observe(nsISupports* aObject, const char* aAction,
|
|
|
|
const PRUnichar* aPrefName)
|
|
|
|
{
|
|
|
|
nsAutoString prefName(aPrefName);
|
|
|
|
if (prefName.Equals(NS_LITERAL_STRING(kFrameResizePref))) {
|
|
|
|
nsCOMPtr<nsIDocument> doc;
|
|
|
|
mContent->GetDocument(*getter_AddRefs(doc));
|
|
|
|
if (doc) {
|
|
|
|
doc->BeginUpdate();
|
|
|
|
doc->AttributeWillChange(mContent,
|
|
|
|
kNameSpaceID_None,
|
|
|
|
nsHTMLAtoms::frameborder);
|
|
|
|
}
|
|
|
|
nsCOMPtr<nsIPrefBranch> prefBranch(do_QueryInterface(aObject));
|
|
|
|
if (prefBranch) {
|
|
|
|
prefBranch->GetBoolPref(kFrameResizePref, &mForceFrameResizability);
|
|
|
|
}
|
|
|
|
RecalculateBorderResize();
|
|
|
|
mRect.width = mRect.height = -1; // force a recalculation of frame sizes
|
|
|
|
if (doc) {
|
|
|
|
doc->AttributeChanged(mContent,
|
|
|
|
kNameSpaceID_None,
|
|
|
|
nsHTMLAtoms::frameborder,
|
|
|
|
nsIDOMMutationEvent::MODIFICATION,
|
|
|
|
NS_STYLE_HINT_REFLOW);
|
|
|
|
doc->EndUpdate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-11-19 18:33:29 +03:00
|
|
|
static NS_DEFINE_IID(kViewCID, NS_VIEW_CID);
|
|
|
|
|
2001-10-07 04:19:01 +04:00
|
|
|
#define FRAMESET 0
|
|
|
|
#define FRAME 1
|
|
|
|
#define BLANK 2
|
|
|
|
|
1999-03-10 09:13:35 +03:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsHTMLFramesetFrame::Init(nsIPresContext* aPresContext,
|
1999-03-10 09:13:35 +03:00
|
|
|
nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIStyleContext* aContext,
|
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
|
|
|
nsHTMLContainerFrame::Init(aPresContext, aContent, aParent,
|
|
|
|
aContext, aPrevInFlow);
|
|
|
|
// find the highest ancestor that is a frameset
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nsIFrame* parentFrame = nsnull;
|
|
|
|
GetParent((nsIFrame**)&parentFrame);
|
|
|
|
mTopLevelFrameset = (nsHTMLFramesetFrame*)this;
|
|
|
|
while (parentFrame) {
|
|
|
|
nsHTMLFramesetFrame* frameset;
|
2002-04-05 09:42:10 +04:00
|
|
|
rv = parentFrame->QueryInterface(kIFramesetFrameIID, (void**)&frameset);
|
1999-03-10 09:13:35 +03:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
mTopLevelFrameset = frameset;
|
|
|
|
parentFrame->GetParent((nsIFrame**)&parentFrame);
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1999-11-19 18:33:29 +03:00
|
|
|
|
|
|
|
// create the view. a view is needed since it needs to be a mouse grabber
|
|
|
|
nsIView* view;
|
2001-01-04 23:44:42 +03:00
|
|
|
nsresult result = nsComponentManager::CreateInstance(kViewCID, nsnull, NS_GET_IID(nsIView),
|
1999-11-19 18:33:29 +03:00
|
|
|
(void **)&view);
|
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
1999-11-24 09:03:41 +03:00
|
|
|
aPresContext->GetShell(getter_AddRefs(presShell));
|
1999-11-19 18:33:29 +03:00
|
|
|
nsCOMPtr<nsIViewManager> viewMan;
|
|
|
|
presShell->GetViewManager(getter_AddRefs(viewMan));
|
|
|
|
|
|
|
|
nsIFrame* parWithView;
|
|
|
|
nsIView *parView;
|
1999-11-24 09:03:41 +03:00
|
|
|
GetParentWithView(aPresContext, &parWithView);
|
|
|
|
parWithView->GetView(aPresContext, &parView);
|
1999-11-19 18:33:29 +03:00
|
|
|
nsRect boundBox(0, 0, 0, 0);
|
2000-04-25 08:43:11 +04:00
|
|
|
result = view->Init(viewMan, boundBox, parView);
|
2001-12-01 17:31:45 +03:00
|
|
|
// XXX Put it last in document order until we can do better
|
|
|
|
viewMan->InsertChild(parView, view, nsnull, PR_TRUE);
|
1999-11-24 09:03:41 +03:00
|
|
|
SetView(aPresContext, view);
|
1999-11-19 18:33:29 +03:00
|
|
|
|
2001-10-07 04:19:01 +04:00
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
|
|
|
aPresContext->GetShell(getter_AddRefs(shell));
|
|
|
|
|
2001-12-07 22:40:07 +03:00
|
|
|
nsFrameborder frameborder = GetFrameBorder();
|
2001-11-06 03:44:25 +03:00
|
|
|
PRInt32 borderWidth = GetBorderWidth(aPresContext, PR_FALSE);
|
2001-10-07 04:19:01 +04:00
|
|
|
nscolor borderColor = GetBorderColor();
|
|
|
|
|
|
|
|
// parse the rows= cols= data
|
|
|
|
ParseRowCol(aPresContext, nsHTMLAtoms::rows, mNumRows, &mRowSpecs);
|
|
|
|
ParseRowCol(aPresContext, nsHTMLAtoms::cols, mNumCols, &mColSpecs);
|
|
|
|
mRowSizes = new nscoord[mNumRows];
|
|
|
|
mColSizes = new nscoord[mNumCols];
|
|
|
|
|
|
|
|
PRInt32 numCells = mNumRows*mNumCols;
|
|
|
|
|
|
|
|
mVerBorders = new nsHTMLFramesetBorderFrame*[mNumCols]; // 1 more than number of ver borders
|
|
|
|
for (int verX = 0; verX < mNumCols; verX++)
|
|
|
|
mVerBorders[verX] = nsnull;
|
|
|
|
|
|
|
|
mHorBorders = new nsHTMLFramesetBorderFrame*[mNumRows]; // 1 more than number of hor borders
|
|
|
|
for (int horX = 0; horX < mNumRows; horX++)
|
|
|
|
mHorBorders[horX] = nsnull;
|
|
|
|
|
|
|
|
mChildTypes = new PRInt32[numCells];
|
|
|
|
mChildFrameborder = new nsFrameborder[numCells];
|
|
|
|
mChildBorderColors = new nsBorderColor[numCells];
|
|
|
|
|
|
|
|
// create the children frames; skip content which isn't <frameset> or <frame>
|
|
|
|
nsIFrame* lastChild = nsnull;
|
|
|
|
mChildCount = 0; // number of <frame> or <frameset> children
|
|
|
|
nsIFrame* frame;
|
|
|
|
PRInt32 numChildren; // number of any type of children
|
|
|
|
mContent->ChildCount(numChildren);
|
|
|
|
for (int childX = 0; childX < numChildren; childX++) {
|
|
|
|
if (mChildCount == numCells) { // we have more <frame> or <frameset> than cells
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
nsCOMPtr<nsIContent> child;
|
|
|
|
mContent->ChildAt(childX, *getter_AddRefs(child));
|
|
|
|
if (!child->IsContentOfType(nsIContent::eHTML))
|
|
|
|
continue;
|
|
|
|
nsCOMPtr<nsIAtom> tag;
|
|
|
|
child->GetTag(*getter_AddRefs(tag));
|
|
|
|
if ((nsHTMLAtoms::frameset == tag) || (nsHTMLAtoms::frame == tag)) {
|
|
|
|
nsCOMPtr<nsIStyleContext> kidSC;
|
|
|
|
nsresult result;
|
|
|
|
|
|
|
|
aPresContext->ResolveStyleContextFor(child, mStyleContext,
|
2002-03-31 20:59:00 +04:00
|
|
|
getter_AddRefs(kidSC));
|
2001-12-07 22:40:07 +03:00
|
|
|
if (nsHTMLAtoms::frameset == tag) {
|
2001-10-07 04:19:01 +04:00
|
|
|
result = NS_NewHTMLFramesetFrame(shell, &frame);
|
|
|
|
|
|
|
|
mChildTypes[mChildCount] = FRAMESET;
|
|
|
|
nsHTMLFramesetFrame* childFrame = (nsHTMLFramesetFrame*)frame;
|
|
|
|
childFrame->SetParentFrameborder(frameborder);
|
|
|
|
childFrame->SetParentBorderWidth(borderWidth);
|
|
|
|
childFrame->SetParentBorderColor(borderColor);
|
2001-11-06 03:44:25 +03:00
|
|
|
frame->Init(aPresContext, child, this, kidSC, nsnull);
|
|
|
|
|
2001-10-07 04:19:01 +04:00
|
|
|
mChildBorderColors[mChildCount].Set(childFrame->GetBorderColor());
|
|
|
|
} else { // frame
|
|
|
|
result = NS_NewHTMLFrameOuterFrame(shell, &frame);
|
|
|
|
frame->Init(aPresContext, child, this, kidSC, nsnull);
|
|
|
|
|
|
|
|
mChildTypes[mChildCount] = FRAME;
|
|
|
|
|
2001-12-07 22:40:07 +03:00
|
|
|
mChildFrameborder[mChildCount] = GetFrameBorder(child);
|
2001-10-07 04:19:01 +04:00
|
|
|
mChildBorderColors[mChildCount].Set(GetBorderColor(child));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_FAILED(result))
|
|
|
|
return result;
|
|
|
|
|
|
|
|
if (lastChild)
|
|
|
|
lastChild->SetNextSibling(frame);
|
|
|
|
else
|
|
|
|
mFrames.SetFrames(frame);
|
|
|
|
|
|
|
|
lastChild = frame;
|
|
|
|
mChildCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mNonBlankChildCount = mChildCount;
|
|
|
|
// add blank frames for frameset cells that had no content provided
|
|
|
|
for (int blankX = mChildCount; blankX < numCells; blankX++) {
|
|
|
|
// XXX the blank frame is using the content of its parent - at some point it
|
|
|
|
// should just have null content, if we support that
|
|
|
|
nsHTMLFramesetBlankFrame* blankFrame = new (shell.get()) nsHTMLFramesetBlankFrame;
|
|
|
|
nsCOMPtr<nsIStyleContext> pseudoStyleContext;
|
|
|
|
aPresContext->ResolvePseudoStyleContextFor(mContent, nsHTMLAtoms::framesetBlankPseudo,
|
2002-03-31 20:59:00 +04:00
|
|
|
mStyleContext,
|
2001-10-07 04:19:01 +04:00
|
|
|
getter_AddRefs(pseudoStyleContext));
|
|
|
|
if(blankFrame)
|
|
|
|
blankFrame->Init(aPresContext, mContent, this, pseudoStyleContext, nsnull);
|
|
|
|
|
|
|
|
if (lastChild)
|
|
|
|
lastChild->SetNextSibling(blankFrame);
|
|
|
|
else
|
|
|
|
mFrames.SetFrames(blankFrame);
|
|
|
|
|
|
|
|
lastChild = blankFrame;
|
|
|
|
mChildTypes[mChildCount] = BLANK;
|
|
|
|
mChildBorderColors[mChildCount].Set(NO_COLOR);
|
|
|
|
mChildCount++;
|
|
|
|
}
|
|
|
|
|
|
|
|
mNonBorderChildCount = mChildCount;
|
1999-03-10 09:13:35 +03:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1998-11-28 21:59:38 +03:00
|
|
|
// XXX should this try to allocate twips based on an even pixel boundary?
|
1999-03-10 09:13:35 +03:00
|
|
|
void nsHTMLFramesetFrame::Scale(nscoord aDesired,
|
|
|
|
PRInt32 aNumIndicies,
|
|
|
|
PRInt32* aIndicies,
|
2000-01-07 08:49:20 +03:00
|
|
|
PRInt32 aNumItems,
|
1999-03-10 09:13:35 +03:00
|
|
|
PRInt32* aItems)
|
1998-11-28 21:59:38 +03:00
|
|
|
{
|
|
|
|
PRInt32 actual = 0;
|
|
|
|
PRInt32 i, j;
|
|
|
|
// get the actual total
|
|
|
|
for (i = 0; i < aNumIndicies; i++) {
|
|
|
|
j = aIndicies[i];
|
|
|
|
actual += aItems[j];
|
|
|
|
}
|
|
|
|
|
|
|
|
float factor = (float)aDesired / (float)actual;
|
|
|
|
actual = 0;
|
|
|
|
// scale the items up or down
|
|
|
|
for (i = 0; i < aNumIndicies; i++) {
|
|
|
|
j = aIndicies[i];
|
|
|
|
aItems[j] = NSToCoordRound((float)aItems[j] * factor);
|
|
|
|
actual += aItems[j];
|
|
|
|
}
|
|
|
|
|
1999-07-07 02:41:54 +04:00
|
|
|
if ((aNumIndicies > 0) && (aDesired != actual)) {
|
1998-11-28 21:59:38 +03:00
|
|
|
PRInt32 unit = (aDesired > actual) ? 1 : -1;
|
2000-01-07 08:49:20 +03:00
|
|
|
for (i=0; (i < aNumIndicies) && (aDesired != actual); i++) {
|
1998-11-28 21:59:38 +03:00
|
|
|
j = aIndicies[i];
|
2000-01-07 08:49:20 +03:00
|
|
|
if (j < aNumItems) {
|
|
|
|
aItems[j] += unit;
|
|
|
|
actual += unit;
|
|
|
|
}
|
1998-11-28 21:59:38 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-07-16 03:42:14 +04:00
|
|
|
/**
|
|
|
|
* Translate the rows/cols specs into an array of integer sizes for
|
1998-11-28 21:59:38 +03:00
|
|
|
* each cell in the frameset. Sizes are allocated based on the priorities of the
|
|
|
|
* specifier - fixed sizes have the highest priority, percentage sizes have the next
|
|
|
|
* highest priority and relative sizes have the lowest.
|
1998-07-16 03:42:14 +04:00
|
|
|
*/
|
1999-03-10 09:13:35 +03:00
|
|
|
void nsHTMLFramesetFrame::CalculateRowCol(nsIPresContext* aPresContext,
|
|
|
|
nscoord aSize,
|
|
|
|
PRInt32 aNumSpecs,
|
|
|
|
nsFramesetSpec* aSpecs,
|
|
|
|
nscoord* aValues)
|
1998-07-16 03:42:14 +04:00
|
|
|
{
|
1998-11-28 21:59:38 +03:00
|
|
|
PRInt32 fixedTotal = 0;
|
|
|
|
PRInt32 numFixed = 0;
|
|
|
|
PRInt32* fixed = new PRInt32[aNumSpecs];
|
|
|
|
PRInt32 numPercent = 0;
|
|
|
|
PRInt32* percent = new PRInt32[aNumSpecs];
|
|
|
|
PRInt32 relativeSums = 0;
|
|
|
|
PRInt32 numRelative = 0;
|
|
|
|
PRInt32* relative= new PRInt32[aNumSpecs];
|
|
|
|
|
1998-11-14 04:52:27 +03:00
|
|
|
float p2t;
|
1999-02-12 20:45:58 +03:00
|
|
|
aPresContext->GetScaledPixelsToTwips(&p2t);
|
1998-11-28 21:59:38 +03:00
|
|
|
PRInt32 i, j;
|
|
|
|
|
|
|
|
// initialize the fixed, percent, relative indices, allocate the fixed sizes and zero the others
|
|
|
|
for (i = 0; i < aNumSpecs; i++) {
|
|
|
|
aValues[i] = 0;
|
1998-07-16 03:42:14 +04:00
|
|
|
switch (aSpecs[i].mUnit) {
|
1998-11-28 21:59:38 +03:00
|
|
|
case eFramesetUnit_Fixed:
|
|
|
|
aValues[i] = NSToCoordRound(p2t * aSpecs[i].mValue);
|
|
|
|
fixedTotal += aValues[i];
|
|
|
|
fixed[numFixed] = i;
|
|
|
|
numFixed++;
|
1998-07-16 03:42:14 +04:00
|
|
|
break;
|
|
|
|
case eFramesetUnit_Percent:
|
1998-11-28 21:59:38 +03:00
|
|
|
percent[numPercent] = i;
|
|
|
|
numPercent++;
|
1998-07-16 03:42:14 +04:00
|
|
|
break;
|
1998-11-28 21:59:38 +03:00
|
|
|
case eFramesetUnit_Relative:
|
|
|
|
relative[numRelative] = i;
|
|
|
|
numRelative++;
|
|
|
|
relativeSums += aSpecs[i].mValue;
|
1998-07-16 03:42:14 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-11-28 21:59:38 +03:00
|
|
|
// scale the fixed sizes if they total too much (or too little and there aren't any percent or relative)
|
|
|
|
if ((fixedTotal > aSize) || ((fixedTotal < aSize) && (0 == numPercent) && (0 == numRelative))) {
|
2000-01-07 08:49:20 +03:00
|
|
|
Scale(aSize, numFixed, fixed, aNumSpecs, aValues);
|
1998-11-28 21:59:38 +03:00
|
|
|
delete [] fixed; delete [] percent; delete [] relative;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRInt32 percentMax = aSize - fixedTotal;
|
|
|
|
PRInt32 percentTotal = 0;
|
|
|
|
// allocate the percentage sizes from what is left over from the fixed allocation
|
|
|
|
for (i = 0; i < numPercent; i++) {
|
|
|
|
j = percent[i];
|
1999-06-11 04:28:00 +04:00
|
|
|
aValues[j] = NSToCoordRound((float)aSpecs[j].mValue * (float)aSize / 100.0f);
|
1998-11-28 21:59:38 +03:00
|
|
|
percentTotal += aValues[j];
|
1998-07-16 03:42:14 +04:00
|
|
|
}
|
|
|
|
|
1998-11-28 21:59:38 +03:00
|
|
|
// scale the percent sizes if they total too much (or too little and there aren't any relative)
|
|
|
|
if ((percentTotal > percentMax) || ((percentTotal < percentMax) && (0 == numRelative))) {
|
2000-01-07 08:49:20 +03:00
|
|
|
Scale(percentMax, numPercent, percent, aNumSpecs, aValues);
|
1998-11-28 21:59:38 +03:00
|
|
|
delete [] fixed; delete [] percent; delete [] relative;
|
|
|
|
return;
|
1998-07-16 03:42:14 +04:00
|
|
|
}
|
1998-11-28 21:59:38 +03:00
|
|
|
|
|
|
|
PRInt32 relativeMax = percentMax - percentTotal;
|
|
|
|
PRInt32 relativeTotal = 0;
|
|
|
|
// allocate the relative sizes from what is left over from the percent allocation
|
|
|
|
for (i = 0; i < numRelative; i++) {
|
|
|
|
j = relative[i];
|
|
|
|
aValues[j] = NSToCoordRound((float)aSpecs[j].mValue * (float)relativeMax / (float)relativeSums);
|
|
|
|
relativeTotal += aValues[j];
|
|
|
|
}
|
|
|
|
|
|
|
|
// scale the relative sizes if they take up too much or too little
|
|
|
|
if (relativeTotal != relativeMax) {
|
2000-01-07 08:49:20 +03:00
|
|
|
Scale(relativeMax, numRelative, relative, aNumSpecs, aValues);
|
1998-07-16 03:42:14 +04:00
|
|
|
}
|
1998-12-01 01:37:52 +03:00
|
|
|
|
|
|
|
delete [] fixed; delete [] percent; delete [] relative;
|
1998-07-16 03:42:14 +04:00
|
|
|
}
|
|
|
|
|
1998-11-28 21:59:38 +03:00
|
|
|
|
1999-06-11 04:51:05 +04:00
|
|
|
/**
|
|
|
|
* Translate the rows/cols integer sizes into an array of specs for
|
|
|
|
* each cell in the frameset. Reverse of CalculateRowCol() behaviour.
|
|
|
|
* This allows us to maintain the user size info through reflows.
|
|
|
|
*/
|
|
|
|
void nsHTMLFramesetFrame::GenerateRowCol(nsIPresContext* aPresContext,
|
|
|
|
nscoord aSize,
|
|
|
|
PRInt32 aNumSpecs,
|
|
|
|
nsFramesetSpec* aSpecs,
|
|
|
|
nscoord* aValues)
|
|
|
|
{
|
|
|
|
float t2p;
|
|
|
|
aPresContext->GetTwipsToPixels(&t2p);
|
|
|
|
PRInt32 i;
|
|
|
|
|
|
|
|
for (i = 0; i < aNumSpecs; i++) {
|
|
|
|
switch (aSpecs[i].mUnit) {
|
|
|
|
case eFramesetUnit_Fixed:
|
|
|
|
aSpecs[i].mValue = NSToCoordRound(t2p * aValues[i]);
|
|
|
|
break;
|
|
|
|
case eFramesetUnit_Percent: // XXX Only accurate to 1%, need 1 pixel
|
|
|
|
aSpecs[i].mValue = (100*aValues[i])/aSize;
|
|
|
|
break;
|
|
|
|
case eFramesetUnit_Relative:
|
|
|
|
aSpecs[i].mValue = aValues[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-11-06 03:44:25 +03:00
|
|
|
PRInt32 nsHTMLFramesetFrame::GetBorderWidth(nsIPresContext* aPresContext,
|
|
|
|
PRBool aTakeForcingIntoAccount)
|
1998-07-27 09:59:37 +04:00
|
|
|
{
|
2001-11-06 03:44:25 +03:00
|
|
|
PRBool forcing = mForceFrameResizability && aTakeForcingIntoAccount;
|
|
|
|
|
|
|
|
if (!forcing) {
|
2001-12-07 22:40:07 +03:00
|
|
|
nsFrameborder frameborder = GetFrameBorder();
|
2001-11-02 05:19:49 +03:00
|
|
|
if (frameborder == eFrameborder_No) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
1998-11-14 04:52:27 +03:00
|
|
|
float p2t;
|
1999-02-12 20:45:58 +03:00
|
|
|
aPresContext->GetScaledPixelsToTwips(&p2t);
|
1998-08-06 23:40:37 +04:00
|
|
|
nsHTMLValue htmlVal;
|
1998-09-10 03:30:30 +04:00
|
|
|
nsIHTMLContent* content = nsnull;
|
|
|
|
mContent->QueryInterface(kIHTMLContentIID, (void**)&content);
|
|
|
|
if (nsnull != content) {
|
1998-12-20 04:21:23 +03:00
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE == (content->GetHTMLAttribute(nsHTMLAtoms::border, htmlVal))) {
|
1998-11-30 21:19:21 +03:00
|
|
|
nsHTMLUnit unit = htmlVal.GetUnit();
|
|
|
|
PRInt32 intVal = 0;
|
|
|
|
if (eHTMLUnit_Pixel == unit) {
|
1998-09-10 03:30:30 +04:00
|
|
|
intVal = htmlVal.GetPixelValue();
|
1998-11-30 21:19:21 +03:00
|
|
|
} else if (eHTMLUnit_Integer == unit) {
|
1998-09-10 03:30:30 +04:00
|
|
|
intVal = htmlVal.GetIntValue();
|
1998-11-30 21:19:21 +03:00
|
|
|
}
|
1998-09-10 03:30:30 +04:00
|
|
|
if (intVal < 0) {
|
|
|
|
intVal = 0;
|
|
|
|
}
|
|
|
|
NS_RELEASE(content);
|
2001-11-06 03:44:25 +03:00
|
|
|
if (forcing && intVal == 0) {
|
2001-11-02 05:19:49 +03:00
|
|
|
intVal = DEFAULT_BORDER_WIDTH_PX;
|
|
|
|
}
|
1998-09-10 03:30:30 +04:00
|
|
|
return NSIntPixelsToTwips(intVal, p2t);
|
1998-08-06 23:40:37 +04:00
|
|
|
}
|
1998-09-10 03:30:30 +04:00
|
|
|
NS_RELEASE(content);
|
1998-08-06 23:40:37 +04:00
|
|
|
}
|
|
|
|
|
2001-11-02 05:19:49 +03:00
|
|
|
if (mParentBorderWidth > 0 ||
|
2001-11-06 03:44:25 +03:00
|
|
|
(mParentBorderWidth == 0 && !forcing)) {
|
1998-08-06 23:40:37 +04:00
|
|
|
return mParentBorderWidth;
|
|
|
|
}
|
|
|
|
|
2001-11-02 05:19:49 +03:00
|
|
|
return NSIntPixelsToTwips(DEFAULT_BORDER_WIDTH_PX, p2t);
|
1998-07-27 09:59:37 +04:00
|
|
|
}
|
|
|
|
|
1998-09-03 05:16:27 +04:00
|
|
|
|
1998-07-16 03:42:14 +04:00
|
|
|
PRIntn
|
|
|
|
nsHTMLFramesetFrame::GetSkipSides() const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-03-10 09:13:35 +03:00
|
|
|
nsHTMLFramesetFrame::GetDesiredSize(nsIPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
1999-03-10 09:13:35 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize)
|
1998-07-16 03:42:14 +04:00
|
|
|
{
|
|
|
|
nsHTMLFramesetFrame* framesetParent = GetFramesetParent(this);
|
|
|
|
if (nsnull == framesetParent) {
|
|
|
|
nsRect area;
|
|
|
|
aPresContext->GetVisibleArea(area);
|
|
|
|
|
|
|
|
aDesiredSize.width = area.width;
|
|
|
|
aDesiredSize.height= area.height;
|
|
|
|
} else {
|
1998-07-22 03:20:04 +04:00
|
|
|
nsSize size;
|
|
|
|
framesetParent->GetSizeOfChild(this, size);
|
|
|
|
aDesiredSize.width = size.width;
|
|
|
|
aDesiredSize.height = size.height;
|
1998-07-16 03:42:14 +04:00
|
|
|
}
|
|
|
|
aDesiredSize.ascent = aDesiredSize.height;
|
|
|
|
aDesiredSize.descent = 0;
|
|
|
|
}
|
|
|
|
|
1998-09-03 05:16:27 +04:00
|
|
|
|
1998-07-16 03:42:14 +04:00
|
|
|
nsHTMLFramesetFrame* nsHTMLFramesetFrame::GetFramesetParent(nsIFrame* aChild)
|
|
|
|
{
|
|
|
|
nsHTMLFramesetFrame* parent = nsnull;
|
1998-09-10 03:30:30 +04:00
|
|
|
nsIContent* content = nsnull;
|
1999-02-10 03:42:56 +03:00
|
|
|
aChild->GetContent(&content);
|
1998-09-10 03:30:30 +04:00
|
|
|
if (nsnull != content) {
|
|
|
|
nsIContent* contentParent = nsnull;
|
|
|
|
content->GetParent(contentParent);
|
|
|
|
if (nsnull != contentParent) {
|
|
|
|
nsIHTMLContent* contentParent2 = nsnull;
|
|
|
|
contentParent->QueryInterface(kIHTMLContentIID, (void**)&contentParent2);
|
|
|
|
if (nsnull != contentParent2) {
|
|
|
|
nsIAtom* tag;
|
|
|
|
contentParent2->GetTag(tag);
|
|
|
|
if (nsHTMLAtoms::frameset == tag) {
|
1999-02-10 04:36:30 +03:00
|
|
|
aChild->GetParent((nsIFrame**)&parent);
|
1998-09-10 03:30:30 +04:00
|
|
|
}
|
|
|
|
NS_IF_RELEASE(tag);
|
|
|
|
NS_RELEASE(contentParent2);
|
|
|
|
}
|
|
|
|
NS_RELEASE(contentParent);
|
|
|
|
}
|
|
|
|
NS_RELEASE(content);
|
1998-07-16 03:42:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return parent;
|
|
|
|
}
|
|
|
|
|
1998-07-27 09:59:37 +04:00
|
|
|
// only valid for non border children
|
1999-03-10 09:13:35 +03:00
|
|
|
void nsHTMLFramesetFrame::GetSizeOfChildAt(PRInt32 aIndexInParent,
|
|
|
|
nsSize& aSize,
|
|
|
|
nsPoint& aCellIndex)
|
1998-07-20 22:52:40 +04:00
|
|
|
{
|
|
|
|
PRInt32 row = aIndexInParent / mNumCols;
|
|
|
|
PRInt32 col = aIndexInParent - (row * mNumCols); // remainder from dividing index by mNumCols
|
|
|
|
if ((row < mNumRows) && (col < mNumCols)) {
|
|
|
|
aSize.width = mColSizes[col];
|
|
|
|
aSize.height = mRowSizes[row];
|
|
|
|
aCellIndex.x = col;
|
|
|
|
aCellIndex.y = row;
|
|
|
|
} else {
|
|
|
|
aSize.width = aSize.height = aCellIndex.x = aCellIndex.y = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-07-27 09:59:37 +04:00
|
|
|
// only valid for non border children
|
1998-07-16 03:42:14 +04:00
|
|
|
void nsHTMLFramesetFrame::GetSizeOfChild(nsIFrame* aChild,
|
1999-03-10 09:13:35 +03:00
|
|
|
nsSize& aSize)
|
1998-07-16 03:42:14 +04:00
|
|
|
{
|
1998-07-20 22:52:40 +04:00
|
|
|
// Reflow only creates children frames for <frameset> and <frame> content.
|
|
|
|
// this assumption is used here
|
1998-07-16 03:42:14 +04:00
|
|
|
int i = 0;
|
1999-01-16 01:53:39 +03:00
|
|
|
for (nsIFrame* child = mFrames.FirstChild(); child;
|
1999-02-10 09:13:38 +03:00
|
|
|
child->GetNextSibling(&child)) {
|
1998-07-16 03:42:14 +04:00
|
|
|
if (aChild == child) {
|
1998-07-20 22:52:40 +04:00
|
|
|
nsPoint ignore;
|
|
|
|
GetSizeOfChildAt(i, aSize, ignore);
|
1998-07-27 09:59:37 +04:00
|
|
|
return;
|
1998-07-16 03:42:14 +04:00
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
1998-07-20 22:52:40 +04:00
|
|
|
aSize.width = 0;
|
|
|
|
aSize.height = 0;
|
1998-07-16 03:42:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_METHOD nsHTMLFramesetFrame::HandleEvent(nsIPresContext* aPresContext,
|
1999-03-10 09:13:35 +03:00
|
|
|
nsGUIEvent* aEvent,
|
1999-11-24 09:03:41 +03:00
|
|
|
nsEventStatus* aEventStatus)
|
1998-09-03 05:16:27 +04:00
|
|
|
{
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_ENSURE_ARG_POINTER(aEventStatus);
|
1998-11-25 21:11:26 +03:00
|
|
|
if (mDragger) {
|
|
|
|
// the nsFramesetBorderFrame has captured NS_MOUSE_DOWN
|
|
|
|
switch (aEvent->message) {
|
|
|
|
case NS_MOUSE_MOVE:
|
|
|
|
MouseDrag(aPresContext, aEvent);
|
|
|
|
break;
|
|
|
|
case NS_MOUSE_LEFT_BUTTON_UP:
|
1999-11-24 09:03:41 +03:00
|
|
|
EndMouseDrag(aPresContext);
|
1998-11-25 21:11:26 +03:00
|
|
|
break;
|
|
|
|
}
|
1999-11-24 09:03:41 +03:00
|
|
|
*aEventStatus = nsEventStatus_eConsumeNoDefault;
|
1998-11-25 21:11:26 +03:00
|
|
|
} else {
|
1999-11-24 09:03:41 +03:00
|
|
|
*aEventStatus = nsEventStatus_eIgnore;
|
1998-11-18 08:25:26 +03:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-03-10 09:13:35 +03:00
|
|
|
#if 0
|
|
|
|
PRBool
|
|
|
|
nsHTMLFramesetFrame::IsGrabbingMouse()
|
1998-11-18 08:25:26 +03:00
|
|
|
{
|
1999-03-10 09:13:35 +03:00
|
|
|
PRBool result = PR_FALSE;
|
1998-09-03 05:16:27 +04:00
|
|
|
nsIView* view;
|
1999-02-10 08:38:18 +03:00
|
|
|
GetView(&view);
|
1998-09-03 05:16:27 +04:00
|
|
|
if (view) {
|
|
|
|
nsIViewManager* viewMan;
|
|
|
|
view->GetViewManager(viewMan);
|
|
|
|
if (viewMan) {
|
|
|
|
nsIView* grabber;
|
|
|
|
viewMan->GetMouseEventGrabber(grabber);
|
|
|
|
if (grabber == view) {
|
1998-11-18 08:25:26 +03:00
|
|
|
// the nsFramesetBorderFrame has captured NS_MOUSE_DOWN
|
1999-03-10 09:13:35 +03:00
|
|
|
result = PR_TRUE;
|
1998-09-03 05:16:27 +04:00
|
|
|
}
|
|
|
|
NS_RELEASE(viewMan);
|
1998-11-18 08:25:26 +03:00
|
|
|
}
|
1998-09-03 05:16:27 +04:00
|
|
|
}
|
1999-03-10 09:13:35 +03:00
|
|
|
return result;
|
1998-09-03 05:16:27 +04:00
|
|
|
}
|
1999-03-10 09:13:35 +03:00
|
|
|
#endif
|
1998-09-03 05:16:27 +04:00
|
|
|
|
1998-07-16 03:42:14 +04:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsHTMLFramesetFrame::GetCursor(nsIPresContext* aPresContext,
|
1999-03-10 09:13:35 +03:00
|
|
|
nsPoint& aPoint,
|
|
|
|
PRInt32& aCursor)
|
|
|
|
{
|
|
|
|
if (mDragger) {
|
|
|
|
aCursor = (mDragger->mVertical) ? NS_STYLE_CURSOR_W_RESIZE : NS_STYLE_CURSOR_N_RESIZE;
|
|
|
|
} else {
|
|
|
|
aCursor = NS_STYLE_CURSOR_DEFAULT;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-10-26 08:44:41 +04:00
|
|
|
nsHTMLFramesetFrame::GetFrameForPoint(nsIPresContext* aPresContext,
|
|
|
|
const nsPoint& aPoint,
|
2000-03-22 05:43:08 +03:00
|
|
|
nsFramePaintLayer aWhichLayer,
|
1999-03-10 09:13:35 +03:00
|
|
|
nsIFrame** aFrame)
|
|
|
|
{
|
|
|
|
//XXX Temporary to deal with event handling in both this and FramsetBorderFrame
|
|
|
|
if (mDragger) {
|
|
|
|
*aFrame = this;
|
|
|
|
return NS_OK;
|
|
|
|
} else {
|
2000-03-22 05:43:08 +03:00
|
|
|
return nsContainerFrame::GetFrameForPoint(aPresContext, aPoint, aWhichLayer, aFrame);
|
1999-03-10 09:13:35 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsHTMLFramesetFrame::Paint(nsIPresContext* aPresContext,
|
1998-07-16 03:42:14 +04:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
1999-03-10 09:13:35 +03:00
|
|
|
const nsRect& aDirtyRect,
|
2001-09-19 16:35:19 +04:00
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
PRUint32 aFlags)
|
1998-07-16 03:42:14 +04:00
|
|
|
{
|
2000-10-29 02:17:53 +04:00
|
|
|
//printf("frameset paint %X (%d,%d,%d,%d) \n", this, aDirtyRect.x, aDirtyRect.y, aDirtyRect.width, aDirtyRect.height);
|
1998-12-18 18:54:23 +03:00
|
|
|
return nsHTMLContainerFrame::Paint(aPresContext, aRenderingContext,
|
|
|
|
aDirtyRect, aWhichLayer);
|
1998-07-16 03:42:14 +04:00
|
|
|
}
|
|
|
|
|
2000-08-04 02:26:56 +04:00
|
|
|
void nsHTMLFramesetFrame::ParseRowCol(nsIPresContext* aPresContext, nsIAtom* aAttrType, PRInt32& aNumSpecs, nsFramesetSpec** aSpecs)
|
1998-07-16 03:42:14 +04:00
|
|
|
{
|
|
|
|
nsHTMLValue value;
|
|
|
|
nsAutoString rowsCols;
|
1998-09-10 03:30:30 +04:00
|
|
|
nsIHTMLContent* content = nsnull;
|
1999-02-12 20:45:58 +03:00
|
|
|
mContent->QueryInterface(kIHTMLContentIID, (void**)&content);
|
1998-09-10 03:30:30 +04:00
|
|
|
if (nsnull != content) {
|
1998-12-20 04:21:23 +03:00
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE == content->GetHTMLAttribute(aAttrType, value)) {
|
1998-09-10 03:30:30 +04:00
|
|
|
if (eHTMLUnit_String == value.GetUnit()) {
|
|
|
|
value.GetStringValue(rowsCols);
|
|
|
|
nsFramesetSpec* specs = new nsFramesetSpec[gMaxNumRowColSpecs];
|
2000-08-04 02:26:56 +04:00
|
|
|
aNumSpecs = ParseRowColSpec(aPresContext, rowsCols, gMaxNumRowColSpecs, specs);
|
1998-09-10 03:30:30 +04:00
|
|
|
*aSpecs = new nsFramesetSpec[aNumSpecs];
|
|
|
|
for (int i = 0; i < aNumSpecs; i++) {
|
|
|
|
(*aSpecs)[i] = specs[i];
|
|
|
|
}
|
|
|
|
delete [] specs;
|
|
|
|
NS_RELEASE(content);
|
|
|
|
return;
|
1998-07-16 03:42:14 +04:00
|
|
|
}
|
|
|
|
}
|
1998-09-10 03:30:30 +04:00
|
|
|
NS_RELEASE(content);
|
1998-07-16 03:42:14 +04:00
|
|
|
}
|
1998-07-22 03:20:04 +04:00
|
|
|
aNumSpecs = 1;
|
|
|
|
*aSpecs = new nsFramesetSpec[1];
|
1998-11-28 21:59:38 +03:00
|
|
|
aSpecs[0]->mUnit = eFramesetUnit_Relative;
|
1998-07-22 03:20:04 +04:00
|
|
|
aSpecs[0]->mValue = 1;
|
1998-07-16 03:42:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Translate a "rows" or "cols" spec into an array of nsFramesetSpecs
|
|
|
|
*/
|
|
|
|
PRInt32
|
2000-08-04 02:26:56 +04:00
|
|
|
nsHTMLFramesetFrame::ParseRowColSpec(nsIPresContext* aPresContext,
|
|
|
|
nsString& aSpec,
|
1999-03-10 09:13:35 +03:00
|
|
|
PRInt32 aMaxNumValues,
|
1998-07-16 03:42:14 +04:00
|
|
|
nsFramesetSpec* aSpecs)
|
|
|
|
{
|
|
|
|
static const PRUnichar ASTER('*');
|
|
|
|
static const PRUnichar PERCENT('%');
|
|
|
|
static const PRUnichar COMMA(',');
|
|
|
|
|
2000-03-30 05:03:02 +04:00
|
|
|
// remove whitespace (Bug 33699)
|
|
|
|
// also remove leading/trailing commas (bug 31482)
|
|
|
|
aSpec.StripChars(" \n\r\t");
|
|
|
|
aSpec.Trim(",");
|
1999-02-03 22:26:29 +03:00
|
|
|
|
1998-07-16 03:42:14 +04:00
|
|
|
// Count the commas
|
1999-07-26 04:37:24 +04:00
|
|
|
PRInt32 commaX = aSpec.FindChar(COMMA);
|
1998-07-16 03:42:14 +04:00
|
|
|
PRInt32 count = 1;
|
|
|
|
while (commaX >= 0) {
|
|
|
|
count++;
|
2002-01-30 09:04:29 +03:00
|
|
|
commaX = aSpec.FindChar(COMMA, commaX + 1);
|
1998-07-16 03:42:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (count > aMaxNumValues) {
|
|
|
|
NS_ASSERTION(0, "Not enough space for values");
|
|
|
|
count = aMaxNumValues;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Parse each comma separated token
|
|
|
|
|
|
|
|
PRInt32 start = 0;
|
|
|
|
PRInt32 specLen = aSpec.Length();
|
|
|
|
|
|
|
|
for (PRInt32 i = 0; i < count; i++) {
|
|
|
|
// Find our comma
|
2002-01-30 09:04:29 +03:00
|
|
|
commaX = aSpec.FindChar(COMMA, start);
|
1998-07-16 03:42:14 +04:00
|
|
|
PRInt32 end = (commaX < 0) ? specLen : commaX;
|
|
|
|
|
|
|
|
// Note: If end == start then it means that the token has no
|
|
|
|
// data in it other than a terminating comma (or the end of the spec)
|
1998-11-28 21:59:38 +03:00
|
|
|
aSpecs[i].mUnit = eFramesetUnit_Fixed;
|
1998-07-16 03:42:14 +04:00
|
|
|
if (end > start) {
|
2000-03-25 06:19:14 +03:00
|
|
|
PRInt32 numberEnd = end;
|
|
|
|
PRUnichar ch = aSpec.CharAt(numberEnd - 1);
|
1998-07-16 03:42:14 +04:00
|
|
|
if (ASTER == ch) {
|
1998-11-28 21:59:38 +03:00
|
|
|
aSpecs[i].mUnit = eFramesetUnit_Relative;
|
1998-07-16 03:42:14 +04:00
|
|
|
numberEnd--;
|
|
|
|
} else if (PERCENT == ch) {
|
|
|
|
aSpecs[i].mUnit = eFramesetUnit_Percent;
|
|
|
|
numberEnd--;
|
2000-06-22 09:32:56 +04:00
|
|
|
// check for "*%"
|
|
|
|
if (numberEnd > start) {
|
|
|
|
ch = aSpec.CharAt(numberEnd - 1);
|
|
|
|
if (ASTER == ch) {
|
|
|
|
aSpecs[i].mUnit = eFramesetUnit_Relative;
|
|
|
|
numberEnd--;
|
|
|
|
}
|
|
|
|
}
|
1998-07-16 03:42:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Translate value to an integer
|
2000-04-16 01:18:29 +04:00
|
|
|
nsString token;
|
2000-03-25 06:19:14 +03:00
|
|
|
aSpec.Mid(token, start, numberEnd - start);
|
|
|
|
|
|
|
|
// Treat * as 1*
|
|
|
|
if ((eFramesetUnit_Relative == aSpecs[i].mUnit) &&
|
2000-03-30 04:19:13 +04:00
|
|
|
(0 == token.Length())) {
|
2000-03-25 06:19:14 +03:00
|
|
|
aSpecs[i].mValue = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise just convert to integer.
|
|
|
|
else {
|
|
|
|
PRInt32 err;
|
|
|
|
aSpecs[i].mValue = token.ToInteger(&err);
|
|
|
|
if (err) {
|
|
|
|
aSpecs[i].mValue = 0;
|
1998-07-16 03:42:14 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-08-04 02:26:56 +04:00
|
|
|
// Treat 0* as 1* in quirks mode (bug 40383)
|
|
|
|
nsCompatibility mode;
|
|
|
|
aPresContext->GetCompatibilityMode(&mode);
|
|
|
|
if (eCompatibility_NavQuirks == mode) {
|
|
|
|
if ((eFramesetUnit_Relative == aSpecs[i].mUnit) &&
|
|
|
|
(0 == aSpecs[i].mValue)) {
|
|
|
|
aSpecs[i].mValue = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-03-25 06:19:14 +03:00
|
|
|
// Catch zero and negative frame sizes for Nav compatability
|
|
|
|
// Nav resized absolute and relative frames to "1" and
|
|
|
|
// percent frames to an even percentage of the width
|
|
|
|
//
|
|
|
|
//if ((eCompatibility_NavQuirks == aMode) && (aSpecs[i].mValue <= 0)) {
|
|
|
|
// if (eFramesetUnit_Percent == aSpecs[i].mUnit) {
|
|
|
|
// aSpecs[i].mValue = 100 / count;
|
|
|
|
// } else {
|
|
|
|
// aSpecs[i].mValue = 1;
|
|
|
|
// }
|
|
|
|
//} else {
|
|
|
|
|
|
|
|
// In standards mode, just set negative sizes to zero
|
|
|
|
if (aSpecs[i].mValue < 0) {
|
|
|
|
aSpecs[i].mValue = 0;
|
|
|
|
}
|
1998-07-16 03:42:14 +04:00
|
|
|
start = end + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
1998-07-27 09:59:37 +04:00
|
|
|
void
|
1998-10-02 08:10:00 +04:00
|
|
|
nsHTMLFramesetFrame::ReflowPlaceChild(nsIFrame* aChild,
|
1999-11-24 09:03:41 +03:00
|
|
|
nsIPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsPoint& aOffset,
|
|
|
|
nsSize& aSize,
|
|
|
|
nsPoint* aCellIndex)
|
1998-07-27 09:59:37 +04:00
|
|
|
{
|
2000-03-24 07:42:40 +03:00
|
|
|
// reflow the child
|
1999-10-30 06:52:11 +04:00
|
|
|
nsHTMLReflowState reflowState(aPresContext, aReflowState, aChild, aSize);
|
|
|
|
nsHTMLReflowMetrics metrics(nsnull);
|
|
|
|
metrics.width = aSize.width;
|
|
|
|
metrics.height= aSize.height;
|
|
|
|
nsReflowStatus status;
|
1999-03-10 09:13:35 +03:00
|
|
|
|
1999-11-19 18:33:29 +03:00
|
|
|
ReflowChild(aChild, aPresContext, metrics, reflowState, aOffset.x,
|
|
|
|
aOffset.y, 0, status);
|
1999-10-30 06:52:11 +04:00
|
|
|
NS_ASSERTION(NS_FRAME_IS_COMPLETE(status), "bad status");
|
1998-07-27 09:59:37 +04:00
|
|
|
|
1999-10-30 06:52:11 +04:00
|
|
|
// Place and size the child
|
1999-11-19 18:33:29 +03:00
|
|
|
metrics.width = aSize.width;
|
|
|
|
metrics.height = aSize.height;
|
2001-12-07 17:51:12 +03:00
|
|
|
FinishReflowChild(aChild, aPresContext, nsnull, metrics, aOffset.x, aOffset.y, 0);
|
1998-07-27 09:59:37 +04:00
|
|
|
}
|
|
|
|
|
1999-02-25 18:38:29 +03:00
|
|
|
static
|
2001-12-07 22:40:07 +03:00
|
|
|
nsFrameborder GetFrameBorderHelper(nsIHTMLContent* aContent)
|
1998-08-06 23:40:37 +04:00
|
|
|
{
|
1998-09-10 03:30:30 +04:00
|
|
|
if (nsnull != aContent) {
|
|
|
|
nsHTMLValue value;
|
1998-12-20 04:21:23 +03:00
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE == (aContent->GetHTMLAttribute(nsHTMLAtoms::frameborder, value))) {
|
2001-12-07 22:40:07 +03:00
|
|
|
if (eHTMLUnit_Enumerated == value.GetUnit()) {
|
|
|
|
switch (value.GetIntValue())
|
|
|
|
{
|
|
|
|
case NS_STYLE_FRAME_YES:
|
|
|
|
case NS_STYLE_FRAME_1:
|
|
|
|
return eFrameborder_Yes;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_STYLE_FRAME_NO:
|
|
|
|
case NS_STYLE_FRAME_0:
|
|
|
|
return eFrameborder_No;
|
|
|
|
break;
|
1998-09-10 03:30:30 +04:00
|
|
|
}
|
|
|
|
}
|
1998-08-06 23:40:37 +04:00
|
|
|
}
|
|
|
|
}
|
1998-09-10 03:30:30 +04:00
|
|
|
return eFrameborder_Notset;
|
1998-08-06 23:40:37 +04:00
|
|
|
}
|
|
|
|
|
2001-12-07 22:40:07 +03:00
|
|
|
nsFrameborder nsHTMLFramesetFrame::GetFrameBorder()
|
1998-07-31 01:25:35 +04:00
|
|
|
{
|
1998-09-10 03:30:30 +04:00
|
|
|
nsFrameborder result = eFrameborder_Notset;
|
|
|
|
nsIHTMLContent* content = nsnull;
|
|
|
|
mContent->QueryInterface(kIHTMLContentIID, (void**) &content);
|
2001-12-07 22:40:07 +03:00
|
|
|
if (content) {
|
|
|
|
result = GetFrameBorderHelper(content);
|
1998-09-10 03:30:30 +04:00
|
|
|
NS_RELEASE(content);
|
|
|
|
}
|
|
|
|
if (eFrameborder_Notset == result) {
|
|
|
|
return mParentFrameborder;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2001-12-07 22:40:07 +03:00
|
|
|
nsFrameborder nsHTMLFramesetFrame::GetFrameBorder(nsIContent* aContent)
|
1998-09-10 03:30:30 +04:00
|
|
|
{
|
|
|
|
nsFrameborder result = eFrameborder_Notset;
|
|
|
|
nsIHTMLContent* content = nsnull;
|
|
|
|
aContent->QueryInterface(kIHTMLContentIID, (void**) &content);
|
|
|
|
if (nsnull != content) {
|
2001-12-07 22:40:07 +03:00
|
|
|
result = GetFrameBorderHelper(content);
|
1998-09-10 03:30:30 +04:00
|
|
|
NS_RELEASE(content);
|
|
|
|
}
|
|
|
|
if (eFrameborder_Notset == result) {
|
2001-12-07 22:40:07 +03:00
|
|
|
return GetFrameBorder();
|
1998-07-31 01:25:35 +04:00
|
|
|
}
|
1998-09-10 03:30:30 +04:00
|
|
|
return result;
|
1998-07-31 01:25:35 +04:00
|
|
|
}
|
1998-07-27 09:59:37 +04:00
|
|
|
|
1998-09-03 05:16:27 +04:00
|
|
|
nscolor nsHTMLFramesetFrame::GetBorderColor()
|
|
|
|
{
|
1998-09-10 03:30:30 +04:00
|
|
|
nscolor result = NO_COLOR;
|
|
|
|
nsIHTMLContent* content = nsnull;
|
|
|
|
mContent->QueryInterface(kIHTMLContentIID, (void**)&content);
|
|
|
|
if (nsnull != content) {
|
|
|
|
nsHTMLValue value;
|
1998-12-20 04:21:23 +03:00
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE == (content->GetHTMLAttribute(nsHTMLAtoms::bordercolor, value))) {
|
1999-07-07 05:25:41 +04:00
|
|
|
if ((eHTMLUnit_Color == value.GetUnit()) ||
|
|
|
|
(eHTMLUnit_ColorName == value.GetUnit())) {
|
1998-09-10 03:30:30 +04:00
|
|
|
result = value.GetColorValue();
|
|
|
|
}
|
1998-09-03 05:16:27 +04:00
|
|
|
}
|
1998-09-10 03:30:30 +04:00
|
|
|
NS_RELEASE(content);
|
1998-09-03 05:16:27 +04:00
|
|
|
}
|
1998-09-10 03:30:30 +04:00
|
|
|
if (NO_COLOR == result) {
|
|
|
|
return mParentBorderColor;
|
|
|
|
}
|
|
|
|
return result;
|
1998-09-03 05:16:27 +04:00
|
|
|
}
|
|
|
|
|
1998-09-10 03:30:30 +04:00
|
|
|
nscolor nsHTMLFramesetFrame::GetBorderColor(nsIContent* aContent)
|
1998-09-03 05:16:27 +04:00
|
|
|
{
|
1998-09-10 03:30:30 +04:00
|
|
|
nscolor result = NO_COLOR;
|
|
|
|
nsIHTMLContent* content = nsnull;
|
|
|
|
aContent->QueryInterface(kIHTMLContentIID, (void**)&content);
|
|
|
|
if (nsnull != content) {
|
|
|
|
nsHTMLValue value;
|
1998-12-20 04:21:23 +03:00
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE == (content->GetHTMLAttribute(nsHTMLAtoms::bordercolor, value))) {
|
1999-07-07 05:25:41 +04:00
|
|
|
if ((eHTMLUnit_Color == value.GetUnit()) ||
|
|
|
|
(eHTMLUnit_ColorName == value.GetUnit())) {
|
1998-09-10 03:30:30 +04:00
|
|
|
result = value.GetColorValue();
|
|
|
|
}
|
1998-09-03 05:16:27 +04:00
|
|
|
}
|
1998-09-10 03:30:30 +04:00
|
|
|
NS_RELEASE(content);
|
|
|
|
}
|
|
|
|
if (NO_COLOR == result) {
|
|
|
|
return GetBorderColor();
|
1998-09-03 05:16:27 +04:00
|
|
|
}
|
1998-09-10 03:30:30 +04:00
|
|
|
return result;
|
1998-09-03 05:16:27 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsHTMLFramesetFrame::Reflow(nsIPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-09-03 05:16:27 +04:00
|
|
|
{
|
2000-04-22 01:51:35 +04:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsHTMLFramesetFrame", aReflowState.reason);
|
2001-11-14 16:40:03 +03:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
|
1999-12-05 02:49:50 +03:00
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
|
|
|
aPresContext->GetShell(getter_AddRefs(shell));
|
|
|
|
|
2000-10-29 02:17:53 +04:00
|
|
|
//printf("FramesetFrame2::Reflow %X (%d,%d) \n", this, aReflowState.availableWidth, aReflowState.availableHeight);
|
1998-07-16 03:42:14 +04:00
|
|
|
// Always get the size so that the caller knows how big we are
|
1999-11-24 09:03:41 +03:00
|
|
|
GetDesiredSize(aPresContext, aReflowState, aDesiredSize);
|
2001-10-07 04:19:01 +04:00
|
|
|
|
1999-01-06 02:31:18 +03:00
|
|
|
nscoord width = (aDesiredSize.width <= aReflowState.availableWidth)
|
|
|
|
? aDesiredSize.width : aReflowState.availableWidth;
|
|
|
|
nscoord height = (aDesiredSize.height <= aReflowState.availableHeight)
|
|
|
|
? aDesiredSize.height : aReflowState.availableHeight;
|
2001-11-02 05:19:49 +03:00
|
|
|
|
|
|
|
PRBool firstTime = (eReflowReason_Initial == aReflowState.reason);
|
|
|
|
if (firstTime) {
|
|
|
|
nsCOMPtr<nsIPrefService> prefService(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
|
|
|
if (prefService) {
|
|
|
|
nsCOMPtr<nsIPrefBranch> prefBranch;
|
|
|
|
prefService->GetBranch(nsnull, getter_AddRefs(prefBranch));
|
|
|
|
if (prefBranch) {
|
|
|
|
nsCOMPtr<nsIPrefBranchInternal> prefBranchInternal(do_QueryInterface(prefBranch));
|
|
|
|
if (prefBranchInternal) {
|
2001-11-06 03:44:25 +03:00
|
|
|
mPrefBranchWeakRef = getter_AddRefs(NS_GetWeakReference(prefBranchInternal));
|
2001-11-02 05:19:49 +03:00
|
|
|
prefBranchInternal->AddObserver(kFrameResizePref, this, PR_FALSE);
|
|
|
|
}
|
|
|
|
prefBranch->GetBoolPref(kFrameResizePref, &mForceFrameResizability);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-07-27 09:59:37 +04:00
|
|
|
// subtract out the width of all of the potential borders. There are
|
|
|
|
// only borders between <frame>s. There are none on the edges (e.g the
|
|
|
|
// leftmost <frame> has no left border).
|
2001-11-06 03:44:25 +03:00
|
|
|
PRInt32 borderWidth = GetBorderWidth(aPresContext, PR_TRUE);
|
2000-09-21 09:07:06 +04:00
|
|
|
|
1998-07-27 09:59:37 +04:00
|
|
|
width -= (mNumCols - 1) * borderWidth;
|
2000-09-21 09:07:06 +04:00
|
|
|
if (width < 0) width = 0;
|
|
|
|
|
1998-07-27 09:59:37 +04:00
|
|
|
height -= (mNumRows - 1) * borderWidth;
|
2000-09-21 09:07:06 +04:00
|
|
|
if (height < 0) height = 0;
|
1998-07-16 03:42:14 +04:00
|
|
|
|
1999-03-10 09:13:35 +03:00
|
|
|
if (!mDrag.mActive && ( (firstTime) ||
|
1998-09-03 05:16:27 +04:00
|
|
|
( (mRect.width != 0) && (mRect.height != 0) &&
|
|
|
|
(aDesiredSize.width != 0) && (aDesiredSize.height != 0) &&
|
|
|
|
((aDesiredSize.width != mRect.width) || (aDesiredSize.height != mRect.height))) ) ) {
|
1999-11-24 09:03:41 +03:00
|
|
|
CalculateRowCol(aPresContext, width, mNumCols, mColSpecs, mColSizes);
|
|
|
|
CalculateRowCol(aPresContext, height, mNumRows, mRowSpecs, mRowSizes);
|
1998-09-03 05:16:27 +04:00
|
|
|
}
|
1998-07-20 22:52:40 +04:00
|
|
|
|
2001-04-11 11:56:13 +04:00
|
|
|
PRBool* verBordersVis = nsnull; // vertical borders visibility
|
|
|
|
nscolor* verBorderColors = nsnull;
|
|
|
|
PRBool* horBordersVis = nsnull; // horizontal borders visibility
|
|
|
|
nscolor* horBorderColors = nsnull;
|
2001-10-07 04:19:01 +04:00
|
|
|
nscolor borderColor = GetBorderColor();
|
2001-12-07 22:40:07 +03:00
|
|
|
nsFrameborder frameborder = GetFrameBorder();
|
2001-04-11 11:56:13 +04:00
|
|
|
|
1998-07-31 01:25:35 +04:00
|
|
|
if (firstTime) {
|
|
|
|
verBordersVis = new PRBool[mNumCols];
|
1998-09-03 05:16:27 +04:00
|
|
|
verBorderColors = new nscolor[mNumCols];
|
1998-07-31 01:25:35 +04:00
|
|
|
for (int verX = 0; verX < mNumCols; verX++) {
|
|
|
|
verBordersVis[verX] = PR_FALSE;
|
1998-09-03 05:16:27 +04:00
|
|
|
verBorderColors[verX] = NO_COLOR;
|
1998-07-31 01:25:35 +04:00
|
|
|
}
|
2001-10-07 04:19:01 +04:00
|
|
|
|
1998-07-31 01:25:35 +04:00
|
|
|
horBordersVis = new PRBool[mNumRows];
|
1998-09-03 05:16:27 +04:00
|
|
|
horBorderColors = new nscolor[mNumRows];
|
1998-07-31 01:25:35 +04:00
|
|
|
for (int horX = 0; horX < mNumRows; horX++) {
|
|
|
|
horBordersVis[horX] = PR_FALSE;
|
1998-09-03 05:16:27 +04:00
|
|
|
horBorderColors[horX] = NO_COLOR;
|
1998-07-31 01:25:35 +04:00
|
|
|
}
|
1998-07-20 22:52:40 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// reflow the children
|
|
|
|
PRInt32 lastRow = 0;
|
1998-09-03 05:16:27 +04:00
|
|
|
PRInt32 lastCol = 0;
|
1998-07-31 01:25:35 +04:00
|
|
|
PRInt32 borderChildX = mNonBorderChildCount; // index of border children
|
|
|
|
nsHTMLFramesetBorderFrame* borderFrame = nsnull;
|
1998-07-20 22:52:40 +04:00
|
|
|
nsPoint offset(0,0);
|
1998-07-27 09:59:37 +04:00
|
|
|
nsSize size, lastSize;
|
1999-01-16 01:53:39 +03:00
|
|
|
nsIFrame* child = mFrames.FirstChild();
|
2001-10-07 04:19:01 +04:00
|
|
|
nsIFrame* lastChild = mFrames.LastChild();
|
1998-07-31 01:25:35 +04:00
|
|
|
|
1998-07-27 09:59:37 +04:00
|
|
|
for (PRInt32 childX = 0; childX < mNonBorderChildCount; childX++) {
|
1998-07-20 22:52:40 +04:00
|
|
|
nsPoint cellIndex;
|
1998-07-27 09:59:37 +04:00
|
|
|
GetSizeOfChildAt(childX, size, cellIndex);
|
1998-07-20 22:52:40 +04:00
|
|
|
|
|
|
|
if (lastRow != cellIndex.y) { // changed to next row
|
|
|
|
offset.x = 0;
|
1998-07-27 09:59:37 +04:00
|
|
|
offset.y += lastSize.height;
|
2001-11-02 05:19:49 +03:00
|
|
|
if (firstTime) { // create horizontal border
|
|
|
|
borderFrame = new (shell.get()) nsHTMLFramesetBorderFrame(borderWidth, PR_FALSE, PR_FALSE);
|
|
|
|
nsIStyleContext* pseudoStyleContext;
|
|
|
|
aPresContext->ResolvePseudoStyleContextFor(mContent, nsHTMLAtoms::horizontalFramesetBorderPseudo,
|
2002-03-31 20:59:00 +04:00
|
|
|
mStyleContext,
|
2001-11-02 05:19:49 +03:00
|
|
|
&pseudoStyleContext);
|
|
|
|
borderFrame->Init(aPresContext, mContent, this, pseudoStyleContext, nsnull);
|
|
|
|
NS_RELEASE(pseudoStyleContext);
|
|
|
|
|
|
|
|
mChildCount++;
|
|
|
|
lastChild->SetNextSibling(borderFrame);
|
|
|
|
lastChild = borderFrame;
|
|
|
|
mHorBorders[cellIndex.y-1] = borderFrame;
|
|
|
|
// set the neighbors for determining drag boundaries
|
|
|
|
borderFrame->mPrevNeighbor = lastRow;
|
|
|
|
borderFrame->mNextNeighbor = cellIndex.y;
|
|
|
|
} else {
|
|
|
|
borderFrame = (nsHTMLFramesetBorderFrame*)mFrames.FrameAt(borderChildX);
|
|
|
|
borderFrame->mWidth = borderWidth;
|
|
|
|
borderChildX++;
|
1998-08-06 23:40:37 +04:00
|
|
|
}
|
2001-11-02 05:19:49 +03:00
|
|
|
nsSize borderSize(aDesiredSize.width, borderWidth);
|
|
|
|
ReflowPlaceChild(borderFrame, aPresContext, aReflowState, offset, borderSize);
|
|
|
|
offset.y += borderWidth;
|
|
|
|
borderFrame = nsnull;
|
1998-07-27 09:59:37 +04:00
|
|
|
} else {
|
2001-11-02 05:19:49 +03:00
|
|
|
if (cellIndex.x > 0) { // moved to next col in same row
|
1998-07-27 09:59:37 +04:00
|
|
|
if (0 == cellIndex.y) { // in 1st row
|
|
|
|
if (firstTime) { // create vertical border
|
1999-12-05 02:49:50 +03:00
|
|
|
borderFrame = new (shell.get()) nsHTMLFramesetBorderFrame(borderWidth, PR_TRUE, PR_FALSE);
|
1999-02-11 18:56:23 +03:00
|
|
|
nsIStyleContext* pseudoStyleContext;
|
1999-11-24 09:03:41 +03:00
|
|
|
aPresContext->ResolvePseudoStyleContextFor(mContent, nsHTMLAtoms::verticalFramesetBorderPseudo,
|
2001-11-02 05:19:49 +03:00
|
|
|
mStyleContext,
|
|
|
|
&pseudoStyleContext);
|
1999-02-25 06:27:57 +03:00
|
|
|
borderFrame->Init(aPresContext, mContent, this, pseudoStyleContext, nsnull);
|
1998-10-15 09:13:21 +04:00
|
|
|
NS_RELEASE(pseudoStyleContext);
|
1998-10-12 18:48:02 +04:00
|
|
|
|
1998-07-27 09:59:37 +04:00
|
|
|
mChildCount++;
|
|
|
|
lastChild->SetNextSibling(borderFrame);
|
|
|
|
lastChild = borderFrame;
|
2001-04-12 12:16:54 +04:00
|
|
|
mVerBorders[cellIndex.x-1] = borderFrame;
|
1998-09-03 05:16:27 +04:00
|
|
|
// set the neighbors for determining drag boundaries
|
|
|
|
borderFrame->mPrevNeighbor = lastCol;
|
|
|
|
borderFrame->mNextNeighbor = cellIndex.x;
|
1998-07-27 09:59:37 +04:00
|
|
|
} else {
|
1999-01-16 01:53:39 +03:00
|
|
|
borderFrame = (nsHTMLFramesetBorderFrame*)mFrames.FrameAt(borderChildX);
|
2001-11-02 05:19:49 +03:00
|
|
|
borderFrame->mWidth = borderWidth;
|
1998-07-31 01:25:35 +04:00
|
|
|
borderChildX++;
|
1998-07-27 09:59:37 +04:00
|
|
|
}
|
1998-07-31 01:25:35 +04:00
|
|
|
nsSize borderSize(borderWidth, aDesiredSize.height);
|
1998-07-27 09:59:37 +04:00
|
|
|
ReflowPlaceChild(borderFrame, aPresContext, aReflowState, offset, borderSize);
|
2001-11-02 05:19:49 +03:00
|
|
|
borderFrame = nsnull;
|
1998-07-27 09:59:37 +04:00
|
|
|
}
|
|
|
|
offset.x += borderWidth;
|
|
|
|
}
|
1998-07-20 22:52:40 +04:00
|
|
|
}
|
1998-07-27 09:59:37 +04:00
|
|
|
|
1999-03-10 09:13:35 +03:00
|
|
|
ReflowPlaceChild(child, aPresContext, aReflowState, offset, size, &cellIndex);
|
1998-07-27 09:59:37 +04:00
|
|
|
|
1998-07-31 01:25:35 +04:00
|
|
|
if (firstTime) {
|
|
|
|
PRInt32 childVis;
|
2001-10-07 04:19:01 +04:00
|
|
|
if (FRAMESET == mChildTypes[childX]) {
|
1998-09-03 05:16:27 +04:00
|
|
|
nsHTMLFramesetFrame* childFS = (nsHTMLFramesetFrame*)child;
|
|
|
|
childVis = childFS->mEdgeVisibility;
|
2001-10-07 04:19:01 +04:00
|
|
|
mChildBorderColors[childX] = childFS->mEdgeColors;
|
|
|
|
} else if (FRAME == mChildTypes[childX]) {
|
|
|
|
if (eFrameborder_Yes == mChildFrameborder[childX]) {
|
1998-09-03 05:16:27 +04:00
|
|
|
childVis = ALL_VIS;
|
2001-10-07 04:19:01 +04:00
|
|
|
} else if (eFrameborder_No == mChildFrameborder[childX]) {
|
1998-09-03 05:16:27 +04:00
|
|
|
childVis = NONE_VIS;
|
1998-08-06 23:40:37 +04:00
|
|
|
} else { // notset
|
1998-09-03 05:16:27 +04:00
|
|
|
childVis = (eFrameborder_No == frameborder) ? NONE_VIS : ALL_VIS;
|
1998-08-06 23:40:37 +04:00
|
|
|
}
|
1998-08-06 02:24:56 +04:00
|
|
|
} else { // blank
|
1998-09-03 05:16:27 +04:00
|
|
|
childVis = NONE_VIS;
|
1998-07-31 01:25:35 +04:00
|
|
|
}
|
2001-10-07 04:19:01 +04:00
|
|
|
nsBorderColor childColors = mChildBorderColors[childX];
|
1998-09-03 05:16:27 +04:00
|
|
|
// set the visibility, color of our edge borders based on children
|
|
|
|
if (0 == cellIndex.x) {
|
|
|
|
if (!(mEdgeVisibility & LEFT_VIS)) {
|
|
|
|
mEdgeVisibility |= (LEFT_VIS & childVis);
|
|
|
|
}
|
|
|
|
if (NO_COLOR == mEdgeColors.mLeft) {
|
|
|
|
mEdgeColors.mLeft = childColors.mLeft;
|
|
|
|
}
|
1998-07-31 01:25:35 +04:00
|
|
|
}
|
1998-09-03 05:16:27 +04:00
|
|
|
if (0 == cellIndex.y) {
|
|
|
|
if (!(mEdgeVisibility & TOP_VIS)) {
|
|
|
|
mEdgeVisibility |= (TOP_VIS & childVis);
|
|
|
|
}
|
|
|
|
if (NO_COLOR == mEdgeColors.mTop) {
|
|
|
|
mEdgeColors.mTop = childColors.mTop;
|
|
|
|
}
|
1998-07-31 01:25:35 +04:00
|
|
|
}
|
1998-09-03 05:16:27 +04:00
|
|
|
if (mNumCols-1 == cellIndex.x) {
|
|
|
|
if (!(mEdgeVisibility & RIGHT_VIS)) {
|
|
|
|
mEdgeVisibility |= (RIGHT_VIS & childVis);
|
|
|
|
}
|
|
|
|
if (NO_COLOR == mEdgeColors.mRight) {
|
|
|
|
mEdgeColors.mRight = childColors.mRight;
|
|
|
|
}
|
1998-07-31 01:25:35 +04:00
|
|
|
}
|
1998-09-03 05:16:27 +04:00
|
|
|
if (mNumRows-1 == cellIndex.y) {
|
|
|
|
if (!(mEdgeVisibility & BOTTOM_VIS)) {
|
|
|
|
mEdgeVisibility |= (BOTTOM_VIS & childVis);
|
|
|
|
}
|
|
|
|
if (NO_COLOR == mEdgeColors.mBottom) {
|
|
|
|
mEdgeColors.mBottom = childColors.mBottom;
|
|
|
|
}
|
1998-07-31 01:25:35 +04:00
|
|
|
}
|
|
|
|
// set the visibility of borders that the child may affect
|
1998-09-03 05:16:27 +04:00
|
|
|
if (childVis & RIGHT_VIS) {
|
1998-07-31 01:25:35 +04:00
|
|
|
verBordersVis[cellIndex.x] = PR_TRUE;
|
|
|
|
}
|
1998-09-03 05:16:27 +04:00
|
|
|
if (childVis & BOTTOM_VIS) {
|
1998-07-31 01:25:35 +04:00
|
|
|
horBordersVis[cellIndex.y] = PR_TRUE;
|
|
|
|
}
|
1998-09-03 05:16:27 +04:00
|
|
|
if ((cellIndex.x > 0) && (childVis & LEFT_VIS)) {
|
1998-07-31 01:25:35 +04:00
|
|
|
verBordersVis[cellIndex.x-1] = PR_TRUE;
|
|
|
|
}
|
1998-09-03 05:16:27 +04:00
|
|
|
if ((cellIndex.y > 0) && (childVis & TOP_VIS)) {
|
1998-07-31 01:25:35 +04:00
|
|
|
horBordersVis[cellIndex.y-1] = PR_TRUE;
|
|
|
|
}
|
1998-09-03 05:16:27 +04:00
|
|
|
// set the colors of borders that the child may affect
|
|
|
|
if (NO_COLOR == verBorderColors[cellIndex.x]) {
|
2001-10-07 04:19:01 +04:00
|
|
|
verBorderColors[cellIndex.x] = mChildBorderColors[childX].mRight;
|
1998-09-03 05:16:27 +04:00
|
|
|
}
|
|
|
|
if (NO_COLOR == horBorderColors[cellIndex.y]) {
|
2001-10-07 04:19:01 +04:00
|
|
|
horBorderColors[cellIndex.y] = mChildBorderColors[childX].mBottom;
|
1998-09-03 05:16:27 +04:00
|
|
|
}
|
|
|
|
if ((cellIndex.x > 0) && (NO_COLOR == verBorderColors[cellIndex.x-1])) {
|
2001-10-07 04:19:01 +04:00
|
|
|
verBorderColors[cellIndex.x-1] = mChildBorderColors[childX].mLeft;
|
1998-09-03 05:16:27 +04:00
|
|
|
}
|
|
|
|
if ((cellIndex.y > 0) && (NO_COLOR == horBorderColors[cellIndex.y-1])) {
|
2001-10-07 04:19:01 +04:00
|
|
|
horBorderColors[cellIndex.y-1] = mChildBorderColors[childX].mTop;
|
1998-09-03 05:16:27 +04:00
|
|
|
}
|
1998-07-31 01:25:35 +04:00
|
|
|
}
|
1998-07-27 09:59:37 +04:00
|
|
|
lastRow = cellIndex.y;
|
1998-09-03 05:16:27 +04:00
|
|
|
lastCol = cellIndex.x;
|
1998-07-27 09:59:37 +04:00
|
|
|
lastSize = size;
|
|
|
|
offset.x += size.width;
|
1999-02-10 09:13:38 +03:00
|
|
|
child->GetNextSibling(&child);
|
1998-07-20 22:52:40 +04:00
|
|
|
}
|
|
|
|
|
1998-07-31 01:25:35 +04:00
|
|
|
if (firstTime) {
|
1998-09-03 05:16:27 +04:00
|
|
|
nscolor childColor;
|
|
|
|
// set the visibility, color, mouse sensitivity of borders
|
1998-07-31 01:25:35 +04:00
|
|
|
for (int verX = 0; verX < mNumCols-1; verX++) {
|
2001-04-12 12:16:54 +04:00
|
|
|
if (mVerBorders[verX]) {
|
|
|
|
mVerBorders[verX]->SetVisibility(verBordersVis[verX]);
|
2001-11-02 05:19:49 +03:00
|
|
|
if (mForceFrameResizability) {
|
|
|
|
mVerBorders[verX]->mVisibilityOverride = PR_TRUE;
|
|
|
|
} else {
|
|
|
|
SetBorderResize(mChildTypes, mVerBorders[verX]);
|
|
|
|
}
|
1998-09-03 05:16:27 +04:00
|
|
|
childColor = (NO_COLOR == verBorderColors[verX]) ? borderColor : verBorderColors[verX];
|
2001-04-12 12:16:54 +04:00
|
|
|
mVerBorders[verX]->SetColor(childColor);
|
1998-07-31 21:47:50 +04:00
|
|
|
}
|
1998-07-31 01:25:35 +04:00
|
|
|
}
|
|
|
|
for (int horX = 0; horX < mNumRows-1; horX++) {
|
2001-04-12 12:16:54 +04:00
|
|
|
if (mHorBorders[horX]) {
|
|
|
|
mHorBorders[horX]->SetVisibility(horBordersVis[horX]);
|
2001-11-02 05:19:49 +03:00
|
|
|
if (mForceFrameResizability) {
|
|
|
|
mHorBorders[horX]->mVisibilityOverride = PR_TRUE;
|
|
|
|
} else {
|
|
|
|
SetBorderResize(mChildTypes, mHorBorders[horX]);
|
|
|
|
}
|
1998-09-03 05:16:27 +04:00
|
|
|
childColor = (NO_COLOR == horBorderColors[horX]) ? borderColor : horBorderColors[horX];
|
2001-04-12 12:16:54 +04:00
|
|
|
mHorBorders[horX]->SetColor(childColor);
|
1998-07-31 21:47:50 +04:00
|
|
|
}
|
1998-07-31 01:25:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
delete[] verBordersVis;
|
1998-09-03 05:16:27 +04:00
|
|
|
delete[] verBorderColors;
|
1998-07-31 01:25:35 +04:00
|
|
|
delete[] horBordersVis;
|
1998-09-03 05:16:27 +04:00
|
|
|
delete[] horBorderColors;
|
2001-10-07 04:19:01 +04:00
|
|
|
delete[] mChildTypes;
|
|
|
|
delete[] mChildFrameborder;
|
|
|
|
delete[] mChildBorderColors;
|
1998-07-31 01:25:35 +04:00
|
|
|
}
|
|
|
|
|
1998-07-20 22:52:40 +04:00
|
|
|
if (nsnull != aDesiredSize.maxElementSize) {
|
|
|
|
aDesiredSize.maxElementSize->width = aDesiredSize.width;
|
|
|
|
aDesiredSize.maxElementSize->height = aDesiredSize.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
1999-03-10 09:13:35 +03:00
|
|
|
mDrag.UnSet();
|
1998-07-16 03:42:14 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-09-03 05:16:27 +04:00
|
|
|
PRBool
|
|
|
|
nsHTMLFramesetFrame::ChildIsFrameset(nsIFrame* aChild)
|
|
|
|
{
|
|
|
|
nsIFrame* childFrame = nsnull;
|
2002-04-05 09:42:10 +04:00
|
|
|
aChild->QueryInterface(kIFramesetFrameIID, (void**)&childFrame);
|
1998-09-03 05:16:27 +04:00
|
|
|
if (childFrame) {
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PRBool
|
1999-03-10 09:13:35 +03:00
|
|
|
nsHTMLFramesetFrame::CanResize(PRBool aVertical,
|
|
|
|
PRBool aLeft)
|
1998-09-03 05:16:27 +04:00
|
|
|
{
|
|
|
|
nsIFrame* child;
|
|
|
|
PRInt32 childX;
|
|
|
|
PRInt32 startX;
|
|
|
|
if (aVertical) {
|
|
|
|
startX = (aLeft) ? 0 : mNumCols-1;
|
|
|
|
for (childX = startX; childX < mNonBorderChildCount; childX += mNumCols) {
|
1999-01-16 01:53:39 +03:00
|
|
|
child = mFrames.FrameAt(childX);
|
1998-09-03 05:16:27 +04:00
|
|
|
if (!CanChildResize(aVertical, aLeft, childX, ChildIsFrameset(child))) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
startX = (aLeft) ? 0 : (mNumRows - 1) * mNumCols;
|
|
|
|
PRInt32 endX = startX + mNumCols;
|
|
|
|
for (childX = startX; childX < endX; childX++) {
|
1999-01-16 01:53:39 +03:00
|
|
|
child = mFrames.FrameAt(childX);
|
1998-09-03 05:16:27 +04:00
|
|
|
if (!CanChildResize(aVertical, aLeft, childX, ChildIsFrameset(child))) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
1998-09-10 03:30:30 +04:00
|
|
|
PRBool
|
|
|
|
nsHTMLFramesetFrame::GetNoResize(nsIFrame* aChildFrame)
|
|
|
|
{
|
|
|
|
PRBool result = PR_FALSE;
|
|
|
|
nsIContent* content = nsnull;
|
1999-02-10 03:42:56 +03:00
|
|
|
aChildFrame->GetContent(&content);
|
1998-09-10 03:30:30 +04:00
|
|
|
if (nsnull != content) {
|
|
|
|
nsIHTMLContent* htmlContent = nsnull;
|
|
|
|
content->QueryInterface(kIHTMLContentIID, (void**)&htmlContent);
|
|
|
|
if (nsnull != htmlContent) {
|
|
|
|
nsHTMLValue value;
|
1998-12-20 04:21:23 +03:00
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE == htmlContent->GetHTMLAttribute(nsHTMLAtoms::noresize, value)) {
|
1998-09-10 03:30:30 +04:00
|
|
|
result = PR_TRUE;
|
|
|
|
}
|
|
|
|
NS_RELEASE(htmlContent);
|
|
|
|
}
|
|
|
|
NS_RELEASE(content);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-09-03 05:16:27 +04:00
|
|
|
PRBool
|
1999-03-10 09:13:35 +03:00
|
|
|
nsHTMLFramesetFrame::CanChildResize(PRBool aVertical,
|
|
|
|
PRBool aLeft,
|
|
|
|
PRInt32 aChildX,
|
|
|
|
PRBool aFrameset)
|
1998-09-03 05:16:27 +04:00
|
|
|
{
|
1999-01-16 01:53:39 +03:00
|
|
|
nsIFrame* child = mFrames.FrameAt(aChildX);
|
1998-09-03 05:16:27 +04:00
|
|
|
if (aFrameset) {
|
|
|
|
return ((nsHTMLFramesetFrame*)child)->CanResize(aVertical, aLeft);
|
|
|
|
} else {
|
1998-09-10 03:30:30 +04:00
|
|
|
return !GetNoResize(child);
|
1998-09-03 05:16:27 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-04-12 12:16:54 +04:00
|
|
|
// This calculates and sets the resizability of all border frames
|
|
|
|
|
|
|
|
void
|
|
|
|
nsHTMLFramesetFrame::RecalculateBorderResize()
|
|
|
|
{
|
|
|
|
if (!mContent) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRInt32 numCells = mNumRows * mNumCols; // max number of cells
|
|
|
|
PRInt32* childTypes = new PRInt32[numCells];
|
|
|
|
PRInt32 childIndex, frameOrFramesetChildIndex = 0;
|
|
|
|
|
|
|
|
PRInt32 numChildren; // number of any type of children
|
|
|
|
mContent->ChildCount(numChildren);
|
|
|
|
for (childIndex = 0; childIndex < numChildren; childIndex++) {
|
|
|
|
nsCOMPtr<nsIContent> childCon;
|
|
|
|
mContent->ChildAt(childIndex, *getter_AddRefs(childCon));
|
|
|
|
nsCOMPtr<nsIHTMLContent> child(do_QueryInterface(childCon));
|
|
|
|
if (child) {
|
|
|
|
nsCOMPtr<nsIAtom> tag;
|
|
|
|
child->GetTag(*getter_AddRefs(tag));
|
|
|
|
if (nsHTMLAtoms::frameset == tag) {
|
|
|
|
childTypes[frameOrFramesetChildIndex++] = FRAMESET;
|
|
|
|
} else if (nsHTMLAtoms::frame == tag) {
|
|
|
|
childTypes[frameOrFramesetChildIndex++] = FRAME;
|
|
|
|
}
|
|
|
|
// Don't overflow childTypes array
|
|
|
|
if (frameOrFramesetChildIndex >= numCells) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-11-02 05:19:49 +03:00
|
|
|
// set the visibility and mouse sensitivity of borders
|
2001-04-12 12:16:54 +04:00
|
|
|
PRInt32 verX;
|
|
|
|
for (verX = 0; verX < mNumCols-1; verX++) {
|
|
|
|
if (mVerBorders[verX]) {
|
2001-11-02 05:19:49 +03:00
|
|
|
mVerBorders[verX]->mCanResize = PR_TRUE;
|
|
|
|
if (mForceFrameResizability) {
|
|
|
|
mVerBorders[verX]->mVisibilityOverride = PR_TRUE;
|
|
|
|
} else {
|
|
|
|
mVerBorders[verX]->mVisibilityOverride = PR_FALSE;
|
|
|
|
SetBorderResize(childTypes, mVerBorders[verX]);
|
|
|
|
}
|
2001-04-12 12:16:54 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
PRInt32 horX;
|
|
|
|
for (horX = 0; horX < mNumRows-1; horX++) {
|
|
|
|
if (mHorBorders[horX]) {
|
2001-11-02 05:19:49 +03:00
|
|
|
mHorBorders[horX]->mCanResize = PR_TRUE;
|
|
|
|
if (mForceFrameResizability) {
|
|
|
|
mHorBorders[horX]->mVisibilityOverride = PR_TRUE;
|
|
|
|
} else {
|
|
|
|
mHorBorders[horX]->mVisibilityOverride = PR_FALSE;
|
|
|
|
SetBorderResize(childTypes, mHorBorders[horX]);
|
|
|
|
}
|
2001-04-12 12:16:54 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
delete[] childTypes;
|
|
|
|
}
|
|
|
|
|
1998-09-03 05:16:27 +04:00
|
|
|
void
|
1999-03-10 09:13:35 +03:00
|
|
|
nsHTMLFramesetFrame::SetBorderResize(PRInt32* aChildTypes,
|
|
|
|
nsHTMLFramesetBorderFrame* aBorderFrame)
|
1998-09-03 05:16:27 +04:00
|
|
|
{
|
|
|
|
if (aBorderFrame->mVertical) {
|
|
|
|
for (int rowX = 0; rowX < mNumRows; rowX++) {
|
|
|
|
PRInt32 childX = aBorderFrame->mPrevNeighbor + (rowX * mNumCols);
|
|
|
|
if (!CanChildResize(PR_TRUE, PR_FALSE, childX, (FRAMESET == aChildTypes[childX])) ||
|
1999-04-13 04:56:23 +04:00
|
|
|
!CanChildResize(PR_TRUE, PR_TRUE, childX+1,(FRAMESET == aChildTypes[childX+1]))) {
|
1998-09-03 05:16:27 +04:00
|
|
|
aBorderFrame->mCanResize = PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
PRInt32 childX = aBorderFrame->mPrevNeighbor * mNumCols;
|
|
|
|
PRInt32 endX = childX + mNumCols;
|
|
|
|
for (; childX < endX; childX++) {
|
|
|
|
if (!CanChildResize(PR_FALSE, PR_FALSE, childX, (FRAMESET == aChildTypes[childX]))) {
|
|
|
|
aBorderFrame->mCanResize = PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
endX = endX + mNumCols;
|
|
|
|
for (; childX < endX; childX++) {
|
|
|
|
if (!CanChildResize(PR_FALSE, PR_TRUE, childX, (FRAMESET == aChildTypes[childX]))) {
|
|
|
|
aBorderFrame->mCanResize = PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-08-03 21:09:37 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHTMLFramesetFrame::VerifyTree() const
|
|
|
|
{
|
|
|
|
// XXX Completely disabled for now; once pseud-frames are reworked
|
|
|
|
// then we can turn it back on.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-09-03 05:16:27 +04:00
|
|
|
void
|
1999-11-24 09:03:41 +03:00
|
|
|
nsHTMLFramesetFrame::StartMouseDrag(nsIPresContext* aPresContext,
|
1999-03-10 09:13:35 +03:00
|
|
|
nsHTMLFramesetBorderFrame* aBorder,
|
|
|
|
nsGUIEvent* aEvent)
|
1998-09-03 05:16:27 +04:00
|
|
|
{
|
|
|
|
if (mMinDrag == 0) {
|
1999-02-12 20:45:58 +03:00
|
|
|
float p2t;
|
1999-11-24 09:03:41 +03:00
|
|
|
aPresContext->GetPixelsToTwips(&p2t);
|
1998-09-03 05:16:27 +04:00
|
|
|
mMinDrag = NSIntPixelsToTwips(2, p2t); // set min drag and min frame size to 2 pixels
|
|
|
|
}
|
|
|
|
|
1998-09-19 07:24:26 +04:00
|
|
|
#if 0
|
1998-09-03 05:16:27 +04:00
|
|
|
PRInt32 index;
|
|
|
|
IndexOf(aBorder, index);
|
|
|
|
NS_ASSERTION((nsnull != aBorder) && (index >= 0), "invalid dragger");
|
1998-09-19 07:24:26 +04:00
|
|
|
#endif
|
1998-09-03 05:16:27 +04:00
|
|
|
nsIView* view;
|
1999-11-24 09:03:41 +03:00
|
|
|
GetView(aPresContext, &view);
|
1998-09-03 05:16:27 +04:00
|
|
|
if (view) {
|
2001-12-01 17:31:45 +03:00
|
|
|
nsCOMPtr<nsIViewManager> viewMan;
|
|
|
|
view->GetViewManager(*getter_AddRefs(viewMan));
|
1998-09-03 05:16:27 +04:00
|
|
|
if (viewMan) {
|
|
|
|
PRBool ignore;
|
|
|
|
viewMan->GrabMouseEvents(view, ignore);
|
|
|
|
mDragger = aBorder;
|
1999-02-26 20:12:16 +03:00
|
|
|
|
1999-03-03 04:59:50 +03:00
|
|
|
//XXX This should go away! Border should have own view instead
|
2001-12-01 17:31:45 +03:00
|
|
|
viewMan->SetViewCheckChildEvents(view, PR_FALSE);
|
1999-03-03 04:59:50 +03:00
|
|
|
|
1999-06-11 05:18:50 +04:00
|
|
|
// The point isn't in frameset coords, but we're using it to compute
|
|
|
|
// moves relative to the start position.
|
|
|
|
mFirstDragPoint.MoveTo(aEvent->point.x, aEvent->point.y);
|
|
|
|
|
|
|
|
// Store the original frame sizes
|
|
|
|
if (mDragger->mVertical) {
|
|
|
|
mPrevNeighborOrigSize = mColSizes[mDragger->mPrevNeighbor];
|
|
|
|
mNextNeighborOrigSize = mColSizes[mDragger->mNextNeighbor];
|
|
|
|
} else {
|
|
|
|
mPrevNeighborOrigSize = mRowSizes[mDragger->mPrevNeighbor];
|
|
|
|
mNextNeighborOrigSize = mRowSizes[mDragger->mNextNeighbor];
|
|
|
|
}
|
1999-02-26 20:12:16 +03:00
|
|
|
|
1998-09-03 05:16:27 +04:00
|
|
|
gDragInProgress = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
1999-11-24 09:03:41 +03:00
|
|
|
nsHTMLFramesetFrame::MouseDrag(nsIPresContext* aPresContext,
|
1999-03-10 09:13:35 +03:00
|
|
|
nsGUIEvent* aEvent)
|
1998-09-03 05:16:27 +04:00
|
|
|
{
|
|
|
|
PRInt32 change; // measured positive from left-to-right or top-to-bottom
|
|
|
|
if (mDragger->mVertical) {
|
1999-06-11 05:18:50 +04:00
|
|
|
change = aEvent->point.x - mFirstDragPoint.x;
|
|
|
|
if (change > mNextNeighborOrigSize - mMinDrag) {
|
|
|
|
change = mNextNeighborOrigSize - mMinDrag;
|
|
|
|
} else if (change <= mMinDrag - mPrevNeighborOrigSize) {
|
|
|
|
change = mMinDrag - mPrevNeighborOrigSize;
|
1998-09-03 05:16:27 +04:00
|
|
|
}
|
1999-06-11 05:18:50 +04:00
|
|
|
mColSizes[mDragger->mPrevNeighbor] = mPrevNeighborOrigSize + change;
|
|
|
|
mColSizes[mDragger->mNextNeighbor] = mNextNeighborOrigSize - change;
|
1999-06-11 04:51:05 +04:00
|
|
|
|
|
|
|
// Recompute the specs from the new sizes.
|
2001-11-06 03:44:25 +03:00
|
|
|
nscoord width = mRect.width - (mNumCols - 1) * GetBorderWidth(aPresContext, PR_TRUE);
|
1999-11-24 09:03:41 +03:00
|
|
|
GenerateRowCol(aPresContext, width, mNumCols, mColSpecs, mColSizes);
|
1998-09-03 05:16:27 +04:00
|
|
|
} else {
|
1999-06-11 05:18:50 +04:00
|
|
|
change = aEvent->point.y - mFirstDragPoint.y;
|
|
|
|
if (change > mNextNeighborOrigSize - mMinDrag) {
|
|
|
|
change = mNextNeighborOrigSize - mMinDrag;
|
|
|
|
} else if (change <= mMinDrag - mPrevNeighborOrigSize) {
|
|
|
|
change = mMinDrag - mPrevNeighborOrigSize;
|
1998-09-03 05:16:27 +04:00
|
|
|
}
|
1999-06-11 05:18:50 +04:00
|
|
|
mRowSizes[mDragger->mPrevNeighbor] = mPrevNeighborOrigSize + change;
|
|
|
|
mRowSizes[mDragger->mNextNeighbor] = mNextNeighborOrigSize - change;
|
1999-06-11 04:51:05 +04:00
|
|
|
|
|
|
|
// Recompute the specs from the new sizes.
|
2001-11-06 03:44:25 +03:00
|
|
|
nscoord height = mRect.height - (mNumRows - 1) * GetBorderWidth(aPresContext, PR_TRUE);
|
1999-11-24 09:03:41 +03:00
|
|
|
GenerateRowCol(aPresContext, height, mNumRows, mRowSpecs, mRowSizes);
|
1998-09-03 05:16:27 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (change != 0) {
|
1999-03-10 09:13:35 +03:00
|
|
|
mDrag.Reset(mDragger->mVertical, mDragger->mPrevNeighbor, change, this);
|
2001-06-19 12:29:13 +04:00
|
|
|
nsIFrame* parentFrame = nsnull;
|
|
|
|
GetParent((nsIFrame**)&parentFrame);
|
|
|
|
if (!parentFrame) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-02-12 20:45:58 +03:00
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
1999-11-24 09:03:41 +03:00
|
|
|
aPresContext->GetShell(getter_AddRefs(shell));
|
2001-06-19 12:29:13 +04:00
|
|
|
if (!shell) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
parentFrame->ReflowDirtyChild(shell, this);
|
|
|
|
|
|
|
|
// Update the view immediately (make drag appear snappier)
|
2000-04-05 04:10:26 +04:00
|
|
|
nsCOMPtr<nsIViewManager> vm;
|
|
|
|
shell->GetViewManager(getter_AddRefs(vm));
|
|
|
|
if (vm) {
|
|
|
|
nsIView* root;
|
|
|
|
vm->GetRootView(root);
|
|
|
|
if (root) {
|
2001-12-01 17:31:45 +03:00
|
|
|
vm->UpdateView(root, NS_VMREFRESH_IMMEDIATE);
|
2000-04-05 04:10:26 +04:00
|
|
|
}
|
|
|
|
}
|
1998-09-03 05:16:27 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-10-26 08:44:41 +04:00
|
|
|
nsHTMLFramesetFrame::EndMouseDrag(nsIPresContext* aPresContext)
|
1998-09-03 05:16:27 +04:00
|
|
|
{
|
|
|
|
nsIView* view;
|
1999-10-26 08:44:41 +04:00
|
|
|
GetView(aPresContext, &view);
|
1998-09-03 05:16:27 +04:00
|
|
|
if (view) {
|
2001-12-01 17:31:45 +03:00
|
|
|
nsCOMPtr<nsIViewManager> viewMan;
|
|
|
|
view->GetViewManager(*getter_AddRefs(viewMan));
|
1998-09-03 05:16:27 +04:00
|
|
|
if (viewMan) {
|
|
|
|
mDragger = nsnull;
|
|
|
|
PRBool ignore;
|
|
|
|
viewMan->GrabMouseEvents(nsnull, ignore);
|
1999-03-03 04:59:50 +03:00
|
|
|
//XXX This should go away! Border should have own view instead
|
2001-12-01 17:31:45 +03:00
|
|
|
viewMan->SetViewCheckChildEvents(view, PR_TRUE);
|
1998-09-03 05:16:27 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
gDragInProgress = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
1998-09-10 03:30:30 +04:00
|
|
|
nsresult
|
1999-12-05 02:49:50 +03:00
|
|
|
NS_NewHTMLFramesetFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
|
1998-07-16 03:42:14 +04:00
|
|
|
{
|
1999-05-12 02:03:29 +04:00
|
|
|
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
|
|
|
if (nsnull == aNewFrame) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1999-12-05 02:49:50 +03:00
|
|
|
nsHTMLFramesetFrame* it = new (aPresShell) nsHTMLFramesetFrame;
|
1999-05-12 02:03:29 +04:00
|
|
|
if (!it) {
|
1998-07-16 03:42:14 +04:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1999-05-12 02:03:29 +04:00
|
|
|
*aNewFrame = it;
|
1998-07-16 03:42:14 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-07-27 09:59:37 +04:00
|
|
|
/*******************************************************************************
|
|
|
|
* nsHTMLFramesetBorderFrame
|
|
|
|
******************************************************************************/
|
1999-03-10 09:13:35 +03:00
|
|
|
nsHTMLFramesetBorderFrame::nsHTMLFramesetBorderFrame(PRInt32 aWidth,
|
|
|
|
PRBool aVertical,
|
|
|
|
PRBool aVisibility)
|
1998-12-03 09:31:43 +03:00
|
|
|
: nsLeafFrame(), mWidth(aWidth), mVertical(aVertical), mVisibility(aVisibility)
|
1998-07-27 09:59:37 +04:00
|
|
|
{
|
2001-11-02 05:19:49 +03:00
|
|
|
mVisibilityOverride = PR_FALSE;
|
1999-04-13 04:56:23 +04:00
|
|
|
mCanResize = PR_TRUE;
|
|
|
|
mColor = NO_COLOR;
|
|
|
|
mPrevNeighbor = 0;
|
|
|
|
mNextNeighbor = 0;
|
1998-07-27 09:59:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsHTMLFramesetBorderFrame::~nsHTMLFramesetBorderFrame()
|
|
|
|
{
|
2000-10-29 02:17:53 +04:00
|
|
|
//printf("nsHTMLFramesetBorderFrame destructor %p \n", this);
|
1998-07-27 09:59:37 +04:00
|
|
|
}
|
|
|
|
|
1999-03-10 09:13:35 +03:00
|
|
|
void nsHTMLFramesetBorderFrame::GetDesiredSize(nsIPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize)
|
1998-07-27 09:59:37 +04:00
|
|
|
{
|
1999-01-06 02:31:18 +03:00
|
|
|
aDesiredSize.width = aReflowState.availableWidth;
|
|
|
|
aDesiredSize.height = aReflowState.availableHeight;
|
1998-07-27 09:59:37 +04:00
|
|
|
aDesiredSize.ascent = aDesiredSize.width;
|
|
|
|
aDesiredSize.descent = 0;
|
|
|
|
}
|
|
|
|
|
1998-07-31 01:25:35 +04:00
|
|
|
void nsHTMLFramesetBorderFrame::SetVisibility(PRBool aVisibility)
|
|
|
|
{
|
|
|
|
mVisibility = aVisibility;
|
|
|
|
}
|
|
|
|
|
1998-09-03 05:16:27 +04:00
|
|
|
void nsHTMLFramesetBorderFrame::SetColor(nscolor aColor)
|
|
|
|
{
|
|
|
|
mColor = aColor;
|
|
|
|
}
|
|
|
|
|
1998-07-31 01:25:35 +04:00
|
|
|
|
1998-07-27 09:59:37 +04:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsHTMLFramesetBorderFrame::Reflow(nsIPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-07-27 09:59:37 +04:00
|
|
|
{
|
2000-04-22 01:51:35 +04:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsHTMLFramesetBorderFrame", aReflowState.reason);
|
1999-11-24 09:03:41 +03:00
|
|
|
GetDesiredSize(aPresContext, aReflowState, aDesiredSize);
|
1998-07-27 09:59:37 +04:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-07-16 03:42:14 +04:00
|
|
|
|
1998-07-27 09:59:37 +04:00
|
|
|
NS_METHOD
|
1999-11-24 09:03:41 +03:00
|
|
|
nsHTMLFramesetBorderFrame::Paint(nsIPresContext* aPresContext,
|
1998-07-27 09:59:37 +04:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
1998-12-18 18:54:23 +03:00
|
|
|
const nsRect& aDirtyRect,
|
2001-09-19 16:35:19 +04:00
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
PRUint32 aFlags)
|
1998-07-27 09:59:37 +04:00
|
|
|
{
|
1999-03-26 03:39:35 +03:00
|
|
|
if (NS_FRAME_PAINT_LAYER_FOREGROUND != aWhichLayer) {
|
1998-12-18 18:54:23 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-10-29 02:17:53 +04:00
|
|
|
//printf("border frame paint %X (%d,%d,%d,%d) \n", this, aDirtyRect.x, aDirtyRect.y, aDirtyRect.width, aDirtyRect.height);
|
1998-12-04 21:05:30 +03:00
|
|
|
nscolor WHITE = NS_RGB(255, 255, 255);
|
|
|
|
nscolor bgColor = NS_RGB(200,200,200);
|
|
|
|
nscolor fgColor = NS_RGB(0,0,0);
|
|
|
|
nscolor hltColor = NS_RGB(255,255,255);
|
|
|
|
nscolor sdwColor = NS_RGB(128,128,128);
|
|
|
|
|
|
|
|
nsILookAndFeel * lookAndFeel;
|
2001-01-04 23:44:42 +03:00
|
|
|
if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, NS_GET_IID(nsILookAndFeel), (void**)&lookAndFeel)) {
|
1998-12-04 21:05:30 +03:00
|
|
|
lookAndFeel->GetColor(nsILookAndFeel::eColor_WidgetBackground, bgColor);
|
|
|
|
lookAndFeel->GetColor(nsILookAndFeel::eColor_WidgetForeground, fgColor);
|
|
|
|
lookAndFeel->GetColor(nsILookAndFeel::eColor_Widget3DShadow, sdwColor);
|
|
|
|
lookAndFeel->GetColor(nsILookAndFeel::eColor_Widget3DHighlight, hltColor);
|
1998-12-21 19:52:17 +03:00
|
|
|
NS_RELEASE(lookAndFeel);
|
1998-12-04 21:05:30 +03:00
|
|
|
}
|
1998-08-06 23:40:37 +04:00
|
|
|
|
1999-02-12 20:45:58 +03:00
|
|
|
float t2p;
|
1999-11-24 09:03:41 +03:00
|
|
|
aPresContext->GetTwipsToPixels(&t2p);
|
1999-02-12 20:45:58 +03:00
|
|
|
nscoord widthInPixels = NSTwipsToIntPixels(mWidth, t2p);
|
|
|
|
float p2t;
|
1999-11-24 09:03:41 +03:00
|
|
|
aPresContext->GetPixelsToTwips(&p2t);
|
1999-02-12 20:45:58 +03:00
|
|
|
nscoord pixelWidth = NSIntPixelsToTwips(1, p2t);
|
1998-08-06 23:40:37 +04:00
|
|
|
|
|
|
|
if (widthInPixels <= 0) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-07-27 09:59:37 +04:00
|
|
|
|
|
|
|
nscoord x0 = 0;
|
|
|
|
nscoord y0 = 0;
|
|
|
|
nscoord x1 = (mVertical) ? x0 : mRect.width;
|
|
|
|
nscoord y1 = (mVertical) ? mRect.height : x0;
|
|
|
|
|
1998-09-03 05:16:27 +04:00
|
|
|
nscolor color = WHITE;
|
2001-11-02 05:19:49 +03:00
|
|
|
if (mVisibility || mVisibilityOverride) {
|
1998-12-04 21:05:30 +03:00
|
|
|
color = (NO_COLOR == mColor) ? bgColor : mColor;
|
1998-09-03 05:16:27 +04:00
|
|
|
}
|
1998-08-06 23:40:37 +04:00
|
|
|
aRenderingContext.SetColor(color);
|
|
|
|
// draw grey or white first
|
|
|
|
for (int i = 0; i < widthInPixels; i++) {
|
1998-07-27 09:59:37 +04:00
|
|
|
aRenderingContext.DrawLine (x0, y0, x1, y1);
|
|
|
|
if (mVertical) {
|
1998-08-06 23:40:37 +04:00
|
|
|
x0 += pixelWidth;
|
1998-07-27 09:59:37 +04:00
|
|
|
x1 = x0;
|
|
|
|
} else {
|
1998-08-06 23:40:37 +04:00
|
|
|
y0 += pixelWidth;
|
1998-07-27 09:59:37 +04:00
|
|
|
y1 = y0;
|
|
|
|
}
|
|
|
|
}
|
1998-08-06 23:40:37 +04:00
|
|
|
|
2001-11-02 05:19:49 +03:00
|
|
|
if (!mVisibility && !mVisibilityOverride) {
|
1998-08-06 23:40:37 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (widthInPixels >= 5) {
|
1998-12-04 21:05:30 +03:00
|
|
|
aRenderingContext.SetColor(hltColor);
|
1998-08-06 23:40:37 +04:00
|
|
|
x0 = (mVertical) ? pixelWidth : 0;
|
|
|
|
y0 = (mVertical) ? 0 : pixelWidth;
|
|
|
|
x1 = (mVertical) ? x0 : mRect.width;
|
|
|
|
y1 = (mVertical) ? mRect.height : y0;
|
|
|
|
aRenderingContext.DrawLine(x0, y0, x1, y1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (widthInPixels >= 2) {
|
1998-12-04 21:05:30 +03:00
|
|
|
aRenderingContext.SetColor(sdwColor);
|
1998-08-06 23:40:37 +04:00
|
|
|
x0 = (mVertical) ? mRect.width - (2 * pixelWidth) : 0;
|
|
|
|
y0 = (mVertical) ? 0 : mRect.height - (2 * pixelWidth);
|
|
|
|
x1 = (mVertical) ? x0 : mRect.width;
|
|
|
|
y1 = (mVertical) ? mRect.height : y0;
|
|
|
|
aRenderingContext.DrawLine(x0, y0, x1, y1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (widthInPixels >= 1) {
|
1998-12-04 21:05:30 +03:00
|
|
|
aRenderingContext.SetColor(fgColor);
|
1998-08-06 23:40:37 +04:00
|
|
|
x0 = (mVertical) ? mRect.width - pixelWidth : 0;
|
|
|
|
y0 = (mVertical) ? 0 : mRect.height - pixelWidth;
|
|
|
|
x1 = (mVertical) ? x0 : mRect.width;
|
|
|
|
y1 = (mVertical) ? mRect.height : y0;
|
|
|
|
aRenderingContext.DrawLine(x0, y0, x1, y1);
|
|
|
|
}
|
|
|
|
|
1998-07-27 09:59:37 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-09-03 05:16:27 +04:00
|
|
|
|
1998-11-18 08:25:26 +03:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsHTMLFramesetBorderFrame::HandleEvent(nsIPresContext* aPresContext,
|
1999-03-10 09:13:35 +03:00
|
|
|
nsGUIEvent* aEvent,
|
1999-11-24 09:03:41 +03:00
|
|
|
nsEventStatus* aEventStatus)
|
1998-07-31 01:25:35 +04:00
|
|
|
{
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_ENSURE_ARG_POINTER(aEventStatus);
|
|
|
|
*aEventStatus = nsEventStatus_eIgnore;
|
1998-11-18 08:25:26 +03:00
|
|
|
|
|
|
|
//XXX Mouse setting logic removed. The remaining logic should also move.
|
1998-09-03 05:16:27 +04:00
|
|
|
if (!mCanResize) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-07-31 01:25:35 +04:00
|
|
|
switch (aEvent->message) {
|
1998-09-03 05:16:27 +04:00
|
|
|
case NS_MOUSE_LEFT_BUTTON_DOWN:
|
|
|
|
nsHTMLFramesetFrame* parentFrame = nsnull;
|
1999-02-10 04:36:30 +03:00
|
|
|
GetParent((nsIFrame**)&parentFrame);
|
1998-09-03 05:16:27 +04:00
|
|
|
parentFrame->StartMouseDrag(aPresContext, this, aEvent);
|
1999-11-24 09:03:41 +03:00
|
|
|
*aEventStatus = nsEventStatus_eConsumeNoDefault;
|
1998-07-31 01:25:35 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-11-18 08:25:26 +03:00
|
|
|
NS_IMETHODIMP
|
1999-10-26 08:44:41 +04:00
|
|
|
nsHTMLFramesetBorderFrame::GetFrameForPoint(nsIPresContext* aPresContext,
|
|
|
|
const nsPoint& aPoint,
|
2000-03-22 05:43:08 +03:00
|
|
|
nsFramePaintLayer aWhichLayer,
|
1998-11-18 08:25:26 +03:00
|
|
|
nsIFrame** aFrame)
|
|
|
|
{
|
2000-03-22 05:43:08 +03:00
|
|
|
if ( (aWhichLayer != NS_FRAME_PAINT_LAYER_FOREGROUND) ||
|
|
|
|
(!((mState & NS_FRAME_OUTSIDE_CHILDREN) || mRect.Contains(aPoint) )))
|
|
|
|
{
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
1998-11-18 08:25:26 +03:00
|
|
|
*aFrame = this;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsHTMLFramesetBorderFrame::GetCursor(nsIPresContext* aPresContext,
|
1999-03-10 09:13:35 +03:00
|
|
|
nsPoint& aPoint,
|
|
|
|
PRInt32& aCursor)
|
1998-11-18 08:25:26 +03:00
|
|
|
{
|
|
|
|
if (!mCanResize) {
|
|
|
|
aCursor = NS_STYLE_CURSOR_DEFAULT;
|
1999-03-10 09:13:35 +03:00
|
|
|
} else {
|
|
|
|
aCursor = (mVertical) ? NS_STYLE_CURSOR_W_RESIZE : NS_STYLE_CURSOR_N_RESIZE;
|
|
|
|
}
|
1998-11-18 08:25:26 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef DEBUG
|
2001-11-14 04:33:42 +03:00
|
|
|
NS_IMETHODIMP nsHTMLFramesetBorderFrame::GetFrameName(nsAString& aResult) const
|
1998-07-27 09:59:37 +04:00
|
|
|
{
|
2001-11-14 04:33:42 +03:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("FramesetBorder"), aResult);
|
1998-07-27 09:59:37 +04:00
|
|
|
}
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|
1998-07-16 03:42:14 +04:00
|
|
|
|
1998-08-06 02:24:56 +04:00
|
|
|
/*******************************************************************************
|
|
|
|
* nsHTMLFramesetBlankFrame
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
nsHTMLFramesetBlankFrame::~nsHTMLFramesetBlankFrame()
|
|
|
|
{
|
2000-10-29 02:17:53 +04:00
|
|
|
//printf("nsHTMLFramesetBlankFrame destructor %p \n", this);
|
1998-08-06 02:24:56 +04:00
|
|
|
}
|
|
|
|
|
1999-03-10 09:13:35 +03:00
|
|
|
void nsHTMLFramesetBlankFrame::GetDesiredSize(nsIPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
1999-03-10 09:13:35 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize)
|
1998-08-06 02:24:56 +04:00
|
|
|
{
|
1999-01-06 02:31:18 +03:00
|
|
|
aDesiredSize.width = aReflowState.availableWidth;
|
|
|
|
aDesiredSize.height = aReflowState.availableHeight;
|
1998-08-06 02:24:56 +04:00
|
|
|
aDesiredSize.ascent = aDesiredSize.width;
|
|
|
|
aDesiredSize.descent = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsHTMLFramesetBlankFrame::Reflow(nsIPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-08-06 02:24:56 +04:00
|
|
|
{
|
2000-04-22 01:51:35 +04:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsHTMLFramesetBlankFrame", aReflowState.reason);
|
1999-11-24 09:03:41 +03:00
|
|
|
GetDesiredSize(aPresContext, aReflowState, aDesiredSize);
|
1998-08-06 02:24:56 +04:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_METHOD
|
1999-11-24 09:03:41 +03:00
|
|
|
nsHTMLFramesetBlankFrame::Paint(nsIPresContext* aPresContext,
|
1998-08-06 02:24:56 +04:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
1998-12-18 18:54:23 +03:00
|
|
|
const nsRect& aDirtyRect,
|
2001-09-19 16:35:19 +04:00
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
PRUint32 aFlags)
|
1998-08-06 02:24:56 +04:00
|
|
|
{
|
1999-03-26 03:39:35 +03:00
|
|
|
if (NS_FRAME_PAINT_LAYER_FOREGROUND != aWhichLayer) {
|
1998-12-18 18:54:23 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-08-06 02:24:56 +04:00
|
|
|
nscolor white = NS_RGB(255,255,255);
|
|
|
|
aRenderingContext.SetColor (white);
|
|
|
|
// XXX FillRect doesn't seem to work
|
|
|
|
//aRenderingContext.FillRect (mRect);
|
|
|
|
|
1999-02-12 20:45:58 +03:00
|
|
|
float p2t;
|
1999-11-24 09:03:41 +03:00
|
|
|
aPresContext->GetPixelsToTwips(&p2t);
|
1998-08-06 02:24:56 +04:00
|
|
|
nscoord x0 = 0;
|
|
|
|
nscoord y0 = 0;
|
|
|
|
nscoord x1 = x0;
|
|
|
|
nscoord y1 = mRect.height;
|
|
|
|
nscoord pixel = NSIntPixelsToTwips(1, p2t);
|
|
|
|
|
|
|
|
aRenderingContext.SetColor(white);
|
|
|
|
for (int i = 0; i < mRect.width; i += pixel) {
|
|
|
|
aRenderingContext.DrawLine (x0, y0, x1, y1);
|
|
|
|
x0 += NSIntPixelsToTwips(1, p2t);
|
|
|
|
x1 = x0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef DEBUG
|
1999-10-26 08:44:41 +04:00
|
|
|
NS_IMETHODIMP nsHTMLFramesetBlankFrame::List(nsIPresContext* aPresContext,
|
|
|
|
FILE* out,
|
1999-03-10 09:13:35 +03:00
|
|
|
PRInt32 aIndent) const
|
1998-08-06 02:24:56 +04:00
|
|
|
{
|
|
|
|
for (PRInt32 i = aIndent; --i >= 0; ) fputs(" ", out); // Indent
|
1999-02-12 20:45:58 +03:00
|
|
|
fprintf(out, "%p BLANK \n", this);
|
1999-10-26 08:44:41 +04:00
|
|
|
return nsLeafFrame::List(aPresContext, out, aIndent);
|
1998-08-06 02:24:56 +04:00
|
|
|
}
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|