1998-09-10 21:23:31 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1998-09-10 21:23:31 +04:00
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* 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-09-10 21:23:31 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
1999-11-06 06:40:37 +03:00
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-02-12 20:45:58 +03:00
|
|
|
#include "nsCOMPtr.h"
|
1998-09-10 21:23:31 +04:00
|
|
|
#include "nsFrameSetFrame.h"
|
2004-04-30 03:34:19 +04:00
|
|
|
#include "nsContentUtils.h"
|
1998-09-25 01:37:45 +04:00
|
|
|
#include "nsIHTMLContent.h"
|
1998-09-10 21:23:31 +04:00
|
|
|
#include "nsLeafFrame.h"
|
|
|
|
#include "nsHTMLContainerFrame.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
1998-09-10 21:23:31 +04:00
|
|
|
#include "nsIPresShell.h"
|
1999-03-09 12:44:27 +03:00
|
|
|
#include "nsIComponentManager.h"
|
1998-09-10 21:23:31 +04:00
|
|
|
#include "nsIStreamListener.h"
|
|
|
|
#include "nsIURL.h"
|
|
|
|
#include "nsIDocument.h"
|
2003-09-27 08:18:26 +04:00
|
|
|
#include "nsINodeInfo.h"
|
1998-09-10 21:23:31 +04:00
|
|
|
#include "nsIView.h"
|
|
|
|
#include "nsIViewManager.h"
|
|
|
|
#include "nsWidgetsCID.h"
|
|
|
|
#include "nsViewsCID.h"
|
|
|
|
#include "nsHTMLAtoms.h"
|
|
|
|
#include "nsIScrollableView.h"
|
|
|
|
#include "nsStyleCoord.h"
|
|
|
|
#include "nsStyleConsts.h"
|
2003-02-22 03:32:13 +03:00
|
|
|
#include "nsStyleContext.h"
|
1998-09-10 21:23:31 +04:00
|
|
|
#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 "nsIServiceManager.h"
|
|
|
|
#include "nsIDOMMutationEvent.h"
|
|
|
|
#include "nsINameSpaceManager.h"
|
2002-11-17 18:37:56 +03:00
|
|
|
#include "nsCSSPseudoElements.h"
|
|
|
|
#include "nsCSSAnonBoxes.h"
|
2003-02-22 03:32:13 +03:00
|
|
|
#include "nsAutoPtr.h"
|
2004-01-28 03:18:22 +03:00
|
|
|
#include "nsStyleSet.h"
|
2001-07-16 06:40:48 +04:00
|
|
|
|
1998-09-10 21:23:31 +04:00
|
|
|
// masks for mEdgeVisibility
|
|
|
|
#define LEFT_VIS 0x0001
|
|
|
|
#define RIGHT_VIS 0x0002
|
|
|
|
#define TOP_VIS 0x0004
|
|
|
|
#define BOTTOM_VIS 0x0008
|
|
|
|
#define ALL_VIS 0x000F
|
|
|
|
#define NONE_VIS 0x0000
|
|
|
|
|
2004-04-30 03:34:19 +04:00
|
|
|
static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
|
1998-09-10 21:23:31 +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-09-10 21:23:31 +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-09-10 21:23:31 +04:00
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
NS_IMETHOD HandleEvent(nsPresContext* aPresContext,
|
1998-09-10 21:23:31 +04:00
|
|
|
nsGUIEvent* aEvent,
|
1999-11-24 09:03:41 +03:00
|
|
|
nsEventStatus* aEventStatus);
|
1998-09-10 21:23:31 +04:00
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
NS_IMETHOD GetFrameForPoint(nsPresContext* aPresContext,
|
1999-10-26 08:44:41 +04:00
|
|
|
const nsPoint& aPoint,
|
2000-03-22 05:43:08 +03:00
|
|
|
nsFramePaintLayer aWhichLayer,
|
1998-11-18 08:25:26 +03:00
|
|
|
nsIFrame** aFrame);
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
NS_IMETHOD GetCursor(nsPresContext* aPresContext,
|
1998-11-18 08:25:26 +03:00
|
|
|
nsPoint& aPoint,
|
|
|
|
PRInt32& aCursor);
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
NS_IMETHOD Paint(nsPresContext* aPresContext,
|
1998-09-10 21:23:31 +04:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
2001-09-19 16:35:19 +04:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
PRUint32 aFlags);
|
1998-09-10 21:23:31 +04:00
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
NS_IMETHOD Reflow(nsPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus);
|
1998-09-10 21:23:31 +04:00
|
|
|
|
2001-11-02 05:19:49 +03:00
|
|
|
PRBool GetVisibility() { return mVisibility || mVisibilityOverride; }
|
1998-09-10 21:23:31 +04:00
|
|
|
void SetVisibility(PRBool aVisibility);
|
|
|
|
void SetColor(nscolor aColor);
|
|
|
|
|
|
|
|
protected:
|
1998-12-03 09:31:43 +03:00
|
|
|
nsHTMLFramesetBorderFrame(PRInt32 aWidth, PRBool aVertical, PRBool aVisible);
|
1998-09-10 21:23:31 +04:00
|
|
|
virtual ~nsHTMLFramesetBorderFrame();
|
2004-08-01 03:15:21 +04:00
|
|
|
virtual void GetDesiredSize(nsPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
1998-10-01 08:46:11 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize);
|
1998-09-10 21:23:31 +04:00
|
|
|
PRInt32 mWidth;
|
2001-11-02 05:19:49 +03:00
|
|
|
PRPackedBool mVertical;
|
|
|
|
PRPackedBool mVisibility;
|
|
|
|
PRPackedBool mVisibilityOverride;
|
1998-09-10 21:23:31 +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;
|
|
|
|
friend class nsHTMLFramesetFrame;
|
|
|
|
};
|
|
|
|
/*******************************************************************************
|
|
|
|
* nsHTMLFramesetBlankFrame
|
|
|
|
******************************************************************************/
|
|
|
|
class nsHTMLFramesetBlankFrame : public nsLeafFrame {
|
|
|
|
|
|
|
|
public:
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef DEBUG
|
2004-08-01 03:15:21 +04:00
|
|
|
NS_IMETHOD List(nsPresContext* aPresContext, FILE* out = stdout, PRInt32 aIndent = 0) const;
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|
1998-09-10 21:23:31 +04:00
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
NS_IMETHOD Paint(nsPresContext* aPresContext,
|
1998-09-10 21:23:31 +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-09-10 21:23:31 +04:00
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
NS_IMETHOD Reflow(nsPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus);
|
1998-09-10 21:23:31 +04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~nsHTMLFramesetBlankFrame();
|
2004-08-01 03:15:21 +04:00
|
|
|
virtual void GetDesiredSize(nsPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
1999-03-10 09:13:35 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize);
|
1998-09-10 21:23:31 +04:00
|
|
|
friend class nsHTMLFramesetFrame;
|
|
|
|
friend class nsHTMLFrameset;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* nsHTMLFramesetFrame
|
|
|
|
******************************************************************************/
|
|
|
|
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-09-10 21:23:31 +04:00
|
|
|
|
1998-12-03 09:31:43 +03:00
|
|
|
nsHTMLFramesetFrame::nsHTMLFramesetFrame()
|
|
|
|
: nsHTMLContainerFrame()
|
1998-09-10 21:23:31 +04:00
|
|
|
{
|
1999-04-13 04:56:23 +04:00
|
|
|
mNumRows = 0;
|
|
|
|
mRowSizes = nsnull;
|
|
|
|
mNumCols = 0;
|
|
|
|
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;
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsHTMLFramesetFrame::~nsHTMLFramesetFrame()
|
|
|
|
{
|
2004-04-30 03:34:19 +04:00
|
|
|
delete[] mRowSizes;
|
|
|
|
delete[] mColSizes;
|
2002-04-17 08:17:16 +04:00
|
|
|
delete[] mVerBorders;
|
|
|
|
delete[] mHorBorders;
|
|
|
|
|
2004-04-30 03:34:19 +04:00
|
|
|
nsContentUtils::UnregisterPrefCallback(kFrameResizePref,
|
|
|
|
FrameResizePrefCallback, this);
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
|
1999-03-10 09:13:35 +03:00
|
|
|
nsresult nsHTMLFramesetFrame::QueryInterface(const nsIID& aIID,
|
|
|
|
void** aInstancePtr)
|
1998-09-10 21:23:31 +04:00
|
|
|
{
|
|
|
|
if (NULL == aInstancePtr) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
2004-04-30 03:34:19 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (aIID.Equals(NS_GET_IID(nsHTMLFramesetFrame))) {
|
2001-11-02 05:19:49 +03:00
|
|
|
*aInstancePtr = (void*)this;
|
|
|
|
return NS_OK;
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return nsHTMLContainerFrame::QueryInterface(aIID, aInstancePtr);
|
|
|
|
}
|
|
|
|
|
2004-04-30 03:34:19 +04:00
|
|
|
// static
|
|
|
|
int
|
|
|
|
nsHTMLFramesetFrame::FrameResizePrefCallback(const char* aPref, void* aClosure)
|
2001-11-02 05:19:49 +03:00
|
|
|
{
|
2004-04-30 03:34:19 +04:00
|
|
|
nsHTMLFramesetFrame *frame =
|
|
|
|
NS_REINTERPRET_CAST(nsHTMLFramesetFrame *, aClosure);
|
2001-11-02 05:19:49 +03:00
|
|
|
|
2004-04-30 03:34:19 +04:00
|
|
|
nsIDocument* doc = frame->mContent->GetDocument();
|
|
|
|
mozAutoDocUpdate updateBatch(doc, UPDATE_CONTENT_MODEL, PR_TRUE);
|
|
|
|
if (doc) {
|
|
|
|
doc->AttributeWillChange(frame->mContent,
|
|
|
|
kNameSpaceID_None,
|
|
|
|
nsHTMLAtoms::frameborder);
|
|
|
|
}
|
2001-11-02 05:19:49 +03:00
|
|
|
|
2004-04-30 03:34:19 +04:00
|
|
|
frame->mForceFrameResizability =
|
|
|
|
nsContentUtils::GetBoolPref(kFrameResizePref,
|
|
|
|
frame->mForceFrameResizability);
|
|
|
|
|
|
|
|
frame->RecalculateBorderResize();
|
|
|
|
if (doc) {
|
|
|
|
doc->AttributeChanged(frame->mContent,
|
|
|
|
kNameSpaceID_None,
|
|
|
|
nsHTMLAtoms::frameborder,
|
|
|
|
nsIDOMMutationEvent::MODIFICATION);
|
2001-11-02 05:19:49 +03:00
|
|
|
}
|
2004-04-30 03:34:19 +04:00
|
|
|
|
|
|
|
return 0;
|
2001-11-02 05:19:49 +03:00
|
|
|
}
|
|
|
|
|
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
|
2004-08-01 03:15:21 +04:00
|
|
|
nsHTMLFramesetFrame::Init(nsPresContext* aPresContext,
|
1999-03-10 09:13:35 +03:00
|
|
|
nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aContext,
|
1999-03-10 09:13:35 +03:00
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
|
|
|
nsHTMLContainerFrame::Init(aPresContext, aContent, aParent,
|
|
|
|
aContext, aPrevInFlow);
|
|
|
|
// find the highest ancestor that is a frameset
|
|
|
|
nsresult rv = NS_OK;
|
2003-07-05 19:30:50 +04:00
|
|
|
nsIFrame* parentFrame = GetParent();
|
1999-03-10 09:13:35 +03:00
|
|
|
mTopLevelFrameset = (nsHTMLFramesetFrame*)this;
|
|
|
|
while (parentFrame) {
|
2003-04-22 03:57:47 +04:00
|
|
|
nsHTMLFramesetFrame* frameset = nsnull;
|
|
|
|
CallQueryInterface(parentFrame, &frameset);
|
|
|
|
|
|
|
|
if (frameset) {
|
1999-03-10 09:13:35 +03:00
|
|
|
mTopLevelFrameset = frameset;
|
2003-07-05 19:30:50 +04:00
|
|
|
parentFrame = parentFrame->GetParent();
|
1999-03-10 09:13:35 +03:00
|
|
|
} 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;
|
2003-04-22 03:57:47 +04:00
|
|
|
nsresult result = CallCreateInstance(kViewCID, &view);
|
2003-07-05 19:30:50 +04:00
|
|
|
nsIViewManager* viewMan = aPresContext->GetViewManager();
|
1999-11-19 18:33:29 +03:00
|
|
|
|
2003-09-23 21:05:29 +04:00
|
|
|
nsIView *parView = GetAncestorWithView()->GetView();
|
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);
|
2003-07-05 19:30:50 +04:00
|
|
|
SetView(view);
|
1999-11-19 18:33:29 +03:00
|
|
|
|
2003-12-21 08:36:36 +03:00
|
|
|
nsIPresShell *shell = aPresContext->PresShell();
|
2001-10-07 04:19:01 +04:00
|
|
|
|
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();
|
|
|
|
|
2002-08-06 05:06:50 +04:00
|
|
|
// Get the rows= cols= data
|
|
|
|
nsCOMPtr<nsIFrameSetElement> ourContent(do_QueryInterface(mContent));
|
|
|
|
NS_ASSERTION(ourContent, "Someone gave us a broken frameset element!");
|
|
|
|
const nsFramesetSpec* rowSpecs = nsnull;
|
|
|
|
const nsFramesetSpec* colSpecs = nsnull;
|
|
|
|
result = ourContent->GetRowSpec(&mNumRows, &rowSpecs);
|
|
|
|
NS_ENSURE_SUCCESS(result, result);
|
|
|
|
result = ourContent->GetColSpec(&mNumCols, &colSpecs);
|
|
|
|
NS_ENSURE_SUCCESS(result, result);
|
2001-10-07 04:19:01 +04:00
|
|
|
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;
|
2003-09-27 08:18:26 +04:00
|
|
|
|
|
|
|
// number of any type of children
|
|
|
|
PRUint32 numChildren = mContent->GetChildCount();
|
|
|
|
|
|
|
|
for (PRUint32 childX = 0; childX < numChildren; childX++) {
|
2001-10-07 04:19:01 +04:00
|
|
|
if (mChildCount == numCells) { // we have more <frame> or <frameset> than cells
|
|
|
|
break;
|
|
|
|
}
|
2003-09-27 08:18:26 +04:00
|
|
|
nsIContent *child = mContent->GetChildAt(childX);
|
|
|
|
|
2001-10-07 04:19:01 +04:00
|
|
|
if (!child->IsContentOfType(nsIContent::eHTML))
|
|
|
|
continue;
|
2003-09-27 08:18:26 +04:00
|
|
|
|
2003-11-19 04:20:56 +03:00
|
|
|
nsIAtom *tag = child->Tag();
|
2002-05-23 04:00:34 +04:00
|
|
|
if (tag == nsHTMLAtoms::frameset || tag == nsHTMLAtoms::frame) {
|
2003-02-22 03:32:13 +03:00
|
|
|
nsRefPtr<nsStyleContext> kidSC;
|
2002-05-23 04:00:34 +04:00
|
|
|
nsresult result;
|
2001-10-07 04:19:01 +04:00
|
|
|
|
2004-01-28 03:18:22 +03:00
|
|
|
kidSC = shell->StyleSet()->ResolveStyleFor(child, mStyleContext);
|
2002-05-23 04:00:34 +04:00
|
|
|
if (tag == nsHTMLAtoms::frameset) {
|
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
|
2004-01-10 08:36:32 +03:00
|
|
|
result = NS_NewSubDocumentFrame(shell, &frame);
|
2001-10-07 04:19:01 +04:00
|
|
|
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
|
2003-12-21 08:36:36 +03:00
|
|
|
nsHTMLFramesetBlankFrame* blankFrame = new (shell) nsHTMLFramesetBlankFrame;
|
2003-02-22 03:32:13 +03:00
|
|
|
nsRefPtr<nsStyleContext> pseudoStyleContext;
|
2004-01-28 03:18:22 +03:00
|
|
|
pseudoStyleContext = shell->StyleSet()->ResolvePseudoStyleFor(nsnull,
|
|
|
|
nsCSSAnonBoxes::framesetBlank,
|
|
|
|
mStyleContext);
|
2001-10-07 04:19:01 +04:00
|
|
|
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];
|
|
|
|
}
|
|
|
|
|
2003-09-13 23:42:43 +04:00
|
|
|
if (actual > 0) {
|
|
|
|
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];
|
|
|
|
}
|
|
|
|
} else if (aNumIndicies != 0) {
|
|
|
|
// All the specs say zero width, but we have to fill up space
|
|
|
|
// somehow. Distribute it equally.
|
|
|
|
nscoord width = NSToCoordRound((float)aDesired / (float)aNumIndicies);
|
|
|
|
actual = width * aNumIndicies;
|
|
|
|
for (i = 0; i < aNumIndicies; i++) {
|
|
|
|
aItems[aIndicies[i]] = width;
|
|
|
|
}
|
1998-11-28 21:59:38 +03:00
|
|
|
}
|
|
|
|
|
2003-09-13 23:42:43 +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-09-10 21:23:31 +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-09-10 21:23:31 +04:00
|
|
|
*/
|
2004-08-01 03:15:21 +04:00
|
|
|
void nsHTMLFramesetFrame::CalculateRowCol(nsPresContext* aPresContext,
|
2002-08-06 05:06:50 +04:00
|
|
|
nscoord aSize,
|
|
|
|
PRInt32 aNumSpecs,
|
|
|
|
const nsFramesetSpec* aSpecs,
|
|
|
|
nscoord* aValues)
|
1998-09-10 21:23:31 +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];
|
|
|
|
|
2004-07-29 23:41:39 +04:00
|
|
|
float p2t = aPresContext->ScaledPixelsToTwips();
|
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-09-10 21:23:31 +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-09-10 21:23:31 +04:00
|
|
|
break;
|
|
|
|
case eFramesetUnit_Percent:
|
1998-11-28 21:59:38 +03:00
|
|
|
percent[numPercent] = i;
|
|
|
|
numPercent++;
|
1998-09-10 21:23:31 +04:00
|
|
|
break;
|
1998-11-28 21:59:38 +03:00
|
|
|
case eFramesetUnit_Relative:
|
|
|
|
relative[numRelative] = i;
|
|
|
|
numRelative++;
|
|
|
|
relativeSums += aSpecs[i].mValue;
|
1998-09-10 21:23:31 +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-09-10 21:23:31 +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-09-10 21:23:31 +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-09-10 21:23:31 +04:00
|
|
|
}
|
1998-12-01 01:37:52 +03:00
|
|
|
|
|
|
|
delete [] fixed; delete [] percent; delete [] relative;
|
1998-09-10 21:23:31 +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.
|
|
|
|
*/
|
2004-08-01 03:15:21 +04:00
|
|
|
void nsHTMLFramesetFrame::GenerateRowCol(nsPresContext* aPresContext,
|
2002-08-06 05:06:50 +04:00
|
|
|
nscoord aSize,
|
|
|
|
PRInt32 aNumSpecs,
|
|
|
|
const nsFramesetSpec* aSpecs,
|
|
|
|
nscoord* aValues,
|
|
|
|
nsString& aNewAttr)
|
1999-06-11 04:51:05 +04:00
|
|
|
{
|
|
|
|
float t2p;
|
2004-02-11 07:57:07 +03:00
|
|
|
t2p = aPresContext->TwipsToPixels();
|
1999-06-11 04:51:05 +04:00
|
|
|
PRInt32 i;
|
|
|
|
|
2002-08-06 05:06:50 +04:00
|
|
|
for (i = 0; i < aNumSpecs; i++) {
|
|
|
|
if (!aNewAttr.IsEmpty())
|
|
|
|
aNewAttr.Append(PRUnichar(','));
|
|
|
|
|
1999-06-11 04:51:05 +04:00
|
|
|
switch (aSpecs[i].mUnit) {
|
|
|
|
case eFramesetUnit_Fixed:
|
2002-08-06 05:06:50 +04:00
|
|
|
aNewAttr.AppendInt(NSToCoordRound(t2p * aValues[i]));
|
1999-06-11 04:51:05 +04:00
|
|
|
break;
|
|
|
|
case eFramesetUnit_Percent: // XXX Only accurate to 1%, need 1 pixel
|
|
|
|
case eFramesetUnit_Relative:
|
2002-08-06 05:06:50 +04:00
|
|
|
// Add 0.5 to the percentage to make rounding work right.
|
|
|
|
aNewAttr.AppendInt(PRUint32((100.0*aValues[i])/aSize + 0.5));
|
|
|
|
aNewAttr.Append(PRUnichar('%'));
|
1999-06-11 04:51:05 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
PRInt32 nsHTMLFramesetFrame::GetBorderWidth(nsPresContext* aPresContext,
|
2001-11-06 03:44:25 +03:00
|
|
|
PRBool aTakeForcingIntoAccount)
|
1998-09-10 21:23:31 +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;
|
|
|
|
}
|
|
|
|
}
|
2004-07-29 23:41:39 +04:00
|
|
|
float p2t = aPresContext->ScaledPixelsToTwips();
|
1998-09-10 21:23:31 +04:00
|
|
|
nsHTMLValue htmlVal;
|
2002-05-23 04:00:34 +04:00
|
|
|
nsCOMPtr<nsIHTMLContent> content(do_QueryInterface(mContent));
|
|
|
|
|
|
|
|
if (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;
|
2004-02-11 03:38:12 +03:00
|
|
|
if (eHTMLUnit_Integer == unit) {
|
1998-09-10 21:23:31 +04:00
|
|
|
intVal = htmlVal.GetIntValue();
|
2004-02-11 03:38:12 +03:00
|
|
|
}
|
1998-09-10 21:23:31 +04:00
|
|
|
if (intVal < 0) {
|
|
|
|
intVal = 0;
|
|
|
|
}
|
2002-05-23 04:00:34 +04:00
|
|
|
|
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 21:23:31 +04:00
|
|
|
return NSIntPixelsToTwips(intVal, p2t);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-11-02 05:19:49 +03:00
|
|
|
if (mParentBorderWidth > 0 ||
|
2001-11-06 03:44:25 +03:00
|
|
|
(mParentBorderWidth == 0 && !forcing)) {
|
1998-09-10 21:23:31 +04:00
|
|
|
return mParentBorderWidth;
|
|
|
|
}
|
|
|
|
|
2001-11-02 05:19:49 +03:00
|
|
|
return NSIntPixelsToTwips(DEFAULT_BORDER_WIDTH_PX, p2t);
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PRIntn
|
|
|
|
nsHTMLFramesetFrame::GetSkipSides() const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsHTMLFramesetFrame::GetDesiredSize(nsPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
1999-03-10 09:13:35 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize)
|
1998-09-10 21:23:31 +04:00
|
|
|
{
|
|
|
|
nsHTMLFramesetFrame* framesetParent = GetFramesetParent(this);
|
|
|
|
if (nsnull == framesetParent) {
|
2004-02-01 13:09:07 +03:00
|
|
|
nsRect area = aPresContext->GetVisibleArea();
|
1998-09-10 21:23:31 +04:00
|
|
|
|
|
|
|
aDesiredSize.width = area.width;
|
|
|
|
aDesiredSize.height= area.height;
|
|
|
|
} else {
|
|
|
|
nsSize size;
|
|
|
|
framesetParent->GetSizeOfChild(this, size);
|
|
|
|
aDesiredSize.width = size.width;
|
|
|
|
aDesiredSize.height = size.height;
|
|
|
|
}
|
|
|
|
aDesiredSize.ascent = aDesiredSize.height;
|
|
|
|
aDesiredSize.descent = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
nsHTMLFramesetFrame* nsHTMLFramesetFrame::GetFramesetParent(nsIFrame* aChild)
|
|
|
|
{
|
|
|
|
nsHTMLFramesetFrame* parent = nsnull;
|
2003-07-05 19:30:50 +04:00
|
|
|
nsIContent* content = aChild->GetContent();
|
2002-05-23 04:00:34 +04:00
|
|
|
|
|
|
|
if (content) {
|
2003-07-29 01:25:13 +04:00
|
|
|
nsCOMPtr<nsIContent> contentParent = content->GetParent();
|
2002-05-23 04:00:34 +04:00
|
|
|
|
2003-11-19 04:20:56 +03:00
|
|
|
if (contentParent && contentParent->IsContentOfType(nsIContent::eHTML) &&
|
|
|
|
contentParent->Tag() == nsHTMLAtoms::frameset) {
|
|
|
|
nsIFrame* fptr = aChild->GetParent();
|
|
|
|
parent = (nsHTMLFramesetFrame*) fptr;
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
// only valid for non border children
|
1999-03-10 09:13:35 +03:00
|
|
|
void nsHTMLFramesetFrame::GetSizeOfChildAt(PRInt32 aIndexInParent,
|
|
|
|
nsSize& aSize,
|
|
|
|
nsPoint& aCellIndex)
|
1998-09-10 21:23:31 +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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// only valid for non border children
|
|
|
|
void nsHTMLFramesetFrame::GetSizeOfChild(nsIFrame* aChild,
|
1999-03-10 09:13:35 +03:00
|
|
|
nsSize& aSize)
|
1998-09-10 21:23:31 +04:00
|
|
|
{
|
|
|
|
// Reflow only creates children frames for <frameset> and <frame> content.
|
|
|
|
// this assumption is used here
|
|
|
|
int i = 0;
|
1999-01-16 01:53:39 +03:00
|
|
|
for (nsIFrame* child = mFrames.FirstChild(); child;
|
2003-07-05 19:30:50 +04:00
|
|
|
child = child->GetNextSibling()) {
|
1998-09-10 21:23:31 +04:00
|
|
|
if (aChild == child) {
|
|
|
|
nsPoint ignore;
|
|
|
|
GetSizeOfChildAt(i, aSize, ignore);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
aSize.width = 0;
|
|
|
|
aSize.height = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
NS_METHOD nsHTMLFramesetFrame::HandleEvent(nsPresContext* aPresContext,
|
1999-03-10 09:13:35 +03:00
|
|
|
nsGUIEvent* aEvent,
|
1999-11-24 09:03:41 +03:00
|
|
|
nsEventStatus* aEventStatus)
|
1998-09-10 21:23:31 +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;
|
2003-07-05 19:30:50 +04:00
|
|
|
nsIView* view = GetView();
|
1998-09-10 21:23:31 +04:00
|
|
|
if (view) {
|
2003-07-05 19:30:50 +04:00
|
|
|
nsIViewManager* viewMan = view->GetViewManager();
|
1998-09-10 21:23:31 +04:00
|
|
|
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-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
NS_RELEASE(viewMan);
|
1998-11-18 08:25:26 +03:00
|
|
|
}
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
1999-03-10 09:13:35 +03:00
|
|
|
return result;
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
1999-03-10 09:13:35 +03:00
|
|
|
#endif
|
1998-09-10 21:23:31 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsHTMLFramesetFrame::GetCursor(nsPresContext* 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
|
2004-08-01 03:15:21 +04:00
|
|
|
nsHTMLFramesetFrame::GetFrameForPoint(nsPresContext* aPresContext,
|
1999-10-26 08:44:41 +04:00
|
|
|
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
|
2004-08-01 03:15:21 +04:00
|
|
|
nsHTMLFramesetFrame::Paint(nsPresContext* aPresContext,
|
1998-09-10 21:23:31 +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-09-10 21:23:31 +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-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1998-10-02 08:10:00 +04:00
|
|
|
nsHTMLFramesetFrame::ReflowPlaceChild(nsIFrame* aChild,
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsPoint& aOffset,
|
|
|
|
nsSize& aSize,
|
|
|
|
nsPoint* aCellIndex)
|
1998-09-10 21:23:31 +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-09-10 21:23:31 +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-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
|
1999-02-25 18:38:29 +03:00
|
|
|
static
|
2001-12-07 22:40:07 +03:00
|
|
|
nsFrameborder GetFrameBorderHelper(nsIHTMLContent* aContent)
|
1998-09-10 21:23:31 +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 21:23:31 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return eFrameborder_Notset;
|
|
|
|
}
|
|
|
|
|
2001-12-07 22:40:07 +03:00
|
|
|
nsFrameborder nsHTMLFramesetFrame::GetFrameBorder()
|
1998-09-10 21:23:31 +04:00
|
|
|
{
|
|
|
|
nsFrameborder result = eFrameborder_Notset;
|
2002-05-23 04:00:34 +04:00
|
|
|
nsCOMPtr<nsIHTMLContent> content(do_QueryInterface(mContent));
|
|
|
|
|
2001-12-07 22:40:07 +03:00
|
|
|
if (content) {
|
|
|
|
result = GetFrameBorderHelper(content);
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
if (eFrameborder_Notset == result) {
|
|
|
|
return mParentFrameborder;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2001-12-07 22:40:07 +03:00
|
|
|
nsFrameborder nsHTMLFramesetFrame::GetFrameBorder(nsIContent* aContent)
|
1998-09-10 21:23:31 +04:00
|
|
|
{
|
|
|
|
nsFrameborder result = eFrameborder_Notset;
|
2002-05-23 04:00:34 +04:00
|
|
|
|
2002-08-22 06:11:05 +04:00
|
|
|
nsCOMPtr<nsIHTMLContent> content(do_QueryInterface(aContent));
|
2002-05-23 04:00:34 +04:00
|
|
|
|
|
|
|
if (content) {
|
2001-12-07 22:40:07 +03:00
|
|
|
result = GetFrameBorderHelper(content);
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
if (eFrameborder_Notset == result) {
|
2001-12-07 22:40:07 +03:00
|
|
|
return GetFrameBorder();
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
nscolor nsHTMLFramesetFrame::GetBorderColor()
|
|
|
|
{
|
2002-05-23 04:00:34 +04:00
|
|
|
nsCOMPtr<nsIHTMLContent> content(do_QueryInterface(mContent));
|
|
|
|
|
|
|
|
if (content) {
|
1998-09-10 21:23:31 +04:00
|
|
|
nsHTMLValue value;
|
1998-12-20 04:21:23 +03:00
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE == (content->GetHTMLAttribute(nsHTMLAtoms::bordercolor, value))) {
|
2004-02-11 03:38:12 +03:00
|
|
|
nscolor color;
|
|
|
|
if (value.GetColorValue(color)) {
|
|
|
|
return color;
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-02-11 03:38:12 +03:00
|
|
|
|
|
|
|
return mParentBorderColor;
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nscolor nsHTMLFramesetFrame::GetBorderColor(nsIContent* aContent)
|
|
|
|
{
|
2002-05-23 04:00:34 +04:00
|
|
|
nsCOMPtr<nsIHTMLContent> content(do_QueryInterface(aContent));
|
|
|
|
|
|
|
|
if (content) {
|
1998-09-10 21:23:31 +04:00
|
|
|
nsHTMLValue value;
|
1998-12-20 04:21:23 +03:00
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE == (content->GetHTMLAttribute(nsHTMLAtoms::bordercolor, value))) {
|
2004-02-11 03:38:12 +03:00
|
|
|
nscolor color;
|
|
|
|
if (value.GetColorValue(color)) {
|
|
|
|
return color;
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-02-11 03:38:12 +03:00
|
|
|
return GetBorderColor();
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsHTMLFramesetFrame::Reflow(nsPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-09-10 21:23:31 +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);
|
2003-12-21 08:36:36 +03:00
|
|
|
nsIPresShell *shell = aPresContext->PresShell();
|
2004-01-28 03:18:22 +03:00
|
|
|
nsStyleSet *styleSet = shell->StyleSet();
|
2003-12-21 08:36:36 +03:00
|
|
|
|
2000-10-29 02:17:53 +04:00
|
|
|
//printf("FramesetFrame2::Reflow %X (%d,%d) \n", this, aReflowState.availableWidth, aReflowState.availableHeight);
|
1998-09-10 21:23:31 +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) {
|
2004-04-30 03:34:19 +04:00
|
|
|
nsContentUtils::RegisterPrefCallback(kFrameResizePref,
|
|
|
|
FrameResizePrefCallback, this);
|
|
|
|
mForceFrameResizability =
|
|
|
|
nsContentUtils::GetBoolPref(kFrameResizePref);
|
2001-11-02 05:19:49 +03:00
|
|
|
}
|
|
|
|
|
1998-09-10 21:23:31 +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-09-10 21:23:31 +04:00
|
|
|
width -= (mNumCols - 1) * borderWidth;
|
2000-09-21 09:07:06 +04:00
|
|
|
if (width < 0) width = 0;
|
|
|
|
|
1998-09-10 21:23:31 +04:00
|
|
|
height -= (mNumRows - 1) * borderWidth;
|
2000-09-21 09:07:06 +04:00
|
|
|
if (height < 0) height = 0;
|
1998-09-10 21:23:31 +04:00
|
|
|
|
2002-08-06 05:06:50 +04:00
|
|
|
if (!mDrag.mActive) {
|
|
|
|
nsCOMPtr<nsIFrameSetElement> ourContent(do_QueryInterface(mContent));
|
|
|
|
NS_ASSERTION(ourContent, "Someone gave us a broken frameset element!");
|
|
|
|
const nsFramesetSpec* rowSpecs = nsnull;
|
|
|
|
const nsFramesetSpec* colSpecs = nsnull;
|
|
|
|
ourContent->GetRowSpec(&mNumRows, &rowSpecs);
|
|
|
|
ourContent->GetColSpec(&mNumCols, &colSpecs);
|
|
|
|
CalculateRowCol(aPresContext, width, mNumCols, colSpecs, mColSizes);
|
|
|
|
CalculateRowCol(aPresContext, height, mNumRows, rowSpecs, mRowSizes);
|
1998-09-10 21:23:31 +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-09-10 21:23:31 +04:00
|
|
|
if (firstTime) {
|
|
|
|
verBordersVis = new PRBool[mNumCols];
|
|
|
|
verBorderColors = new nscolor[mNumCols];
|
|
|
|
for (int verX = 0; verX < mNumCols; verX++) {
|
|
|
|
verBordersVis[verX] = PR_FALSE;
|
|
|
|
verBorderColors[verX] = NO_COLOR;
|
|
|
|
}
|
2001-10-07 04:19:01 +04:00
|
|
|
|
1998-09-10 21:23:31 +04:00
|
|
|
horBordersVis = new PRBool[mNumRows];
|
|
|
|
horBorderColors = new nscolor[mNumRows];
|
|
|
|
for (int horX = 0; horX < mNumRows; horX++) {
|
|
|
|
horBordersVis[horX] = PR_FALSE;
|
|
|
|
horBorderColors[horX] = NO_COLOR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// reflow the children
|
|
|
|
PRInt32 lastRow = 0;
|
|
|
|
PRInt32 lastCol = 0;
|
|
|
|
PRInt32 borderChildX = mNonBorderChildCount; // index of border children
|
|
|
|
nsHTMLFramesetBorderFrame* borderFrame = nsnull;
|
|
|
|
nsPoint offset(0,0);
|
|
|
|
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-09-10 21:23:31 +04:00
|
|
|
|
|
|
|
for (PRInt32 childX = 0; childX < mNonBorderChildCount; childX++) {
|
|
|
|
nsPoint cellIndex;
|
|
|
|
GetSizeOfChildAt(childX, size, cellIndex);
|
|
|
|
|
|
|
|
if (lastRow != cellIndex.y) { // changed to next row
|
|
|
|
offset.x = 0;
|
|
|
|
offset.y += lastSize.height;
|
2001-11-02 05:19:49 +03:00
|
|
|
if (firstTime) { // create horizontal border
|
2003-12-21 08:36:36 +03:00
|
|
|
borderFrame = new (shell) nsHTMLFramesetBorderFrame(borderWidth,
|
|
|
|
PR_FALSE,
|
|
|
|
PR_FALSE);
|
2003-02-22 03:32:13 +03:00
|
|
|
nsRefPtr<nsStyleContext> pseudoStyleContext;
|
2004-01-28 03:18:22 +03:00
|
|
|
pseudoStyleContext = styleSet->ResolvePseudoStyleFor(mContent,
|
|
|
|
nsCSSPseudoElements::horizontalFramesetBorder,
|
|
|
|
mStyleContext);
|
2001-11-02 05:19:49 +03:00
|
|
|
borderFrame->Init(aPresContext, mContent, this, pseudoStyleContext, nsnull);
|
|
|
|
|
|
|
|
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-09-10 21:23:31 +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-09-10 21:23:31 +04:00
|
|
|
} else {
|
2001-11-02 05:19:49 +03:00
|
|
|
if (cellIndex.x > 0) { // moved to next col in same row
|
1998-09-10 21:23:31 +04:00
|
|
|
if (0 == cellIndex.y) { // in 1st row
|
|
|
|
if (firstTime) { // create vertical border
|
2003-12-21 08:36:36 +03:00
|
|
|
borderFrame = new (shell) nsHTMLFramesetBorderFrame(borderWidth,
|
|
|
|
PR_TRUE,
|
|
|
|
PR_FALSE);
|
2003-02-22 03:32:13 +03:00
|
|
|
nsRefPtr<nsStyleContext> pseudoStyleContext;
|
2004-01-28 03:18:22 +03:00
|
|
|
pseudoStyleContext = styleSet->ResolvePseudoStyleFor(mContent,
|
|
|
|
nsCSSPseudoElements::verticalFramesetBorder,
|
|
|
|
mStyleContext);
|
1999-02-25 06:27:57 +03:00
|
|
|
borderFrame->Init(aPresContext, mContent, this, pseudoStyleContext, nsnull);
|
1998-10-12 18:48:02 +04:00
|
|
|
|
1998-09-10 21:23:31 +04:00
|
|
|
mChildCount++;
|
|
|
|
lastChild->SetNextSibling(borderFrame);
|
|
|
|
lastChild = borderFrame;
|
2001-04-12 12:16:54 +04:00
|
|
|
mVerBorders[cellIndex.x-1] = borderFrame;
|
1998-09-10 21:23:31 +04:00
|
|
|
// set the neighbors for determining drag boundaries
|
|
|
|
borderFrame->mPrevNeighbor = lastCol;
|
|
|
|
borderFrame->mNextNeighbor = cellIndex.x;
|
|
|
|
} 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-09-10 21:23:31 +04:00
|
|
|
borderChildX++;
|
|
|
|
}
|
|
|
|
nsSize borderSize(borderWidth, aDesiredSize.height);
|
|
|
|
ReflowPlaceChild(borderFrame, aPresContext, aReflowState, offset, borderSize);
|
2001-11-02 05:19:49 +03:00
|
|
|
borderFrame = nsnull;
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
offset.x += borderWidth;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-03-10 09:13:35 +03:00
|
|
|
ReflowPlaceChild(child, aPresContext, aReflowState, offset, size, &cellIndex);
|
1998-09-10 21:23:31 +04:00
|
|
|
|
|
|
|
if (firstTime) {
|
|
|
|
PRInt32 childVis;
|
2001-10-07 04:19:01 +04:00
|
|
|
if (FRAMESET == mChildTypes[childX]) {
|
1998-09-10 21:23:31 +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-10 21:23:31 +04:00
|
|
|
childVis = ALL_VIS;
|
2001-10-07 04:19:01 +04:00
|
|
|
} else if (eFrameborder_No == mChildFrameborder[childX]) {
|
1998-09-10 21:23:31 +04:00
|
|
|
childVis = NONE_VIS;
|
|
|
|
} else { // notset
|
|
|
|
childVis = (eFrameborder_No == frameborder) ? NONE_VIS : ALL_VIS;
|
|
|
|
}
|
|
|
|
} else { // blank
|
|
|
|
childVis = NONE_VIS;
|
|
|
|
}
|
2001-10-07 04:19:01 +04:00
|
|
|
nsBorderColor childColors = mChildBorderColors[childX];
|
1998-09-10 21:23:31 +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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (0 == cellIndex.y) {
|
|
|
|
if (!(mEdgeVisibility & TOP_VIS)) {
|
|
|
|
mEdgeVisibility |= (TOP_VIS & childVis);
|
|
|
|
}
|
|
|
|
if (NO_COLOR == mEdgeColors.mTop) {
|
|
|
|
mEdgeColors.mTop = childColors.mTop;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mNumCols-1 == cellIndex.x) {
|
|
|
|
if (!(mEdgeVisibility & RIGHT_VIS)) {
|
|
|
|
mEdgeVisibility |= (RIGHT_VIS & childVis);
|
|
|
|
}
|
|
|
|
if (NO_COLOR == mEdgeColors.mRight) {
|
|
|
|
mEdgeColors.mRight = childColors.mRight;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mNumRows-1 == cellIndex.y) {
|
|
|
|
if (!(mEdgeVisibility & BOTTOM_VIS)) {
|
|
|
|
mEdgeVisibility |= (BOTTOM_VIS & childVis);
|
|
|
|
}
|
|
|
|
if (NO_COLOR == mEdgeColors.mBottom) {
|
|
|
|
mEdgeColors.mBottom = childColors.mBottom;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// set the visibility of borders that the child may affect
|
|
|
|
if (childVis & RIGHT_VIS) {
|
|
|
|
verBordersVis[cellIndex.x] = PR_TRUE;
|
|
|
|
}
|
|
|
|
if (childVis & BOTTOM_VIS) {
|
|
|
|
horBordersVis[cellIndex.y] = PR_TRUE;
|
|
|
|
}
|
|
|
|
if ((cellIndex.x > 0) && (childVis & LEFT_VIS)) {
|
|
|
|
verBordersVis[cellIndex.x-1] = PR_TRUE;
|
|
|
|
}
|
|
|
|
if ((cellIndex.y > 0) && (childVis & TOP_VIS)) {
|
|
|
|
horBordersVis[cellIndex.y-1] = PR_TRUE;
|
|
|
|
}
|
|
|
|
// 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-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
if (NO_COLOR == horBorderColors[cellIndex.y]) {
|
2001-10-07 04:19:01 +04:00
|
|
|
horBorderColors[cellIndex.y] = mChildBorderColors[childX].mBottom;
|
1998-09-10 21:23:31 +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-10 21:23:31 +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-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
lastRow = cellIndex.y;
|
|
|
|
lastCol = cellIndex.x;
|
|
|
|
lastSize = size;
|
|
|
|
offset.x += size.width;
|
2003-07-05 19:30:50 +04:00
|
|
|
child = child->GetNextSibling();
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (firstTime) {
|
|
|
|
nscolor childColor;
|
|
|
|
// set the visibility, color, mouse sensitivity of borders
|
|
|
|
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-10 21:23:31 +04:00
|
|
|
childColor = (NO_COLOR == verBorderColors[verX]) ? borderColor : verBorderColors[verX];
|
2001-04-12 12:16:54 +04:00
|
|
|
mVerBorders[verX]->SetColor(childColor);
|
1998-09-10 21:23:31 +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-10 21:23:31 +04:00
|
|
|
childColor = (NO_COLOR == horBorderColors[horX]) ? borderColor : horBorderColors[horX];
|
2001-04-12 12:16:54 +04:00
|
|
|
mHorBorders[horX]->SetColor(childColor);
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
delete[] verBordersVis;
|
|
|
|
delete[] verBorderColors;
|
|
|
|
delete[] horBordersVis;
|
|
|
|
delete[] horBorderColors;
|
2001-10-07 04:19:01 +04:00
|
|
|
delete[] mChildTypes;
|
|
|
|
delete[] mChildFrameborder;
|
|
|
|
delete[] mChildBorderColors;
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
|
2003-01-09 17:26:32 +03:00
|
|
|
if (aDesiredSize.mComputeMEW) {
|
|
|
|
aDesiredSize.mMaxElementWidth = aDesiredSize.width;
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
1999-03-10 09:13:35 +03:00
|
|
|
mDrag.UnSet();
|
2002-05-29 02:50:43 +04:00
|
|
|
|
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
1998-09-10 21:23:31 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsHTMLFramesetFrame::ChildIsFrameset(nsIFrame* aChild)
|
|
|
|
{
|
|
|
|
nsIFrame* childFrame = nsnull;
|
2002-04-17 08:17:16 +04:00
|
|
|
aChild->QueryInterface(NS_GET_IID(nsHTMLFramesetFrame), (void**)&childFrame);
|
1998-09-10 21:23:31 +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-10 21:23:31 +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-10 21:23:31 +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-10 21:23:31 +04:00
|
|
|
if (!CanChildResize(aVertical, aLeft, childX, ChildIsFrameset(child))) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsHTMLFramesetFrame::GetNoResize(nsIFrame* aChildFrame)
|
|
|
|
{
|
|
|
|
PRBool result = PR_FALSE;
|
2003-07-05 19:30:50 +04:00
|
|
|
nsIContent* content = aChildFrame->GetContent();
|
2002-05-23 04:00:34 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsIHTMLContent> htmlContent(do_QueryInterface(content));
|
|
|
|
|
|
|
|
if (htmlContent) {
|
|
|
|
nsHTMLValue value;
|
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE == htmlContent->GetHTMLAttribute(nsHTMLAtoms::noresize, value)) {
|
|
|
|
result = PR_TRUE;
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
1999-03-10 09:13:35 +03:00
|
|
|
nsHTMLFramesetFrame::CanChildResize(PRBool aVertical,
|
|
|
|
PRBool aLeft,
|
|
|
|
PRInt32 aChildX,
|
|
|
|
PRBool aFrameset)
|
1998-09-10 21:23:31 +04:00
|
|
|
{
|
1999-01-16 01:53:39 +03:00
|
|
|
nsIFrame* child = mFrames.FrameAt(aChildX);
|
1998-09-10 21:23:31 +04:00
|
|
|
if (aFrameset) {
|
|
|
|
return ((nsHTMLFramesetFrame*)child)->CanResize(aVertical, aLeft);
|
|
|
|
} else {
|
|
|
|
return !GetNoResize(child);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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];
|
2003-09-27 08:18:26 +04:00
|
|
|
PRUint32 childIndex, frameOrFramesetChildIndex = 0;
|
2001-04-12 12:16:54 +04:00
|
|
|
|
2003-09-27 08:18:26 +04:00
|
|
|
// number of any type of children
|
|
|
|
PRUint32 numChildren = mContent->GetChildCount();
|
2001-04-12 12:16:54 +04:00
|
|
|
for (childIndex = 0; childIndex < numChildren; childIndex++) {
|
2003-09-27 08:18:26 +04:00
|
|
|
nsIContent *child = mContent->GetChildAt(childIndex);
|
|
|
|
|
|
|
|
if (child->IsContentOfType(nsIContent::eHTML)) {
|
|
|
|
nsINodeInfo *ni = child->GetNodeInfo();
|
|
|
|
|
|
|
|
if (ni->Equals(nsHTMLAtoms::frameset)) {
|
2001-04-12 12:16:54 +04:00
|
|
|
childTypes[frameOrFramesetChildIndex++] = FRAMESET;
|
2003-09-27 08:18:26 +04:00
|
|
|
} else if (ni->Equals(nsHTMLAtoms::frame)) {
|
2001-04-12 12:16:54 +04:00
|
|
|
childTypes[frameOrFramesetChildIndex++] = FRAME;
|
|
|
|
}
|
|
|
|
// Don't overflow childTypes array
|
2003-09-27 08:18:26 +04:00
|
|
|
if (((PRInt32)frameOrFramesetChildIndex) >= numCells) {
|
2001-04-12 12:16:54 +04:00
|
|
|
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-10 21:23:31 +04:00
|
|
|
void
|
1999-03-10 09:13:35 +03:00
|
|
|
nsHTMLFramesetFrame::SetBorderResize(PRInt32* aChildTypes,
|
|
|
|
nsHTMLFramesetBorderFrame* aBorderFrame)
|
1998-09-10 21:23:31 +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-10 21:23:31 +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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsHTMLFramesetFrame::StartMouseDrag(nsPresContext* aPresContext,
|
1999-03-10 09:13:35 +03:00
|
|
|
nsHTMLFramesetBorderFrame* aBorder,
|
|
|
|
nsGUIEvent* aEvent)
|
1998-09-10 21:23:31 +04:00
|
|
|
{
|
|
|
|
if (mMinDrag == 0) {
|
1999-02-12 20:45:58 +03:00
|
|
|
float p2t;
|
2004-02-11 07:57:07 +03:00
|
|
|
p2t = aPresContext->PixelsToTwips();
|
1998-09-10 21:23:31 +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-10 21:23:31 +04:00
|
|
|
PRInt32 index;
|
|
|
|
IndexOf(aBorder, index);
|
|
|
|
NS_ASSERTION((nsnull != aBorder) && (index >= 0), "invalid dragger");
|
1998-09-19 07:24:26 +04:00
|
|
|
#endif
|
2003-07-05 19:30:50 +04:00
|
|
|
nsIView* view = GetView();
|
1998-09-10 21:23:31 +04:00
|
|
|
if (view) {
|
2003-07-05 19:30:50 +04:00
|
|
|
nsIViewManager* viewMan = view->GetViewManager();
|
1998-09-10 21:23:31 +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-10 21:23:31 +04:00
|
|
|
gDragInProgress = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsHTMLFramesetFrame::MouseDrag(nsPresContext* aPresContext,
|
1999-03-10 09:13:35 +03:00
|
|
|
nsGUIEvent* aEvent)
|
1998-09-10 21:23:31 +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-10 21:23:31 +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
|
|
|
|
2002-08-06 05:06:50 +04:00
|
|
|
if (change != 0) {
|
|
|
|
// Recompute the specs from the new sizes.
|
|
|
|
nscoord width = mRect.width - (mNumCols - 1) * GetBorderWidth(aPresContext, PR_TRUE);
|
|
|
|
nsCOMPtr<nsIFrameSetElement> ourContent(do_QueryInterface(mContent));
|
|
|
|
NS_ASSERTION(ourContent, "Someone gave us a broken frameset element!");
|
|
|
|
const nsFramesetSpec* colSpecs = nsnull;
|
|
|
|
ourContent->GetColSpec(&mNumCols, &colSpecs);
|
|
|
|
nsAutoString newColAttr;
|
|
|
|
GenerateRowCol(aPresContext, width, mNumCols, colSpecs, mColSizes,
|
|
|
|
newColAttr);
|
|
|
|
// Setting the attr will trigger a reflow
|
|
|
|
mContent->SetAttr(kNameSpaceID_None, nsHTMLAtoms::cols, newColAttr, PR_TRUE);
|
|
|
|
}
|
1998-09-10 21:23:31 +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-10 21:23:31 +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
|
|
|
|
2002-08-06 05:06:50 +04:00
|
|
|
if (change != 0) {
|
|
|
|
// Recompute the specs from the new sizes.
|
|
|
|
nscoord height = mRect.height - (mNumRows - 1) * GetBorderWidth(aPresContext, PR_TRUE);
|
|
|
|
nsCOMPtr<nsIFrameSetElement> ourContent(do_QueryInterface(mContent));
|
|
|
|
NS_ASSERTION(ourContent, "Someone gave us a broken frameset element!");
|
|
|
|
const nsFramesetSpec* rowSpecs = nsnull;
|
|
|
|
ourContent->GetRowSpec(&mNumRows, &rowSpecs);
|
|
|
|
nsAutoString newRowAttr;
|
|
|
|
GenerateRowCol(aPresContext, height, mNumRows, rowSpecs, mRowSizes,
|
|
|
|
newRowAttr);
|
|
|
|
// Setting the attr will trigger a reflow
|
|
|
|
mContent->SetAttr(kNameSpaceID_None, nsHTMLAtoms::rows, newRowAttr, PR_TRUE);
|
|
|
|
}
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (change != 0) {
|
1999-03-10 09:13:35 +03:00
|
|
|
mDrag.Reset(mDragger->mVertical, mDragger->mPrevNeighbor, change, this);
|
2003-07-05 19:30:50 +04:00
|
|
|
nsIFrame* parentFrame = GetParent();
|
2001-06-19 12:29:13 +04:00
|
|
|
if (!parentFrame) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update the view immediately (make drag appear snappier)
|
2003-07-05 19:30:50 +04:00
|
|
|
nsIViewManager* vm = aPresContext->GetViewManager();
|
2000-04-05 04:10:26 +04:00
|
|
|
if (vm) {
|
2004-05-17 20:29:13 +04:00
|
|
|
nsIView* root;
|
|
|
|
vm->GetRootView(root);
|
|
|
|
if (root) {
|
|
|
|
vm->UpdateView(root, NS_VMREFRESH_IMMEDIATE);
|
|
|
|
}
|
2000-04-05 04:10:26 +04:00
|
|
|
}
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsHTMLFramesetFrame::EndMouseDrag(nsPresContext* aPresContext)
|
1998-09-10 21:23:31 +04:00
|
|
|
{
|
2003-07-05 19:30:50 +04:00
|
|
|
nsIView* view = GetView();
|
1998-09-10 21:23:31 +04:00
|
|
|
if (view) {
|
2003-07-05 19:30:50 +04:00
|
|
|
nsIViewManager* viewMan = view->GetViewManager();
|
1998-09-10 21:23:31 +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-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
gDragInProgress = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
1999-12-05 02:49:50 +03:00
|
|
|
NS_NewHTMLFramesetFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
|
1998-09-10 21:23:31 +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-09-10 21:23:31 +04:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1999-05-12 02:03:29 +04:00
|
|
|
*aNewFrame = it;
|
1998-09-10 21:23:31 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* 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-09-10 21:23:31 +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-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsHTMLFramesetBorderFrame::~nsHTMLFramesetBorderFrame()
|
|
|
|
{
|
2000-10-29 02:17:53 +04:00
|
|
|
//printf("nsHTMLFramesetBorderFrame destructor %p \n", this);
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
void nsHTMLFramesetBorderFrame::GetDesiredSize(nsPresContext* aPresContext,
|
1999-03-10 09:13:35 +03:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize)
|
1998-09-10 21:23:31 +04:00
|
|
|
{
|
1999-01-06 02:31:18 +03:00
|
|
|
aDesiredSize.width = aReflowState.availableWidth;
|
|
|
|
aDesiredSize.height = aReflowState.availableHeight;
|
1998-09-10 21:23:31 +04:00
|
|
|
aDesiredSize.ascent = aDesiredSize.width;
|
|
|
|
aDesiredSize.descent = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsHTMLFramesetBorderFrame::SetVisibility(PRBool aVisibility)
|
|
|
|
{
|
|
|
|
mVisibility = aVisibility;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsHTMLFramesetBorderFrame::SetColor(nscolor aColor)
|
|
|
|
{
|
|
|
|
mColor = aColor;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsHTMLFramesetBorderFrame::Reflow(nsPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-09-10 21:23:31 +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-09-10 21:23:31 +04:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_METHOD
|
2004-08-01 03:15:21 +04:00
|
|
|
nsHTMLFramesetBorderFrame::Paint(nsPresContext* aPresContext,
|
1998-09-10 21:23:31 +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-09-10 21:23:31 +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-09-10 21:23:31 +04:00
|
|
|
|
1999-02-12 20:45:58 +03:00
|
|
|
float t2p;
|
2004-02-11 07:57:07 +03:00
|
|
|
t2p = aPresContext->TwipsToPixels();
|
1999-02-12 20:45:58 +03:00
|
|
|
nscoord widthInPixels = NSTwipsToIntPixels(mWidth, t2p);
|
|
|
|
float p2t;
|
2004-02-11 07:57:07 +03:00
|
|
|
p2t = aPresContext->PixelsToTwips();
|
1999-02-12 20:45:58 +03:00
|
|
|
nscoord pixelWidth = NSIntPixelsToTwips(1, p2t);
|
1998-09-10 21:23:31 +04:00
|
|
|
|
|
|
|
if (widthInPixels <= 0) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord x0 = 0;
|
|
|
|
nscoord y0 = 0;
|
|
|
|
nscoord x1 = (mVertical) ? x0 : mRect.width;
|
|
|
|
nscoord y1 = (mVertical) ? mRect.height : x0;
|
|
|
|
|
|
|
|
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-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
aRenderingContext.SetColor(color);
|
|
|
|
// draw grey or white first
|
|
|
|
for (int i = 0; i < widthInPixels; i++) {
|
|
|
|
aRenderingContext.DrawLine (x0, y0, x1, y1);
|
|
|
|
if (mVertical) {
|
|
|
|
x0 += pixelWidth;
|
|
|
|
x1 = x0;
|
|
|
|
} else {
|
|
|
|
y0 += pixelWidth;
|
|
|
|
y1 = y0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-11-02 05:19:49 +03:00
|
|
|
if (!mVisibility && !mVisibilityOverride) {
|
1998-09-10 21:23:31 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (widthInPixels >= 5) {
|
1998-12-04 21:05:30 +03:00
|
|
|
aRenderingContext.SetColor(hltColor);
|
1998-09-10 21:23:31 +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-09-10 21:23:31 +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-09-10 21:23:31 +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);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-11-18 08:25:26 +03:00
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsHTMLFramesetBorderFrame::HandleEvent(nsPresContext* aPresContext,
|
1999-03-10 09:13:35 +03:00
|
|
|
nsGUIEvent* aEvent,
|
1999-11-24 09:03:41 +03:00
|
|
|
nsEventStatus* aEventStatus)
|
1998-09-10 21:23:31 +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-10 21:23:31 +04:00
|
|
|
if (!mCanResize) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (aEvent->message) {
|
|
|
|
case NS_MOUSE_LEFT_BUTTON_DOWN:
|
2003-05-01 00:39:27 +04:00
|
|
|
nsHTMLFramesetFrame* parentFrame;
|
2003-07-05 19:30:50 +04:00
|
|
|
nsIFrame* fptr = GetParent();
|
2003-05-01 00:39:27 +04:00
|
|
|
parentFrame = (nsHTMLFramesetFrame*) fptr;
|
1998-09-10 21:23:31 +04:00
|
|
|
parentFrame->StartMouseDrag(aPresContext, this, aEvent);
|
1999-11-24 09:03:41 +03:00
|
|
|
*aEventStatus = nsEventStatus_eConsumeNoDefault;
|
1998-09-10 21:23:31 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-11-18 08:25:26 +03:00
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsHTMLFramesetBorderFrame::GetFrameForPoint(nsPresContext* aPresContext,
|
1999-10-26 08:44:41 +04:00
|
|
|
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
|
2004-08-01 03:15:21 +04:00
|
|
|
nsHTMLFramesetBorderFrame::GetCursor(nsPresContext* 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-09-10 21:23:31 +04:00
|
|
|
{
|
2001-11-14 04:33:42 +03:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("FramesetBorder"), aResult);
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|
1998-09-10 21:23:31 +04:00
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* nsHTMLFramesetBlankFrame
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
nsHTMLFramesetBlankFrame::~nsHTMLFramesetBlankFrame()
|
|
|
|
{
|
2000-10-29 02:17:53 +04:00
|
|
|
//printf("nsHTMLFramesetBlankFrame destructor %p \n", this);
|
1998-09-10 21:23:31 +04:00
|
|
|
}
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
void nsHTMLFramesetBlankFrame::GetDesiredSize(nsPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
1999-03-10 09:13:35 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize)
|
1998-09-10 21:23:31 +04:00
|
|
|
{
|
1999-01-06 02:31:18 +03:00
|
|
|
aDesiredSize.width = aReflowState.availableWidth;
|
|
|
|
aDesiredSize.height = aReflowState.availableHeight;
|
1998-09-10 21:23:31 +04:00
|
|
|
aDesiredSize.ascent = aDesiredSize.width;
|
|
|
|
aDesiredSize.descent = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsHTMLFramesetBlankFrame::Reflow(nsPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-09-10 21:23:31 +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-09-10 21:23:31 +04:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_METHOD
|
2004-08-01 03:15:21 +04:00
|
|
|
nsHTMLFramesetBlankFrame::Paint(nsPresContext* aPresContext,
|
1998-09-10 21:23:31 +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-09-10 21:23:31 +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-09-10 21:23:31 +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;
|
2004-02-11 07:57:07 +03:00
|
|
|
p2t = aPresContext->PixelsToTwips();
|
1998-09-10 21:23:31 +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
|
2004-08-01 03:15:21 +04:00
|
|
|
NS_IMETHODIMP nsHTMLFramesetBlankFrame::List(nsPresContext* aPresContext,
|
1999-10-26 08:44:41 +04:00
|
|
|
FILE* out,
|
1999-03-10 09:13:35 +03:00
|
|
|
PRInt32 aIndent) const
|
1998-09-10 21:23:31 +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-09-10 21:23:31 +04:00
|
|
|
}
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|