2010-08-24 11:06:07 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2006-03-29 22:29:03 +04:00
|
|
|
|
|
|
|
/* rendering object for HTML <frameset> elements */
|
|
|
|
|
2013-09-25 05:43:43 +04:00
|
|
|
#include "nsFrameSetFrame.h"
|
|
|
|
|
2012-12-15 03:58:45 +04:00
|
|
|
#include "mozilla/DebugOnly.h"
|
|
|
|
#include "mozilla/Likely.h"
|
|
|
|
|
2005-01-12 22:45:38 +03:00
|
|
|
#include "nsGenericHTMLElement.h"
|
2012-09-30 20:40:24 +04:00
|
|
|
#include "nsAttrValueInlines.h"
|
1998-07-16 03:42:14 +04:00
|
|
|
#include "nsLeafFrame.h"
|
2011-12-28 00:18:48 +04:00
|
|
|
#include "nsContainerFrame.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
1998-07-16 03:42:14 +04:00
|
|
|
#include "nsIPresShell.h"
|
2007-01-30 03:06:41 +03:00
|
|
|
#include "nsGkAtoms.h"
|
1998-09-10 03:30:30 +04:00
|
|
|
#include "nsStyleConsts.h"
|
2003-02-22 03:32:13 +03:00
|
|
|
#include "nsStyleContext.h"
|
1998-09-13 06:45:07 +04:00
|
|
|
#include "nsHTMLParts.h"
|
2011-04-08 05:04:40 +04:00
|
|
|
#include "nsRenderingContext.h"
|
2001-11-02 05:19:49 +03:00
|
|
|
#include "nsIDOMMutationEvent.h"
|
|
|
|
#include "nsINameSpaceManager.h"
|
2002-11-17 18:37:56 +03:00
|
|
|
#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"
|
2010-08-24 11:06:07 +04:00
|
|
|
#include "mozilla/dom/Element.h"
|
2006-01-26 05:29:17 +03:00
|
|
|
#include "nsDisplayList.h"
|
2006-07-02 11:23:10 +04:00
|
|
|
#include "nsNodeUtils.h"
|
2008-04-11 21:29:06 +04:00
|
|
|
#include "mozAutoDocUpdate.h"
|
2011-05-25 10:31:59 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
2012-12-21 18:06:50 +04:00
|
|
|
#include "mozilla/dom/HTMLFrameSetElement.h"
|
2011-09-09 06:27:13 +04:00
|
|
|
#include "mozilla/LookAndFeel.h"
|
2013-09-25 15:21:18 +04:00
|
|
|
#include "mozilla/MouseEvents.h"
|
2012-12-01 06:28:02 +04:00
|
|
|
#include "nsSubDocumentFrame.h"
|
2011-05-25 10:31:59 +04:00
|
|
|
|
|
|
|
using namespace mozilla;
|
2012-12-21 18:06:50 +04:00
|
|
|
using namespace mozilla::dom;
|
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
|
|
|
|
|
1999-03-10 09:13:35 +03:00
|
|
|
/*******************************************************************************
|
|
|
|
* nsFramesetDrag
|
|
|
|
******************************************************************************/
|
2012-12-03 23:47:10 +04:00
|
|
|
nsFramesetDrag::nsFramesetDrag()
|
1999-03-10 09:13:35 +03:00
|
|
|
{
|
|
|
|
UnSet();
|
|
|
|
}
|
|
|
|
|
2012-12-03 23:47:10 +04:00
|
|
|
void nsFramesetDrag::Reset(bool aVertical,
|
|
|
|
int32_t aIndex,
|
|
|
|
int32_t aChange,
|
|
|
|
nsHTMLFramesetFrame* aSource)
|
1999-03-10 09:13:35 +03:00
|
|
|
{
|
|
|
|
mVertical = aVertical;
|
|
|
|
mIndex = aIndex;
|
|
|
|
mChange = aChange;
|
|
|
|
mSource = aSource;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsFramesetDrag::UnSet()
|
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
mVertical = true;
|
1999-03-10 09:13:35 +03:00
|
|
|
mIndex = -1;
|
|
|
|
mChange = 0;
|
2012-07-30 18:20:58 +04:00
|
|
|
mSource = nullptr;
|
1999-03-10 09:13:35 +03:00
|
|
|
}
|
|
|
|
|
1998-07-27 09:59:37 +04:00
|
|
|
/*******************************************************************************
|
|
|
|
* nsHTMLFramesetBorderFrame
|
|
|
|
******************************************************************************/
|
2009-09-12 20:49:24 +04:00
|
|
|
class nsHTMLFramesetBorderFrame : public nsLeafFrame
|
|
|
|
{
|
1998-07-27 09:59:37 +04:00
|
|
|
public:
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
|
|
|
|
2014-01-06 03:31:14 +04:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-02-24 18:41:56 +04:00
|
|
|
virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE;
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|
1998-07-27 09:59:37 +04:00
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
virtual nsresult HandleEvent(nsPresContext* aPresContext,
|
2014-02-18 12:36:33 +04:00
|
|
|
WidgetGUIEvent* aEvent,
|
2014-02-24 18:41:56 +04:00
|
|
|
nsEventStatus* aEventStatus) MOZ_OVERRIDE;
|
1998-07-31 01:25:35 +04:00
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
virtual nsresult GetCursor(const nsPoint& aPoint,
|
2014-02-24 18:41:56 +04:00
|
|
|
nsIFrame::Cursor& aCursor) MOZ_OVERRIDE;
|
2012-12-03 23:47:10 +04:00
|
|
|
|
2013-02-14 15:12:27 +04:00
|
|
|
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists) MOZ_OVERRIDE;
|
1998-07-27 09:59:37 +04:00
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
virtual nsresult Reflow(nsPresContext* aPresContext,
|
2014-02-18 12:36:33 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
2014-02-24 18:41:56 +04:00
|
|
|
nsReflowStatus& aStatus) MOZ_OVERRIDE;
|
1998-07-27 09:59:37 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool GetVisibility() { return mVisibility || mVisibilityOverride; }
|
|
|
|
void SetVisibility(bool aVisibility);
|
1998-09-03 05:16:27 +04:00
|
|
|
void SetColor(nscolor aColor);
|
1998-07-31 01:25:35 +04:00
|
|
|
|
2011-04-08 05:04:40 +04:00
|
|
|
void PaintBorder(nsRenderingContext& aRenderingContext, nsPoint aPt);
|
2006-01-26 05:29:17 +03:00
|
|
|
|
1998-07-27 09:59:37 +04:00
|
|
|
protected:
|
2012-08-22 19:56:38 +04:00
|
|
|
nsHTMLFramesetBorderFrame(nsStyleContext* aContext, int32_t aWidth, bool aVertical, bool aVisible);
|
1998-07-27 09:59:37 +04:00
|
|
|
virtual ~nsHTMLFramesetBorderFrame();
|
2014-02-24 18:41:56 +04:00
|
|
|
virtual nscoord GetIntrinsicWidth() MOZ_OVERRIDE;
|
|
|
|
virtual nscoord GetIntrinsicHeight() MOZ_OVERRIDE;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
2009-05-12 14:13:09 +04:00
|
|
|
// the prev and next neighbors are indexes into the row (for a horizontal border) or col (for
|
|
|
|
// a vertical border) of nsHTMLFramesetFrames or nsHTMLFrames
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t mPrevNeighbor;
|
|
|
|
int32_t mNextNeighbor;
|
2009-05-12 14:13:09 +04:00
|
|
|
nscolor mColor;
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t mWidth;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mVertical;
|
|
|
|
bool mVisibility;
|
|
|
|
bool mVisibilityOverride;
|
|
|
|
bool mCanResize;
|
1998-07-27 09:59:37 +04:00
|
|
|
friend class nsHTMLFramesetFrame;
|
|
|
|
};
|
1998-08-06 02:24:56 +04:00
|
|
|
/*******************************************************************************
|
|
|
|
* nsHTMLFramesetBlankFrame
|
|
|
|
******************************************************************************/
|
2009-09-12 20:49:24 +04:00
|
|
|
class nsHTMLFramesetBlankFrame : public nsLeafFrame
|
|
|
|
{
|
1998-08-06 02:24:56 +04:00
|
|
|
public:
|
2013-04-04 03:35:07 +04:00
|
|
|
NS_DECL_QUERYFRAME_TARGET(nsHTMLFramesetBlankFrame)
|
|
|
|
NS_DECL_QUERYFRAME
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
|
|
|
|
2014-01-06 03:31:14 +04:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-02-24 18:41:56 +04:00
|
|
|
virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE
|
2013-04-30 22:38:52 +04:00
|
|
|
{
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("FramesetBlank"), aResult);
|
|
|
|
}
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|
1998-08-06 02:24:56 +04:00
|
|
|
|
2013-02-14 15:12:27 +04:00
|
|
|
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists) MOZ_OVERRIDE;
|
1998-08-06 02:24:56 +04:00
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
virtual nsresult Reflow(nsPresContext* aPresContext,
|
2014-02-18 12:36:33 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
2014-02-24 18:41:56 +04:00
|
|
|
nsReflowStatus& aStatus) MOZ_OVERRIDE;
|
1998-08-06 02:24:56 +04:00
|
|
|
|
|
|
|
protected:
|
2006-03-27 01:30:36 +04:00
|
|
|
nsHTMLFramesetBlankFrame(nsStyleContext* aContext) : nsLeafFrame(aContext) {}
|
1998-08-06 02:24:56 +04:00
|
|
|
virtual ~nsHTMLFramesetBlankFrame();
|
2014-02-24 18:41:56 +04:00
|
|
|
virtual nscoord GetIntrinsicWidth() MOZ_OVERRIDE;
|
|
|
|
virtual nscoord GetIntrinsicHeight() MOZ_OVERRIDE;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
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
|
|
|
|
******************************************************************************/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool nsHTMLFramesetFrame::gDragInProgress = 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
|
|
|
|
2006-03-27 01:30:36 +04:00
|
|
|
nsHTMLFramesetFrame::nsHTMLFramesetFrame(nsStyleContext* aContext)
|
2011-12-28 00:18:48 +04:00
|
|
|
: nsContainerFrame(aContext)
|
1998-07-16 03:42:14 +04:00
|
|
|
{
|
1999-04-13 04:56:23 +04:00
|
|
|
mNumRows = 0;
|
2012-07-30 18:20:58 +04:00
|
|
|
mRowSizes = nullptr;
|
1999-04-13 04:56:23 +04:00
|
|
|
mNumCols = 0;
|
2012-07-30 18:20:58 +04:00
|
|
|
mColSizes = nullptr;
|
1999-04-13 04:56:23 +04:00
|
|
|
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;
|
2007-02-07 10:46:44 +03:00
|
|
|
mMinDrag = nsPresContext::CSSPixelsToAppUnits(2);
|
1999-04-13 04:56:23 +04:00
|
|
|
mNonBorderChildCount = 0;
|
|
|
|
mNonBlankChildCount = 0;
|
2012-07-30 18:20:58 +04:00
|
|
|
mDragger = nullptr;
|
1999-04-13 04:56:23 +04:00
|
|
|
mChildCount = 0;
|
2012-07-30 18:20:58 +04:00
|
|
|
mTopLevelFrameset = nullptr;
|
1999-03-10 09:13:35 +03:00
|
|
|
mEdgeColors.Set(NO_COLOR);
|
2012-07-30 18:20:58 +04:00
|
|
|
mVerBorders = nullptr;
|
|
|
|
mHorBorders = nullptr;
|
|
|
|
mChildFrameborder = nullptr;
|
|
|
|
mChildBorderColors = nullptr;
|
2011-10-17 18:59:28 +04:00
|
|
|
mForceFrameResizability = false;
|
1998-07-16 03:42:14 +04:00
|
|
|
}
|
|
|
|
|
1998-07-20 22:52:40 +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-12-31 01:05:22 +03:00
|
|
|
delete[] mChildFrameborder;
|
|
|
|
delete[] mChildBorderColors;
|
2002-04-17 08:17:16 +04:00
|
|
|
|
2011-05-29 03:42:57 +04:00
|
|
|
Preferences::UnregisterCallback(FrameResizePrefCallback,
|
|
|
|
kFrameResizePref, this);
|
1998-07-20 22:52:40 +04:00
|
|
|
}
|
1998-07-16 03:42:14 +04:00
|
|
|
|
2009-01-12 22:20:59 +03:00
|
|
|
NS_QUERYFRAME_HEAD(nsHTMLFramesetFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsHTMLFramesetFrame)
|
2011-12-28 00:18:48 +04:00
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
|
1998-09-03 05:16:27 +04:00
|
|
|
|
2004-04-30 03:34:19 +04:00
|
|
|
// static
|
2013-12-11 03:10:01 +04:00
|
|
|
void
|
2004-04-30 03:34:19 +04:00
|
|
|
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 =
|
2007-07-08 11:08:04 +04:00
|
|
|
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();
|
2011-10-17 18:59:28 +04:00
|
|
|
mozAutoDocUpdate updateBatch(doc, UPDATE_CONTENT_MODEL, true);
|
2004-04-30 03:34:19 +04:00
|
|
|
if (doc) {
|
2010-08-24 11:06:20 +04:00
|
|
|
nsNodeUtils::AttributeWillChange(frame->GetContent()->AsElement(),
|
|
|
|
kNameSpaceID_None,
|
2009-06-29 22:36:25 +04:00
|
|
|
nsGkAtoms::frameborder,
|
|
|
|
nsIDOMMutationEvent::MODIFICATION);
|
2004-04-30 03:34:19 +04:00
|
|
|
}
|
2001-11-02 05:19:49 +03:00
|
|
|
|
2004-04-30 03:34:19 +04:00
|
|
|
frame->mForceFrameResizability =
|
2011-05-25 10:31:59 +04:00
|
|
|
Preferences::GetBool(kFrameResizePref, frame->mForceFrameResizability);
|
2004-04-30 03:34:19 +04:00
|
|
|
|
|
|
|
frame->RecalculateBorderResize();
|
|
|
|
if (doc) {
|
2010-08-24 11:06:07 +04:00
|
|
|
nsNodeUtils::AttributeChanged(frame->GetContent()->AsElement(),
|
2006-07-02 11:23:10 +04:00
|
|
|
kNameSpaceID_None,
|
2006-12-26 20:47:52 +03:00
|
|
|
nsGkAtoms::frameborder,
|
2009-12-11 01:36:04 +03:00
|
|
|
nsIDOMMutationEvent::MODIFICATION);
|
2001-11-02 05:19:49 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-20 05:47:48 +04:00
|
|
|
void
|
2006-03-09 21:55:21 +03:00
|
|
|
nsHTMLFramesetFrame::Init(nsIContent* aContent,
|
1999-03-10 09:13:35 +03:00
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
2011-12-28 00:18:48 +04:00
|
|
|
nsContainerFrame::Init(aContent, aParent, aPrevInFlow);
|
1999-03-10 09:13:35 +03:00
|
|
|
// find the highest ancestor that is a frameset
|
2003-07-05 19:30:50 +04:00
|
|
|
nsIFrame* parentFrame = GetParent();
|
2012-12-01 06:28:02 +04:00
|
|
|
mTopLevelFrameset = this;
|
1999-03-10 09:13:35 +03:00
|
|
|
while (parentFrame) {
|
2009-01-12 22:20:59 +03:00
|
|
|
nsHTMLFramesetFrame* frameset = do_QueryFrame(parentFrame);
|
2003-04-22 03:57:47 +04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
2009-03-11 18:43:08 +03:00
|
|
|
nsPresContext* presContext = PresContext();
|
|
|
|
nsIPresShell* shell = presContext->PresShell();
|
1999-11-19 18:33:29 +03:00
|
|
|
|
2001-12-07 22:40:07 +03:00
|
|
|
nsFrameborder frameborder = GetFrameBorder();
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t borderWidth = GetBorderWidth(presContext, false);
|
2001-10-07 04:19:01 +04:00
|
|
|
nscolor borderColor = GetBorderColor();
|
2012-12-03 23:47:10 +04:00
|
|
|
|
2002-08-06 05:06:50 +04:00
|
|
|
// Get the rows= cols= data
|
2012-12-21 18:06:50 +04:00
|
|
|
HTMLFrameSetElement* ourContent = HTMLFrameSetElement::FromContent(mContent);
|
2002-08-06 05:06:50 +04:00
|
|
|
NS_ASSERTION(ourContent, "Someone gave us a broken frameset element!");
|
2012-07-30 18:20:58 +04:00
|
|
|
const nsFramesetSpec* rowSpecs = nullptr;
|
|
|
|
const nsFramesetSpec* colSpecs = nullptr;
|
2013-03-20 05:47:48 +04:00
|
|
|
// GetRowSpec and GetColSpec can fail, but when they do they set
|
|
|
|
// mNumRows and mNumCols respectively to 0, so we deal with it fine.
|
|
|
|
ourContent->GetRowSpec(&mNumRows, &rowSpecs);
|
|
|
|
ourContent->GetColSpec(&mNumCols, &colSpecs);
|
2011-01-25 04:38:07 +03:00
|
|
|
|
|
|
|
// Maximum value of mNumRows and mNumCols is NS_MAX_FRAMESET_SPEC_COUNT
|
|
|
|
PR_STATIC_ASSERT(NS_MAX_FRAMESET_SPEC_COUNT < UINT_MAX / sizeof(nscoord));
|
2001-10-07 04:19:01 +04:00
|
|
|
mRowSizes = new nscoord[mNumRows];
|
|
|
|
mColSizes = new nscoord[mNumCols];
|
|
|
|
|
2011-01-25 04:38:07 +03:00
|
|
|
// Ensure we can't overflow numCells
|
2012-09-28 10:57:33 +04:00
|
|
|
PR_STATIC_ASSERT(NS_MAX_FRAMESET_SPEC_COUNT < INT32_MAX / NS_MAX_FRAMESET_SPEC_COUNT);
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t numCells = mNumRows*mNumCols;
|
2001-10-07 04:19:01 +04:00
|
|
|
|
2011-01-25 04:38:07 +03:00
|
|
|
PR_STATIC_ASSERT(NS_MAX_FRAMESET_SPEC_COUNT < UINT_MAX / sizeof(nsHTMLFramesetBorderFrame*));
|
2001-10-07 04:19:01 +04:00
|
|
|
mVerBorders = new nsHTMLFramesetBorderFrame*[mNumCols]; // 1 more than number of ver borders
|
2004-12-31 01:05:22 +03:00
|
|
|
|
2001-10-07 04:19:01 +04:00
|
|
|
for (int verX = 0; verX < mNumCols; verX++)
|
2012-07-30 18:20:58 +04:00
|
|
|
mVerBorders[verX] = nullptr;
|
2001-10-07 04:19:01 +04:00
|
|
|
|
|
|
|
mHorBorders = new nsHTMLFramesetBorderFrame*[mNumRows]; // 1 more than number of hor borders
|
2004-12-31 01:05:22 +03:00
|
|
|
|
2001-10-07 04:19:01 +04:00
|
|
|
for (int horX = 0; horX < mNumRows; horX++)
|
2012-07-30 18:20:58 +04:00
|
|
|
mHorBorders[horX] = nullptr;
|
2012-12-03 23:47:10 +04:00
|
|
|
|
2011-01-25 04:38:07 +03:00
|
|
|
PR_STATIC_ASSERT(NS_MAX_FRAMESET_SPEC_COUNT
|
2012-12-03 23:47:10 +04:00
|
|
|
< UINT_MAX / sizeof(int32_t) / NS_MAX_FRAMESET_SPEC_COUNT);
|
2011-01-25 04:38:07 +03:00
|
|
|
PR_STATIC_ASSERT(NS_MAX_FRAMESET_SPEC_COUNT
|
2012-12-03 23:47:10 +04:00
|
|
|
< UINT_MAX / sizeof(nsFrameborder) / NS_MAX_FRAMESET_SPEC_COUNT);
|
2011-01-25 04:38:07 +03:00
|
|
|
PR_STATIC_ASSERT(NS_MAX_FRAMESET_SPEC_COUNT
|
2012-12-03 23:47:10 +04:00
|
|
|
< UINT_MAX / sizeof(nsBorderColor) / NS_MAX_FRAMESET_SPEC_COUNT);
|
2011-01-25 04:38:07 +03:00
|
|
|
mChildFrameborder = new nsFrameborder[numCells];
|
2012-12-03 23:47:10 +04:00
|
|
|
mChildBorderColors = new nsBorderColor[numCells];
|
2001-10-07 04:19:01 +04:00
|
|
|
|
|
|
|
// create the children frames; skip content which isn't <frameset> or <frame>
|
|
|
|
mChildCount = 0; // number of <frame> or <frameset> children
|
|
|
|
nsIFrame* frame;
|
2003-09-27 08:18:26 +04:00
|
|
|
|
|
|
|
// number of any type of children
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t numChildren = mContent->GetChildCount();
|
2003-09-27 08:18:26 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t childX = 0; childX < numChildren; childX++) {
|
2001-10-07 04:19:01 +04:00
|
|
|
if (mChildCount == numCells) { // we have more <frame> or <frameset> than cells
|
2011-03-04 18:27:02 +03:00
|
|
|
// Clear the lazy bits in the remaining children. Also clear
|
|
|
|
// the restyle flags, like nsCSSFrameConstructor::ProcessChildren does.
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = childX; i < numChildren; i++) {
|
2011-03-04 18:27:02 +03:00
|
|
|
nsIContent *child = mContent->GetChildAt(i);
|
|
|
|
child->UnsetFlags(NODE_DESCENDANTS_NEED_FRAMES | NODE_NEEDS_FRAME);
|
|
|
|
if (child->IsElement()) {
|
|
|
|
child->UnsetFlags(ELEMENT_ALL_RESTYLE_FLAGS);
|
|
|
|
}
|
2010-05-12 04:30:42 +04:00
|
|
|
}
|
2001-10-07 04:19:01 +04:00
|
|
|
break;
|
|
|
|
}
|
2003-09-27 08:18:26 +04:00
|
|
|
nsIContent *child = mContent->GetChildAt(childX);
|
2010-05-12 04:30:42 +04:00
|
|
|
child->UnsetFlags(NODE_DESCENDANTS_NEED_FRAMES | NODE_NEEDS_FRAME);
|
2011-03-04 18:27:02 +03:00
|
|
|
// Also clear the restyle flags in the child like
|
|
|
|
// nsCSSFrameConstructor::ProcessChildren does.
|
|
|
|
if (child->IsElement()) {
|
|
|
|
child->UnsetFlags(ELEMENT_ALL_RESTYLE_FLAGS);
|
|
|
|
}
|
2003-09-27 08:18:26 +04:00
|
|
|
|
2007-03-05 03:11:23 +03:00
|
|
|
// IMPORTANT: This must match the conditions in
|
2012-12-03 23:47:10 +04:00
|
|
|
// nsCSSFrameConstructor::ContentAppended/Inserted/Removed
|
2009-08-25 00:02:07 +04:00
|
|
|
if (!child->IsHTML())
|
2001-10-07 04:19:01 +04:00
|
|
|
continue;
|
2003-09-27 08:18:26 +04:00
|
|
|
|
2003-11-19 04:20:56 +03:00
|
|
|
nsIAtom *tag = child->Tag();
|
2006-12-26 20:47:52 +03:00
|
|
|
if (tag == nsGkAtoms::frameset || tag == nsGkAtoms::frame) {
|
2003-02-22 03:32:13 +03:00
|
|
|
nsRefPtr<nsStyleContext> kidSC;
|
2001-10-07 04:19:01 +04:00
|
|
|
|
2010-04-30 17:12:06 +04:00
|
|
|
kidSC = shell->StyleSet()->ResolveStyleFor(child->AsElement(),
|
|
|
|
mStyleContext);
|
2006-12-26 20:47:52 +03:00
|
|
|
if (tag == nsGkAtoms::frameset) {
|
2006-03-27 01:30:36 +04:00
|
|
|
frame = NS_NewHTMLFramesetFrame(shell, kidSC);
|
2001-10-07 04:19:01 +04:00
|
|
|
|
|
|
|
nsHTMLFramesetFrame* childFrame = (nsHTMLFramesetFrame*)frame;
|
|
|
|
childFrame->SetParentFrameborder(frameborder);
|
|
|
|
childFrame->SetParentBorderWidth(borderWidth);
|
|
|
|
childFrame->SetParentBorderColor(borderColor);
|
2013-03-20 05:47:48 +04:00
|
|
|
frame->Init(child, this, nullptr);
|
2004-12-31 01:05:22 +03:00
|
|
|
|
2001-10-07 04:19:01 +04:00
|
|
|
mChildBorderColors[mChildCount].Set(childFrame->GetBorderColor());
|
|
|
|
} else { // frame
|
2006-03-27 01:30:36 +04:00
|
|
|
frame = NS_NewSubDocumentFrame(shell, kidSC);
|
2004-12-31 01:05:22 +03:00
|
|
|
|
2013-03-20 05:47:48 +04:00
|
|
|
frame->Init(child, this, nullptr);
|
2001-10-07 04:19:01 +04:00
|
|
|
|
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));
|
|
|
|
}
|
2009-12-25 00:20:05 +03:00
|
|
|
child->SetPrimaryFrame(frame);
|
2012-12-03 23:47:10 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
mFrames.AppendFrame(nullptr, frame);
|
2009-09-18 15:09:35 +04:00
|
|
|
|
2001-10-07 04:19:01 +04:00
|
|
|
mChildCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mNonBlankChildCount = mChildCount;
|
|
|
|
// add blank frames for frameset cells that had no content provided
|
|
|
|
for (int blankX = mChildCount; blankX < numCells; blankX++) {
|
2003-02-22 03:32:13 +03:00
|
|
|
nsRefPtr<nsStyleContext> pseudoStyleContext;
|
2006-03-27 01:30:36 +04:00
|
|
|
pseudoStyleContext = shell->StyleSet()->
|
2009-12-11 10:37:40 +03:00
|
|
|
ResolveAnonymousBoxStyle(nsCSSAnonBoxes::framesetBlank, mStyleContext);
|
2004-12-31 01:05:22 +03:00
|
|
|
|
2012-12-03 23:47:10 +04:00
|
|
|
// XXX the blank frame is using the content of its parent - at some point it
|
|
|
|
// should just have null content, if we support that
|
2006-03-27 01:30:36 +04:00
|
|
|
nsHTMLFramesetBlankFrame* blankFrame = new (shell) nsHTMLFramesetBlankFrame(pseudoStyleContext);
|
|
|
|
|
2013-03-20 05:47:48 +04:00
|
|
|
blankFrame->Init(mContent, this, nullptr);
|
2012-12-03 23:47:10 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
mFrames.AppendFrame(nullptr, blankFrame);
|
2009-09-18 15:09:35 +04:00
|
|
|
|
2001-10-07 04:19:01 +04:00
|
|
|
mChildBorderColors[mChildCount].Set(NO_COLOR);
|
|
|
|
mChildCount++;
|
|
|
|
}
|
|
|
|
|
|
|
|
mNonBorderChildCount = mChildCount;
|
1999-03-10 09:13:35 +03:00
|
|
|
}
|
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
nsresult
|
2011-08-25 00:54:30 +04:00
|
|
|
nsHTMLFramesetFrame::SetInitialChildList(ChildListID aListID,
|
2009-07-28 16:53:20 +04:00
|
|
|
nsFrameList& aChildList)
|
2009-01-19 21:31:31 +03:00
|
|
|
{
|
|
|
|
// We do this weirdness where we create our child frames in Init(). On the
|
2009-07-28 16:53:20 +04:00
|
|
|
// other hand, we're going to get a SetInitialChildList() with an empty list
|
|
|
|
// and null list name after the frame constructor is done creating us. So
|
|
|
|
// just ignore that call.
|
2011-08-25 00:54:30 +04:00
|
|
|
if (aListID == kPrincipalList && aChildList.IsEmpty()) {
|
2009-01-19 21:31:31 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-12-28 00:18:48 +04:00
|
|
|
return nsContainerFrame::SetInitialChildList(aListID, aChildList);
|
2009-01-19 21:31:31 +03:00
|
|
|
}
|
|
|
|
|
1998-11-28 21:59:38 +03:00
|
|
|
// XXX should this try to allocate twips based on an even pixel boundary?
|
2012-12-03 23:47:10 +04:00
|
|
|
void nsHTMLFramesetFrame::Scale(nscoord aDesired,
|
|
|
|
int32_t aNumIndicies,
|
|
|
|
int32_t* aIndicies,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aNumItems,
|
|
|
|
int32_t* aItems)
|
1998-11-28 21:59:38 +03:00
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t actual = 0;
|
|
|
|
int32_t i, j;
|
1998-11-28 21:59:38 +03:00
|
|
|
// 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) {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t 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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-12-03 23:47:10 +04:00
|
|
|
|
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
|
|
|
*/
|
2012-12-03 23:47:10 +04:00
|
|
|
void nsHTMLFramesetFrame::CalculateRowCol(nsPresContext* aPresContext,
|
|
|
|
nscoord aSize,
|
|
|
|
int32_t aNumSpecs,
|
|
|
|
const nsFramesetSpec* aSpecs,
|
2002-08-06 05:06:50 +04:00
|
|
|
nscoord* aValues)
|
1998-07-16 03:42:14 +04:00
|
|
|
{
|
2011-01-25 04:38:07 +03:00
|
|
|
// aNumSpecs maximum value is NS_MAX_FRAMESET_SPEC_COUNT
|
2012-08-22 19:56:38 +04:00
|
|
|
PR_STATIC_ASSERT(NS_MAX_FRAMESET_SPEC_COUNT < UINT_MAX / sizeof(int32_t));
|
2011-01-25 04:38:07 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t fixedTotal = 0;
|
|
|
|
int32_t numFixed = 0;
|
|
|
|
nsAutoArrayPtr<int32_t> fixed(new int32_t[aNumSpecs]);
|
|
|
|
int32_t numPercent = 0;
|
|
|
|
nsAutoArrayPtr<int32_t> percent(new int32_t[aNumSpecs]);
|
|
|
|
int32_t relativeSums = 0;
|
|
|
|
int32_t numRelative = 0;
|
|
|
|
nsAutoArrayPtr<int32_t> relative(new int32_t[aNumSpecs]);
|
2006-10-07 12:53:06 +04:00
|
|
|
|
2012-10-26 17:32:10 +04:00
|
|
|
if (MOZ_UNLIKELY(!fixed || !percent || !relative)) {
|
2006-10-07 12:53:06 +04:00
|
|
|
return; // NS_ERROR_OUT_OF_MEMORY
|
|
|
|
}
|
1998-11-28 21:59:38 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t i, j;
|
2012-12-03 23:47:10 +04:00
|
|
|
|
1998-11-28 21:59:38 +03:00
|
|
|
// initialize the fixed, percent, relative indices, allocate the fixed sizes and zero the others
|
2012-12-03 23:47:10 +04:00
|
|
|
for (i = 0; i < aNumSpecs; i++) {
|
1998-11-28 21:59:38 +03:00
|
|
|
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:
|
2007-02-07 10:46:44 +03:00
|
|
|
aValues[i] = nsPresContext::CSSPixelsToAppUnits(aSpecs[i].mValue);
|
1998-11-28 21:59:38 +03:00
|
|
|
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)
|
2012-12-03 23:47:10 +04:00
|
|
|
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
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t percentMax = aSize - fixedTotal;
|
|
|
|
int32_t percentTotal = 0;
|
1998-11-28 21:59:38 +03:00
|
|
|
// 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)
|
2012-12-03 23:47:10 +04:00
|
|
|
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
|
|
|
return;
|
1998-07-16 03:42:14 +04:00
|
|
|
}
|
1998-11-28 21:59:38 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t relativeMax = percentMax - percentTotal;
|
|
|
|
int32_t relativeTotal = 0;
|
1998-11-28 21:59:38 +03:00
|
|
|
// 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
|
2012-12-03 23:47:10 +04:00
|
|
|
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-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.
|
|
|
|
*/
|
2012-12-03 23:47:10 +04:00
|
|
|
void nsHTMLFramesetFrame::GenerateRowCol(nsPresContext* aPresContext,
|
|
|
|
nscoord aSize,
|
|
|
|
int32_t aNumSpecs,
|
2002-08-06 05:06:50 +04:00
|
|
|
const nsFramesetSpec* aSpecs,
|
|
|
|
nscoord* aValues,
|
|
|
|
nsString& aNewAttr)
|
1999-06-11 04:51:05 +04:00
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t i;
|
2012-12-03 23:47:10 +04:00
|
|
|
|
2002-08-06 05:06:50 +04:00
|
|
|
for (i = 0; i < aNumSpecs; i++) {
|
|
|
|
if (!aNewAttr.IsEmpty())
|
2014-01-04 19:02:17 +04:00
|
|
|
aNewAttr.Append(char16_t(','));
|
2012-12-03 23:47:10 +04:00
|
|
|
|
1999-06-11 04:51:05 +04:00
|
|
|
switch (aSpecs[i].mUnit) {
|
|
|
|
case eFramesetUnit_Fixed:
|
2007-02-07 10:46:44 +03:00
|
|
|
aNewAttr.AppendInt(nsPresContext::AppUnitsToIntCSSPixels(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.
|
2012-12-03 23:47:10 +04:00
|
|
|
aNewAttr.AppendInt(uint32_t((100.0*aValues[i])/aSize + 0.5));
|
2014-01-04 19:02:17 +04:00
|
|
|
aNewAttr.Append(char16_t('%'));
|
1999-06-11 04:51:05 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t nsHTMLFramesetFrame::GetBorderWidth(nsPresContext* aPresContext,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aTakeForcingIntoAccount)
|
1998-07-27 09:59:37 +04:00
|
|
|
{
|
2011-09-29 10:19:26 +04:00
|
|
|
bool forcing = mForceFrameResizability && aTakeForcingIntoAccount;
|
2012-12-03 23:47:10 +04:00
|
|
|
|
2001-11-06 03:44:25 +03:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2005-01-12 22:45:38 +03:00
|
|
|
nsGenericHTMLElement *content = nsGenericHTMLElement::FromContent(mContent);
|
2002-05-23 04:00:34 +04:00
|
|
|
|
|
|
|
if (content) {
|
2006-12-26 20:47:52 +03:00
|
|
|
const nsAttrValue* attr = content->GetParsedAttr(nsGkAtoms::border);
|
2005-01-25 03:02:58 +03:00
|
|
|
if (attr) {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t intVal = 0;
|
2005-01-25 03:02:58 +03:00
|
|
|
if (attr->Type() == nsAttrValue::eInteger) {
|
|
|
|
intVal = attr->GetIntegerValue();
|
|
|
|
if (intVal < 0) {
|
|
|
|
intVal = 0;
|
|
|
|
}
|
1998-09-10 03:30:30 +04:00
|
|
|
}
|
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;
|
|
|
|
}
|
2007-02-07 10:46:44 +03:00
|
|
|
return nsPresContext::CSSPixelsToAppUnits(intVal);
|
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;
|
|
|
|
}
|
|
|
|
|
2007-02-07 10:46:44 +03:00
|
|
|
return nsPresContext::CSSPixelsToAppUnits(DEFAULT_BORDER_WIDTH_PX);
|
1998-07-27 09:59:37 +04:00
|
|
|
}
|
|
|
|
|
2012-12-03 23:47:10 +04:00
|
|
|
void
|
|
|
|
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-07-16 03:42:14 +04:00
|
|
|
{
|
2012-12-01 06:28:02 +04:00
|
|
|
nsHTMLFramesetFrame* framesetParent = do_QueryFrame(GetParent());
|
2012-07-30 18:20:58 +04:00
|
|
|
if (nullptr == framesetParent) {
|
2006-11-24 11:12:17 +03:00
|
|
|
if (aPresContext->IsPaginated()) {
|
|
|
|
// XXX This needs to be changed when framesets paginate properly
|
2013-12-27 21:59:52 +04:00
|
|
|
aDesiredSize.Width() = aReflowState.AvailableWidth();
|
|
|
|
aDesiredSize.Height() = aReflowState.AvailableHeight();
|
2006-11-24 11:12:17 +03:00
|
|
|
} else {
|
|
|
|
nsRect area = aPresContext->GetVisibleArea();
|
1998-07-16 03:42:14 +04:00
|
|
|
|
2013-12-27 21:59:52 +04:00
|
|
|
aDesiredSize.Width() = area.width;
|
|
|
|
aDesiredSize.Height() = area.height;
|
2006-11-24 11:12:17 +03:00
|
|
|
}
|
1998-07-16 03:42:14 +04:00
|
|
|
} else {
|
1998-07-22 03:20:04 +04:00
|
|
|
nsSize size;
|
|
|
|
framesetParent->GetSizeOfChild(this, size);
|
2013-12-27 21:59:52 +04:00
|
|
|
aDesiredSize.Width() = size.width;
|
|
|
|
aDesiredSize.Height() = size.height;
|
2012-12-03 23:47:10 +04:00
|
|
|
}
|
1998-07-16 03:42:14 +04:00
|
|
|
}
|
|
|
|
|
1998-07-27 09:59:37 +04:00
|
|
|
// only valid for non border children
|
2012-12-03 23:47:10 +04:00
|
|
|
void nsHTMLFramesetFrame::GetSizeOfChildAt(int32_t aIndexInParent,
|
|
|
|
nsSize& aSize,
|
2009-01-15 06:27:09 +03:00
|
|
|
nsIntPoint& aCellIndex)
|
1998-07-20 22:52:40 +04:00
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t row = aIndexInParent / mNumCols;
|
|
|
|
int32_t col = aIndexInParent - (row * mNumCols); // remainder from dividing index by mNumCols
|
1998-07-20 22:52:40 +04:00
|
|
|
if ((row < mNumRows) && (col < mNumCols)) {
|
|
|
|
aSize.width = mColSizes[col];
|
|
|
|
aSize.height = mRowSizes[row];
|
|
|
|
aCellIndex.x = col;
|
|
|
|
aCellIndex.y = row;
|
|
|
|
} else {
|
2009-01-15 06:27:09 +03:00
|
|
|
aSize.width = aSize.height = 0;
|
|
|
|
aCellIndex.x = aCellIndex.y = 0;
|
1998-07-20 22:52:40 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-07-27 09:59:37 +04:00
|
|
|
// only valid for non border children
|
2012-12-03 23:47:10 +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;
|
2003-07-05 19:30:50 +04:00
|
|
|
child = child->GetNextSibling()) {
|
1998-07-16 03:42:14 +04:00
|
|
|
if (aChild == child) {
|
2009-01-15 06:27:09 +03:00
|
|
|
nsIntPoint ignore;
|
1998-07-20 22:52:40 +04:00
|
|
|
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;
|
2012-12-03 23:47:10 +04:00
|
|
|
}
|
1998-07-16 03:42:14 +04:00
|
|
|
|
2012-12-03 23:47:10 +04:00
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
nsresult nsHTMLFramesetFrame::HandleEvent(nsPresContext* aPresContext,
|
2013-10-02 07:46:03 +04:00
|
|
|
WidgetGUIEvent* aEvent,
|
2012-12-03 23:47:10 +04: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;
|
2006-11-17 00:35:39 +03:00
|
|
|
case NS_MOUSE_BUTTON_UP:
|
2013-10-22 12:55:20 +04:00
|
|
|
if (aEvent->AsMouseEvent()->button == WidgetMouseEvent::eLeftButton) {
|
2006-11-17 00:35:39 +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;
|
|
|
|
}
|
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
nsresult
|
2004-12-31 00:56:11 +03:00
|
|
|
nsHTMLFramesetFrame::GetCursor(const nsPoint& aPoint,
|
|
|
|
nsIFrame::Cursor& aCursor)
|
1999-03-10 09:13:35 +03:00
|
|
|
{
|
|
|
|
if (mDragger) {
|
2009-08-12 18:03:35 +04:00
|
|
|
aCursor.mCursor = (mDragger->mVertical) ? NS_STYLE_CURSOR_EW_RESIZE : NS_STYLE_CURSOR_NS_RESIZE;
|
1999-03-10 09:13:35 +03:00
|
|
|
} else {
|
2004-12-31 00:56:11 +03:00
|
|
|
aCursor.mCursor = NS_STYLE_CURSOR_DEFAULT;
|
1999-03-10 09:13:35 +03:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-02-14 15:12:27 +04:00
|
|
|
void
|
2006-01-26 05:29:17 +03:00
|
|
|
nsHTMLFramesetFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
1998-07-16 03:42:14 +04:00
|
|
|
{
|
2013-02-14 15:08:08 +04:00
|
|
|
BuildDisplayListForInline(aBuilder, aDirtyRect, aLists);
|
2012-12-03 23:47:10 +04:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
if (mDragger && aBuilder->IsForEventDelivery()) {
|
2013-02-14 15:08:08 +04:00
|
|
|
aLists.Content()->AppendNewToTop(
|
|
|
|
new (aBuilder) nsDisplayEventReceiver(aBuilder, this));
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
1998-07-16 03:42:14 +04:00
|
|
|
}
|
|
|
|
|
2012-12-03 23:47:10 +04:00
|
|
|
void
|
1998-10-02 08:10:00 +04:00
|
|
|
nsHTMLFramesetFrame::ReflowPlaceChild(nsIFrame* aChild,
|
2012-12-03 23:47:10 +04:00
|
|
|
nsPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsPoint& aOffset,
|
|
|
|
nsSize& aSize,
|
2009-01-15 06:27:09 +03:00
|
|
|
nsIntPoint* aCellIndex)
|
1998-07-27 09:59:37 +04:00
|
|
|
{
|
2000-03-24 07:42:40 +03:00
|
|
|
// reflow the child
|
2013-04-02 15:03:03 +04:00
|
|
|
nsHTMLReflowState reflowState(aPresContext, aReflowState, aChild, aSize);
|
2013-12-27 21:59:21 +04:00
|
|
|
reflowState.SetComputedWidth(std::max(0, aSize.width - reflowState.ComputedPhysicalBorderPadding().LeftRight()));
|
|
|
|
reflowState.SetComputedHeight(std::max(0, aSize.height - reflowState.ComputedPhysicalBorderPadding().TopBottom()));
|
2013-12-30 02:48:13 +04:00
|
|
|
nsHTMLReflowMetrics metrics(aReflowState.GetWritingMode());
|
2013-12-27 21:59:52 +04:00
|
|
|
metrics.Width() = aSize.width;
|
|
|
|
metrics.Height() = aSize.height;
|
1999-10-30 06:52:11 +04:00
|
|
|
nsReflowStatus status;
|
2012-12-03 23:47:10 +04: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");
|
2012-12-03 23:47:10 +04:00
|
|
|
|
1999-10-30 06:52:11 +04:00
|
|
|
// Place and size the child
|
2013-12-27 21:59:52 +04:00
|
|
|
metrics.Width() = aSize.width;
|
|
|
|
metrics.Height() = aSize.height;
|
2014-01-17 05:34:44 +04:00
|
|
|
FinishReflowChild(aChild, aPresContext, metrics, nullptr, aOffset.x, aOffset.y, 0);
|
1998-07-27 09:59:37 +04:00
|
|
|
}
|
|
|
|
|
1999-02-25 18:38:29 +03:00
|
|
|
static
|
2005-01-12 22:45:38 +03:00
|
|
|
nsFrameborder GetFrameBorderHelper(nsGenericHTMLElement* aContent)
|
1998-08-06 23:40:37 +04:00
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
if (nullptr != aContent) {
|
2006-12-26 20:47:52 +03:00
|
|
|
const nsAttrValue* attr = aContent->GetParsedAttr(nsGkAtoms::frameborder);
|
2005-01-25 03:02:58 +03:00
|
|
|
if (attr && attr->Type() == nsAttrValue::eEnum) {
|
|
|
|
switch (attr->GetEnumValue())
|
|
|
|
{
|
|
|
|
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-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
|
|
|
}
|
|
|
|
|
2012-12-03 23:47:10 +04:00
|
|
|
nsFrameborder nsHTMLFramesetFrame::GetFrameBorder()
|
1998-07-31 01:25:35 +04:00
|
|
|
{
|
1998-09-10 03:30:30 +04:00
|
|
|
nsFrameborder result = eFrameborder_Notset;
|
2005-01-12 22:45:38 +03:00
|
|
|
nsGenericHTMLElement *content = nsGenericHTMLElement::FromContent(mContent);
|
2002-05-23 04:00:34 +04:00
|
|
|
|
2001-12-07 22:40:07 +03:00
|
|
|
if (content) {
|
|
|
|
result = GetFrameBorderHelper(content);
|
1998-09-10 03:30:30 +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 03:30:30 +04:00
|
|
|
{
|
|
|
|
nsFrameborder result = eFrameborder_Notset;
|
2002-05-23 04:00:34 +04:00
|
|
|
|
2005-01-12 22:45:38 +03:00
|
|
|
nsGenericHTMLElement *content = nsGenericHTMLElement::FromContent(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 03:30:30 +04:00
|
|
|
}
|
|
|
|
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
|
|
|
|
2012-12-03 23:47:10 +04:00
|
|
|
nscolor nsHTMLFramesetFrame::GetBorderColor()
|
1998-09-03 05:16:27 +04:00
|
|
|
{
|
2005-01-12 22:45:38 +03:00
|
|
|
nsGenericHTMLElement *content = nsGenericHTMLElement::FromContent(mContent);
|
2002-05-23 04:00:34 +04:00
|
|
|
|
|
|
|
if (content) {
|
2006-12-26 20:47:52 +03:00
|
|
|
const nsAttrValue* attr = content->GetParsedAttr(nsGkAtoms::bordercolor);
|
2005-01-25 03:02:58 +03:00
|
|
|
if (attr) {
|
2004-02-11 03:38:12 +03:00
|
|
|
nscolor color;
|
2005-01-25 03:02:58 +03:00
|
|
|
if (attr->GetColorValue(color)) {
|
2004-02-11 03:38:12 +03:00
|
|
|
return color;
|
1998-09-10 03:30:30 +04:00
|
|
|
}
|
1998-09-03 05:16:27 +04:00
|
|
|
}
|
|
|
|
}
|
2004-02-11 03:38:12 +03:00
|
|
|
|
|
|
|
return mParentBorderColor;
|
1998-09-03 05:16:27 +04:00
|
|
|
}
|
|
|
|
|
2012-12-03 23:47:10 +04:00
|
|
|
nscolor nsHTMLFramesetFrame::GetBorderColor(nsIContent* aContent)
|
1998-09-03 05:16:27 +04:00
|
|
|
{
|
2005-01-12 22:45:38 +03:00
|
|
|
nsGenericHTMLElement *content = nsGenericHTMLElement::FromContent(aContent);
|
2002-05-23 04:00:34 +04:00
|
|
|
|
|
|
|
if (content) {
|
2006-12-26 20:47:52 +03:00
|
|
|
const nsAttrValue* attr = content->GetParsedAttr(nsGkAtoms::bordercolor);
|
2005-01-25 03:02:58 +03:00
|
|
|
if (attr) {
|
2004-02-11 03:38:12 +03:00
|
|
|
nscolor color;
|
2005-01-25 03:02:58 +03:00
|
|
|
if (attr->GetColorValue(color)) {
|
2004-02-11 03:38:12 +03:00
|
|
|
return color;
|
1998-09-10 03:30:30 +04:00
|
|
|
}
|
1998-09-03 05:16:27 +04:00
|
|
|
}
|
1998-09-10 03:30:30 +04:00
|
|
|
}
|
2004-02-11 03:38:12 +03:00
|
|
|
return GetBorderColor();
|
1998-09-03 05:16:27 +04:00
|
|
|
}
|
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
nsresult
|
2012-12-03 23:47:10 +04:00
|
|
|
nsHTMLFramesetFrame::Reflow(nsPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-09-03 05:16:27 +04:00
|
|
|
{
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsHTMLFramesetFrame");
|
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
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
mParent->AddStateBits(NS_FRAME_CONTAINS_RELATIVE_HEIGHT);
|
2012-12-03 23:47:10 +04:00
|
|
|
|
2013-12-27 21:59:21 +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);
|
2012-12-03 23:47:10 +04:00
|
|
|
|
2013-12-27 21:59:52 +04: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
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool firstTime = (GetStateBits() & NS_FRAME_FIRST_REFLOW) != 0;
|
2001-11-02 05:19:49 +03:00
|
|
|
if (firstTime) {
|
2011-05-29 03:42:57 +04:00
|
|
|
Preferences::RegisterCallback(FrameResizePrefCallback,
|
|
|
|
kFrameResizePref, this);
|
2011-05-25 10:31:59 +04:00
|
|
|
mForceFrameResizability = Preferences::GetBool(kFrameResizePref);
|
2001-11-02 05:19:49 +03:00
|
|
|
}
|
2012-12-03 23:47:10 +04:00
|
|
|
|
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).
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t borderWidth = GetBorderWidth(aPresContext, 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
|
|
|
|
2012-12-21 18:06:50 +04:00
|
|
|
HTMLFrameSetElement* ourContent = HTMLFrameSetElement::FromContent(mContent);
|
2007-03-23 02:57:55 +03:00
|
|
|
NS_ASSERTION(ourContent, "Someone gave us a broken frameset element!");
|
2012-07-30 18:20:58 +04:00
|
|
|
const nsFramesetSpec* rowSpecs = nullptr;
|
|
|
|
const nsFramesetSpec* colSpecs = nullptr;
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t rows = 0;
|
|
|
|
int32_t cols = 0;
|
2007-03-23 02:57:55 +03:00
|
|
|
ourContent->GetRowSpec(&rows, &rowSpecs);
|
|
|
|
ourContent->GetColSpec(&cols, &colSpecs);
|
|
|
|
// If the number of cols or rows has changed, the frame for the frameset
|
|
|
|
// will be re-created.
|
2007-04-10 23:08:21 +04:00
|
|
|
if (mNumRows != rows || mNumCols != cols) {
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
mDrag.UnSet();
|
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2007-03-23 02:57:55 +03:00
|
|
|
|
2011-01-26 08:41:52 +03:00
|
|
|
CalculateRowCol(aPresContext, width, mNumCols, colSpecs, mColSizes);
|
|
|
|
CalculateRowCol(aPresContext, height, mNumRows, rowSpecs, mRowSizes);
|
1998-07-20 22:52:40 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
nsAutoArrayPtr<bool> verBordersVis; // vertical borders visibility
|
2006-10-07 12:53:06 +04:00
|
|
|
nsAutoArrayPtr<nscolor> verBorderColors;
|
2011-09-29 10:19:26 +04:00
|
|
|
nsAutoArrayPtr<bool> horBordersVis; // horizontal borders visibility
|
2006-10-07 12:53:06 +04:00
|
|
|
nsAutoArrayPtr<nscolor> horBorderColors;
|
|
|
|
nscolor borderColor = GetBorderColor();
|
|
|
|
nsFrameborder frameborder = GetFrameBorder();
|
2001-04-11 11:56:13 +04:00
|
|
|
|
1998-07-31 01:25:35 +04:00
|
|
|
if (firstTime) {
|
2011-01-25 04:38:07 +03:00
|
|
|
// Check for overflow in memory allocations using mNumCols and mNumRows
|
|
|
|
// which have a maxium value of NS_MAX_FRAMESET_SPEC_COUNT.
|
2011-09-29 10:19:26 +04:00
|
|
|
PR_STATIC_ASSERT(NS_MAX_FRAMESET_SPEC_COUNT < UINT_MAX / sizeof(bool));
|
2011-01-25 04:38:07 +03:00
|
|
|
PR_STATIC_ASSERT(NS_MAX_FRAMESET_SPEC_COUNT < UINT_MAX / sizeof(nscolor));
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
verBordersVis = new bool[mNumCols];
|
2006-10-07 12:53:06 +04:00
|
|
|
NS_ENSURE_TRUE(verBordersVis, NS_ERROR_OUT_OF_MEMORY);
|
1998-09-03 05:16:27 +04:00
|
|
|
verBorderColors = new nscolor[mNumCols];
|
2006-10-07 12:53:06 +04:00
|
|
|
NS_ENSURE_TRUE(verBorderColors, NS_ERROR_OUT_OF_MEMORY);
|
1998-07-31 01:25:35 +04:00
|
|
|
for (int verX = 0; verX < mNumCols; verX++) {
|
2011-10-17 18:59:28 +04:00
|
|
|
verBordersVis[verX] = 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
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
horBordersVis = new bool[mNumRows];
|
2006-10-07 12:53:06 +04:00
|
|
|
NS_ENSURE_TRUE(horBordersVis, NS_ERROR_OUT_OF_MEMORY);
|
1998-09-03 05:16:27 +04:00
|
|
|
horBorderColors = new nscolor[mNumRows];
|
2006-10-07 12:53:06 +04:00
|
|
|
NS_ENSURE_TRUE(horBorderColors, NS_ERROR_OUT_OF_MEMORY);
|
1998-07-31 01:25:35 +04:00
|
|
|
for (int horX = 0; horX < mNumRows; horX++) {
|
2011-10-17 18:59:28 +04:00
|
|
|
horBordersVis[horX] = 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
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t lastRow = 0;
|
|
|
|
int32_t lastCol = 0;
|
|
|
|
int32_t borderChildX = mNonBorderChildCount; // index of border children
|
2012-07-30 18:20:58 +04:00
|
|
|
nsHTMLFramesetBorderFrame* borderFrame = nullptr;
|
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();
|
1998-07-31 01:25:35 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
for (int32_t childX = 0; childX < mNonBorderChildCount; childX++) {
|
2009-01-15 06:27:09 +03:00
|
|
|
nsIntPoint 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
|
2006-03-27 01:30:36 +04:00
|
|
|
|
2003-02-22 03:32:13 +03:00
|
|
|
nsRefPtr<nsStyleContext> pseudoStyleContext;
|
2009-12-11 10:37:40 +03:00
|
|
|
pseudoStyleContext = styleSet->
|
|
|
|
ResolveAnonymousBoxStyle(nsCSSAnonBoxes::horizontalFramesetBorder,
|
|
|
|
mStyleContext);
|
2006-03-27 01:30:36 +04:00
|
|
|
|
|
|
|
borderFrame = new (shell) nsHTMLFramesetBorderFrame(pseudoStyleContext,
|
|
|
|
borderWidth,
|
2011-10-17 18:59:28 +04:00
|
|
|
false,
|
|
|
|
false);
|
2013-08-03 08:11:06 +04:00
|
|
|
borderFrame->Init(mContent, this, nullptr);
|
|
|
|
mChildCount++;
|
|
|
|
mFrames.AppendFrame(nullptr, borderFrame);
|
|
|
|
mHorBorders[cellIndex.y-1] = borderFrame;
|
|
|
|
// set the neighbors for determining drag boundaries
|
|
|
|
borderFrame->mPrevNeighbor = lastRow;
|
|
|
|
borderFrame->mNextNeighbor = cellIndex.y;
|
2001-11-02 05:19:49 +03:00
|
|
|
} else {
|
|
|
|
borderFrame = (nsHTMLFramesetBorderFrame*)mFrames.FrameAt(borderChildX);
|
2013-08-03 08:11:06 +04:00
|
|
|
borderFrame->mWidth = borderWidth;
|
|
|
|
borderChildX++;
|
1998-08-06 23:40:37 +04:00
|
|
|
}
|
2013-12-27 21:59:52 +04:00
|
|
|
nsSize borderSize(aDesiredSize.Width(), borderWidth);
|
2013-08-03 08:11:06 +04:00
|
|
|
ReflowPlaceChild(borderFrame, aPresContext, aReflowState, offset, borderSize);
|
|
|
|
borderFrame = nullptr;
|
2001-11-02 05:19:49 +03:00
|
|
|
offset.y += borderWidth;
|
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
|
2012-12-03 23:47:10 +04:00
|
|
|
|
2003-02-22 03:32:13 +03:00
|
|
|
nsRefPtr<nsStyleContext> pseudoStyleContext;
|
2009-12-11 10:37:40 +03:00
|
|
|
pseudoStyleContext = styleSet->
|
|
|
|
ResolveAnonymousBoxStyle(nsCSSAnonBoxes::verticalFramesetBorder,
|
|
|
|
mStyleContext);
|
2006-03-27 01:30:36 +04:00
|
|
|
|
2012-12-03 23:47:10 +04:00
|
|
|
borderFrame = new (shell) nsHTMLFramesetBorderFrame(pseudoStyleContext,
|
2006-03-27 01:30:36 +04:00
|
|
|
borderWidth,
|
2011-10-17 18:59:28 +04:00
|
|
|
true,
|
|
|
|
false);
|
2013-08-03 08:11:06 +04:00
|
|
|
borderFrame->Init(mContent, this, nullptr);
|
|
|
|
mChildCount++;
|
|
|
|
mFrames.AppendFrame(nullptr, borderFrame);
|
|
|
|
mVerBorders[cellIndex.x-1] = borderFrame;
|
|
|
|
// set the neighbors for determining drag boundaries
|
|
|
|
borderFrame->mPrevNeighbor = lastCol;
|
|
|
|
borderFrame->mNextNeighbor = cellIndex.x;
|
2012-12-03 23:47:10 +04:00
|
|
|
} else {
|
1999-01-16 01:53:39 +03:00
|
|
|
borderFrame = (nsHTMLFramesetBorderFrame*)mFrames.FrameAt(borderChildX);
|
2013-08-03 08:11:06 +04:00
|
|
|
borderFrame->mWidth = borderWidth;
|
|
|
|
borderChildX++;
|
1998-07-27 09:59:37 +04:00
|
|
|
}
|
2013-12-27 21:59:52 +04:00
|
|
|
nsSize borderSize(borderWidth, aDesiredSize.Height());
|
2013-08-03 08:11:06 +04:00
|
|
|
ReflowPlaceChild(borderFrame, aPresContext, aReflowState, offset, borderSize);
|
|
|
|
borderFrame = nullptr;
|
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) {
|
2012-12-01 06:28:02 +04:00
|
|
|
int32_t childVis;
|
|
|
|
nsHTMLFramesetFrame* framesetFrame = do_QueryFrame(child);
|
|
|
|
nsSubDocumentFrame* subdocFrame;
|
|
|
|
if (framesetFrame) {
|
|
|
|
childVis = framesetFrame->mEdgeVisibility;
|
|
|
|
mChildBorderColors[childX] = framesetFrame->mEdgeColors;
|
|
|
|
} else if ((subdocFrame = do_QueryFrame(child))) {
|
2001-10-07 04:19:01 +04:00
|
|
|
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
|
|
|
}
|
2012-12-03 23:47:10 +04:00
|
|
|
} else { // blank
|
2012-12-01 06:28:02 +04:00
|
|
|
DebugOnly<nsHTMLFramesetBlankFrame*> blank;
|
|
|
|
MOZ_ASSERT(blank = do_QueryFrame(child), "unexpected child frame type");
|
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) {
|
2011-10-17 18:59:28 +04:00
|
|
|
verBordersVis[cellIndex.x] = true;
|
1998-07-31 01:25:35 +04:00
|
|
|
}
|
1998-09-03 05:16:27 +04:00
|
|
|
if (childVis & BOTTOM_VIS) {
|
2011-10-17 18:59:28 +04:00
|
|
|
horBordersVis[cellIndex.y] = true;
|
1998-07-31 01:25:35 +04:00
|
|
|
}
|
1998-09-03 05:16:27 +04:00
|
|
|
if ((cellIndex.x > 0) && (childVis & LEFT_VIS)) {
|
2011-10-17 18:59:28 +04:00
|
|
|
verBordersVis[cellIndex.x-1] = true;
|
1998-07-31 01:25:35 +04:00
|
|
|
}
|
1998-09-03 05:16:27 +04:00
|
|
|
if ((cellIndex.y > 0) && (childVis & TOP_VIS)) {
|
2011-10-17 18:59:28 +04:00
|
|
|
horBordersVis[cellIndex.y-1] = true;
|
1998-07-31 01:25:35 +04:00
|
|
|
}
|
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;
|
2003-07-05 19:30:50 +04:00
|
|
|
child = child->GetNextSibling();
|
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) {
|
2011-10-17 18:59:28 +04:00
|
|
|
mVerBorders[verX]->mVisibilityOverride = true;
|
2001-11-02 05:19:49 +03:00
|
|
|
} else {
|
2012-12-01 06:28:02 +04:00
|
|
|
SetBorderResize(mVerBorders[verX]);
|
2001-11-02 05:19:49 +03:00
|
|
|
}
|
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) {
|
2011-10-17 18:59:28 +04:00
|
|
|
mHorBorders[horX]->mVisibilityOverride = true;
|
2001-11-02 05:19:49 +03:00
|
|
|
} else {
|
2012-12-01 06:28:02 +04:00
|
|
|
SetBorderResize(mHorBorders[horX]);
|
2001-11-02 05:19:49 +03:00
|
|
|
}
|
2012-12-03 23:47:10 +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
|
|
|
}
|
|
|
|
|
2001-10-07 04:19:01 +04:00
|
|
|
delete[] mChildFrameborder;
|
|
|
|
delete[] mChildBorderColors;
|
2004-12-31 01:05:22 +03:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
mChildFrameborder = nullptr;
|
|
|
|
mChildBorderColors = nullptr;
|
1998-07-31 01:25:35 +04:00
|
|
|
}
|
|
|
|
|
1998-07-20 22:52:40 +04:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
1999-03-10 09:13:35 +03:00
|
|
|
mDrag.UnSet();
|
2002-05-29 02:50:43 +04:00
|
|
|
|
2010-10-07 08:25:46 +04:00
|
|
|
aDesiredSize.SetOverflowAreasToDesiredBounds();
|
2007-06-27 20:37:50 +04:00
|
|
|
|
2002-05-29 02:50:43 +04:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
1998-07-16 03:42:14 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2005-09-06 06:14:36 +04:00
|
|
|
nsIAtom*
|
|
|
|
nsHTMLFramesetFrame::GetType() const
|
|
|
|
{
|
2006-12-26 20:47:52 +03:00
|
|
|
return nsGkAtoms::frameSetFrame;
|
2005-09-06 06:14:36 +04:00
|
|
|
}
|
|
|
|
|
2014-01-06 03:31:14 +04:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-02-18 11:47:48 +04:00
|
|
|
nsresult
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
nsHTMLFramesetFrame::GetFrameName(nsAString& aResult) const
|
|
|
|
{
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("Frameset"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2005-08-17 02:52:48 +04:00
|
|
|
nsHTMLFramesetFrame::IsLeaf() const
|
|
|
|
{
|
|
|
|
// We handle constructing our kids manually
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2005-08-17 02:52:48 +04:00
|
|
|
}
|
|
|
|
|
2012-12-03 23:47:10 +04:00
|
|
|
bool
|
|
|
|
nsHTMLFramesetFrame::CanResize(bool aVertical,
|
|
|
|
bool aLeft)
|
1998-09-03 05:16:27 +04:00
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t childX;
|
|
|
|
int32_t startX;
|
1998-09-03 05:16:27 +04:00
|
|
|
if (aVertical) {
|
|
|
|
startX = (aLeft) ? 0 : mNumCols-1;
|
|
|
|
for (childX = startX; childX < mNonBorderChildCount; childX += mNumCols) {
|
2012-12-01 06:28:02 +04:00
|
|
|
if (!CanChildResize(aVertical, aLeft, childX)) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
1998-09-03 05:16:27 +04:00
|
|
|
}
|
2012-12-03 23:47:10 +04:00
|
|
|
}
|
1998-09-03 05:16:27 +04:00
|
|
|
} else {
|
|
|
|
startX = (aLeft) ? 0 : (mNumRows - 1) * mNumCols;
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t endX = startX + mNumCols;
|
1998-09-03 05:16:27 +04:00
|
|
|
for (childX = startX; childX < endX; childX++) {
|
2012-12-01 06:28:02 +04:00
|
|
|
if (!CanChildResize(aVertical, aLeft, childX)) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
1998-09-03 05:16:27 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
1998-09-03 05:16:27 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2012-12-03 23:47:10 +04:00
|
|
|
nsHTMLFramesetFrame::GetNoResize(nsIFrame* aChildFrame)
|
1998-09-10 03:30:30 +04:00
|
|
|
{
|
2003-07-05 19:30:50 +04:00
|
|
|
nsIContent* content = aChildFrame->GetContent();
|
2002-05-23 04:00:34 +04:00
|
|
|
|
2006-12-26 20:47:52 +03:00
|
|
|
return content && content->HasAttr(kNameSpaceID_None, nsGkAtoms::noresize);
|
1998-09-10 03:30:30 +04:00
|
|
|
}
|
|
|
|
|
2012-12-03 23:47:10 +04:00
|
|
|
bool
|
2012-12-01 06:28:02 +04:00
|
|
|
nsHTMLFramesetFrame::CanChildResize(bool aVertical, bool aLeft, int32_t aChildX)
|
1998-09-03 05:16:27 +04:00
|
|
|
{
|
1999-01-16 01:53:39 +03:00
|
|
|
nsIFrame* child = mFrames.FrameAt(aChildX);
|
2012-12-01 06:28:02 +04:00
|
|
|
nsHTMLFramesetFrame* frameset = do_QueryFrame(child);
|
|
|
|
return frameset ? frameset->CanResize(aVertical, aLeft) : !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;
|
|
|
|
}
|
|
|
|
|
2012-09-28 10:57:33 +04:00
|
|
|
PR_STATIC_ASSERT(NS_MAX_FRAMESET_SPEC_COUNT < INT32_MAX / NS_MAX_FRAMESET_SPEC_COUNT);
|
2011-01-25 04:38:07 +03:00
|
|
|
PR_STATIC_ASSERT(NS_MAX_FRAMESET_SPEC_COUNT
|
2012-12-03 23:47:10 +04:00
|
|
|
< UINT_MAX / sizeof(int32_t) / NS_MAX_FRAMESET_SPEC_COUNT);
|
2001-11-02 05:19:49 +03:00
|
|
|
// set the visibility and mouse sensitivity of borders
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t verX;
|
2001-04-12 12:16:54 +04:00
|
|
|
for (verX = 0; verX < mNumCols-1; verX++) {
|
|
|
|
if (mVerBorders[verX]) {
|
2011-10-17 18:59:28 +04:00
|
|
|
mVerBorders[verX]->mCanResize = true;
|
2001-11-02 05:19:49 +03:00
|
|
|
if (mForceFrameResizability) {
|
2011-10-17 18:59:28 +04:00
|
|
|
mVerBorders[verX]->mVisibilityOverride = true;
|
2001-11-02 05:19:49 +03:00
|
|
|
} else {
|
2011-10-17 18:59:28 +04:00
|
|
|
mVerBorders[verX]->mVisibilityOverride = false;
|
2012-12-01 06:28:02 +04:00
|
|
|
SetBorderResize(mVerBorders[verX]);
|
2001-11-02 05:19:49 +03:00
|
|
|
}
|
2001-04-12 12:16:54 +04:00
|
|
|
}
|
|
|
|
}
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t horX;
|
2001-04-12 12:16:54 +04:00
|
|
|
for (horX = 0; horX < mNumRows-1; horX++) {
|
|
|
|
if (mHorBorders[horX]) {
|
2011-10-17 18:59:28 +04:00
|
|
|
mHorBorders[horX]->mCanResize = true;
|
2001-11-02 05:19:49 +03:00
|
|
|
if (mForceFrameResizability) {
|
2011-10-17 18:59:28 +04:00
|
|
|
mHorBorders[horX]->mVisibilityOverride = true;
|
2001-11-02 05:19:49 +03:00
|
|
|
} else {
|
2011-10-17 18:59:28 +04:00
|
|
|
mHorBorders[horX]->mVisibilityOverride = false;
|
2012-12-01 06:28:02 +04:00
|
|
|
SetBorderResize(mHorBorders[horX]);
|
2001-11-02 05:19:49 +03:00
|
|
|
}
|
2001-04-12 12:16:54 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-03 23:47:10 +04:00
|
|
|
void
|
2012-12-01 06:28:02 +04:00
|
|
|
nsHTMLFramesetFrame::SetBorderResize(nsHTMLFramesetBorderFrame* aBorderFrame)
|
1998-09-03 05:16:27 +04:00
|
|
|
{
|
|
|
|
if (aBorderFrame->mVertical) {
|
|
|
|
for (int rowX = 0; rowX < mNumRows; rowX++) {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t childX = aBorderFrame->mPrevNeighbor + (rowX * mNumCols);
|
2012-12-01 06:28:02 +04:00
|
|
|
if (!CanChildResize(true, false, childX) ||
|
|
|
|
!CanChildResize(true, true, childX+1)) {
|
2011-10-17 18:59:28 +04:00
|
|
|
aBorderFrame->mCanResize = false;
|
1998-09-03 05:16:27 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t childX = aBorderFrame->mPrevNeighbor * mNumCols;
|
|
|
|
int32_t endX = childX + mNumCols;
|
1998-09-03 05:16:27 +04:00
|
|
|
for (; childX < endX; childX++) {
|
2012-12-01 06:28:02 +04:00
|
|
|
if (!CanChildResize(false, false, childX)) {
|
2011-10-17 18:59:28 +04:00
|
|
|
aBorderFrame->mCanResize = false;
|
1998-09-03 05:16:27 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
endX = endX + mNumCols;
|
|
|
|
for (; childX < endX; childX++) {
|
2012-12-01 06:28:02 +04:00
|
|
|
if (!CanChildResize(false, true, childX)) {
|
2011-10-17 18:59:28 +04:00
|
|
|
aBorderFrame->mCanResize = false;
|
1998-09-03 05:16:27 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-12-03 23:47:10 +04:00
|
|
|
|
1998-09-03 05:16:27 +04:00
|
|
|
void
|
2012-12-03 23:47:10 +04:00
|
|
|
nsHTMLFramesetFrame::StartMouseDrag(nsPresContext* aPresContext,
|
|
|
|
nsHTMLFramesetBorderFrame* aBorder,
|
2013-10-02 07:46:03 +04:00
|
|
|
WidgetGUIEvent* aEvent)
|
1998-09-03 05:16:27 +04:00
|
|
|
{
|
1998-09-19 07:24:26 +04:00
|
|
|
#if 0
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t index;
|
1998-09-03 05:16:27 +04:00
|
|
|
IndexOf(aBorder, index);
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_ASSERTION((nullptr != aBorder) && (index >= 0), "invalid dragger");
|
1998-09-19 07:24:26 +04:00
|
|
|
#endif
|
1999-02-26 20:12:16 +03:00
|
|
|
|
2009-09-13 17:13:16 +04:00
|
|
|
nsIPresShell::SetCapturingContent(GetContent(), CAPTURE_IGNOREALLOWED);
|
|
|
|
|
|
|
|
mDragger = aBorder;
|
|
|
|
|
2013-08-02 11:05:16 +04:00
|
|
|
mFirstDragPoint = LayoutDeviceIntPoint::ToUntyped(aEvent->refPoint);
|
2009-09-13 17:13:16 +04:00
|
|
|
|
|
|
|
// 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];
|
1998-09-03 05:16:27 +04:00
|
|
|
}
|
2009-09-13 17:13:16 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
gDragInProgress = true;
|
1998-09-03 05:16:27 +04:00
|
|
|
}
|
2012-12-03 23:47:10 +04:00
|
|
|
|
1998-09-03 05:16:27 +04:00
|
|
|
|
|
|
|
void
|
2012-12-03 23:47:10 +04:00
|
|
|
nsHTMLFramesetFrame::MouseDrag(nsPresContext* aPresContext,
|
2013-10-02 07:46:03 +04:00
|
|
|
WidgetGUIEvent* aEvent)
|
1998-09-03 05:16:27 +04:00
|
|
|
{
|
2009-09-28 18:17:01 +04:00
|
|
|
// if the capture ended, reset the drag state
|
|
|
|
if (nsIPresShell::GetCapturingContent() != GetContent()) {
|
2012-07-30 18:20:58 +04:00
|
|
|
mDragger = nullptr;
|
2011-10-17 18:59:28 +04:00
|
|
|
gDragInProgress = false;
|
2009-09-28 18:17:01 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t change; // measured positive from left-to-right or top-to-bottom
|
2006-11-02 21:34:55 +03:00
|
|
|
nsWeakFrame weakFrame(this);
|
1998-09-03 05:16:27 +04:00
|
|
|
if (mDragger->mVertical) {
|
2007-02-07 10:46:44 +03:00
|
|
|
change = aPresContext->DevPixelsToAppUnits(aEvent->refPoint.x - mFirstDragPoint.x);
|
1999-06-11 05:18:50 +04:00
|
|
|
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
|
|
|
|
2002-08-06 05:06:50 +04:00
|
|
|
if (change != 0) {
|
|
|
|
// Recompute the specs from the new sizes.
|
2011-10-17 18:59:28 +04:00
|
|
|
nscoord width = mRect.width - (mNumCols - 1) * GetBorderWidth(aPresContext, true);
|
2012-12-21 18:06:50 +04:00
|
|
|
HTMLFrameSetElement* ourContent = HTMLFrameSetElement::FromContent(mContent);
|
2002-08-06 05:06:50 +04:00
|
|
|
NS_ASSERTION(ourContent, "Someone gave us a broken frameset element!");
|
2012-07-30 18:20:58 +04:00
|
|
|
const nsFramesetSpec* colSpecs = nullptr;
|
2002-08-06 05:06:50 +04:00
|
|
|
ourContent->GetColSpec(&mNumCols, &colSpecs);
|
|
|
|
nsAutoString newColAttr;
|
|
|
|
GenerateRowCol(aPresContext, width, mNumCols, colSpecs, mColSizes,
|
|
|
|
newColAttr);
|
|
|
|
// Setting the attr will trigger a reflow
|
2011-10-17 18:59:28 +04:00
|
|
|
mContent->SetAttr(kNameSpaceID_None, nsGkAtoms::cols, newColAttr, true);
|
2002-08-06 05:06:50 +04:00
|
|
|
}
|
1998-09-03 05:16:27 +04:00
|
|
|
} else {
|
2007-02-07 10:46:44 +03:00
|
|
|
change = aPresContext->DevPixelsToAppUnits(aEvent->refPoint.y - mFirstDragPoint.y);
|
1999-06-11 05:18:50 +04:00
|
|
|
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
|
|
|
|
2002-08-06 05:06:50 +04:00
|
|
|
if (change != 0) {
|
|
|
|
// Recompute the specs from the new sizes.
|
2011-10-17 18:59:28 +04:00
|
|
|
nscoord height = mRect.height - (mNumRows - 1) * GetBorderWidth(aPresContext, true);
|
2012-12-21 18:06:50 +04:00
|
|
|
HTMLFrameSetElement* ourContent = HTMLFrameSetElement::FromContent(mContent);
|
2002-08-06 05:06:50 +04:00
|
|
|
NS_ASSERTION(ourContent, "Someone gave us a broken frameset element!");
|
2012-07-30 18:20:58 +04:00
|
|
|
const nsFramesetSpec* rowSpecs = nullptr;
|
2002-08-06 05:06:50 +04:00
|
|
|
ourContent->GetRowSpec(&mNumRows, &rowSpecs);
|
|
|
|
nsAutoString newRowAttr;
|
|
|
|
GenerateRowCol(aPresContext, height, mNumRows, rowSpecs, mRowSizes,
|
|
|
|
newRowAttr);
|
|
|
|
// Setting the attr will trigger a reflow
|
2011-10-17 18:59:28 +04:00
|
|
|
mContent->SetAttr(kNameSpaceID_None, nsGkAtoms::rows, newRowAttr, true);
|
2002-08-06 05:06:50 +04:00
|
|
|
}
|
1998-09-03 05:16:27 +04:00
|
|
|
}
|
|
|
|
|
2006-11-02 21:34:55 +03:00
|
|
|
ENSURE_TRUE(weakFrame.IsAlive());
|
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);
|
1998-09-03 05:16:27 +04:00
|
|
|
}
|
2012-12-03 23:47:10 +04:00
|
|
|
}
|
1998-09-03 05:16:27 +04:00
|
|
|
|
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsHTMLFramesetFrame::EndMouseDrag(nsPresContext* aPresContext)
|
1998-09-03 05:16:27 +04:00
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
nsIPresShell::SetCapturingContent(nullptr, 0);
|
|
|
|
mDragger = nullptr;
|
2011-10-17 18:59:28 +04:00
|
|
|
gDragInProgress = false;
|
2009-09-13 17:13:16 +04:00
|
|
|
}
|
1998-09-03 05:16:27 +04:00
|
|
|
|
2005-11-01 23:40:54 +03:00
|
|
|
nsIFrame*
|
2006-03-27 01:30:36 +04:00
|
|
|
NS_NewHTMLFramesetFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
1998-07-16 03:42:14 +04:00
|
|
|
{
|
2009-01-19 21:31:31 +03:00
|
|
|
#ifdef DEBUG
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStyleDisplay* disp = aContext->StyleDisplay();
|
2012-08-02 15:38:50 +04:00
|
|
|
NS_ASSERTION(!disp->IsAbsolutelyPositionedStyle() && !disp->IsFloatingStyle(),
|
2009-01-19 21:31:31 +03:00
|
|
|
"Framesets should not be positioned and should not float");
|
|
|
|
#endif
|
|
|
|
|
2006-03-27 01:30:36 +04:00
|
|
|
return new (aPresShell) nsHTMLFramesetFrame(aContext);
|
1998-07-16 03:42:14 +04:00
|
|
|
}
|
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsHTMLFramesetFrame)
|
|
|
|
|
1998-07-27 09:59:37 +04:00
|
|
|
/*******************************************************************************
|
|
|
|
* nsHTMLFramesetBorderFrame
|
|
|
|
******************************************************************************/
|
2006-03-27 01:30:36 +04:00
|
|
|
nsHTMLFramesetBorderFrame::nsHTMLFramesetBorderFrame(nsStyleContext* aContext,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aWidth,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aVertical,
|
|
|
|
bool aVisibility)
|
2006-03-27 01:30:36 +04:00
|
|
|
: nsLeafFrame(aContext), mWidth(aWidth), mVertical(aVertical), mVisibility(aVisibility)
|
1998-07-27 09:59:37 +04:00
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
mVisibilityOverride = false;
|
|
|
|
mCanResize = true;
|
1999-04-13 04:56:23 +04:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsHTMLFramesetBorderFrame)
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
nscoord nsHTMLFramesetBorderFrame::GetIntrinsicWidth()
|
1998-07-27 09:59:37 +04:00
|
|
|
{
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
// No intrinsic width
|
|
|
|
return 0;
|
1998-07-27 09:59:37 +04:00
|
|
|
}
|
|
|
|
|
2008-10-30 20:10:19 +03:00
|
|
|
nscoord nsHTMLFramesetBorderFrame::GetIntrinsicHeight()
|
|
|
|
{
|
|
|
|
// No intrinsic height
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
void nsHTMLFramesetBorderFrame::SetVisibility(bool aVisibility)
|
2012-12-03 23:47:10 +04:00
|
|
|
{
|
|
|
|
mVisibility = aVisibility;
|
1998-07-31 01:25:35 +04:00
|
|
|
}
|
|
|
|
|
1998-09-03 05:16:27 +04:00
|
|
|
void nsHTMLFramesetBorderFrame::SetColor(nscolor aColor)
|
2012-12-03 23:47:10 +04:00
|
|
|
{
|
1998-09-03 05:16:27 +04:00
|
|
|
mColor = aColor;
|
|
|
|
}
|
|
|
|
|
1998-07-31 01:25:35 +04:00
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
nsresult
|
2012-12-03 23:47:10 +04:00
|
|
|
nsHTMLFramesetBorderFrame::Reflow(nsPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-07-27 09:59:37 +04:00
|
|
|
{
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsHTMLFramesetBorderFrame");
|
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
|
|
|
|
|
|
|
|
// Override Reflow(), since we don't want to deal with what our
|
|
|
|
// computed values are.
|
|
|
|
SizeToAvailSize(aReflowState, aDesiredSize);
|
|
|
|
|
2010-10-07 08:25:46 +04:00
|
|
|
aDesiredSize.SetOverflowAreasToDesiredBounds();
|
1998-07-27 09:59:37 +04:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-07-16 03:42:14 +04:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
class nsDisplayFramesetBorder : public nsDisplayItem {
|
|
|
|
public:
|
2010-08-13 14:01:13 +04:00
|
|
|
nsDisplayFramesetBorder(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsHTMLFramesetBorderFrame* aFrame)
|
|
|
|
: nsDisplayItem(aBuilder, aFrame) {
|
2006-01-29 21:48:58 +03:00
|
|
|
MOZ_COUNT_CTOR(nsDisplayFramesetBorder);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayFramesetBorder() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayFramesetBorder);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
// REVIEW: see old GetFrameForPoint
|
|
|
|
// Receives events in its bounds
|
2010-04-08 04:31:26 +04:00
|
|
|
virtual void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
|
2014-02-24 18:41:56 +04:00
|
|
|
HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames) MOZ_OVERRIDE {
|
2010-04-08 04:31:26 +04:00
|
|
|
aOutFrames->AppendElement(mFrame);
|
|
|
|
}
|
2009-09-07 04:35:14 +04:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder,
|
2014-02-24 18:41:56 +04:00
|
|
|
nsRenderingContext* aCtx) MOZ_OVERRIDE;
|
2010-07-16 01:07:49 +04:00
|
|
|
NS_DISPLAY_DECL_NAME("FramesetBorder", TYPE_FRAMESET_BORDER)
|
2006-01-26 05:29:17 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
void nsDisplayFramesetBorder::Paint(nsDisplayListBuilder* aBuilder,
|
2011-04-08 05:04:40 +04:00
|
|
|
nsRenderingContext* aCtx)
|
2006-01-26 05:29:17 +03:00
|
|
|
{
|
2007-07-08 11:08:04 +04:00
|
|
|
static_cast<nsHTMLFramesetBorderFrame*>(mFrame)->
|
2010-08-13 14:01:58 +04:00
|
|
|
PaintBorder(*aCtx, ToReferenceFrame());
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
|
|
|
|
2013-02-14 15:12:27 +04:00
|
|
|
void
|
2006-01-26 05:29:17 +03:00
|
|
|
nsHTMLFramesetBorderFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
|
|
|
{
|
2013-02-14 15:08:08 +04:00
|
|
|
aLists.Content()->AppendNewToTop(
|
|
|
|
new (aBuilder) nsDisplayFramesetBorder(aBuilder, this));
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
|
|
|
|
2011-04-08 05:04:40 +04:00
|
|
|
void nsHTMLFramesetBorderFrame::PaintBorder(nsRenderingContext& aRenderingContext,
|
2006-01-26 05:29:17 +03:00
|
|
|
nsPoint aPt)
|
1998-07-27 09:59:37 +04:00
|
|
|
{
|
1998-12-04 21:05:30 +03:00
|
|
|
nscolor WHITE = NS_RGB(255, 255, 255);
|
2011-09-09 06:27:13 +04:00
|
|
|
|
|
|
|
nscolor bgColor =
|
|
|
|
LookAndFeel::GetColor(LookAndFeel::eColorID_WidgetBackground,
|
|
|
|
NS_RGB(200,200,200));
|
|
|
|
nscolor fgColor =
|
|
|
|
LookAndFeel::GetColor(LookAndFeel::eColorID_WidgetForeground,
|
|
|
|
NS_RGB(0,0,0));
|
|
|
|
nscolor hltColor =
|
|
|
|
LookAndFeel::GetColor(LookAndFeel::eColorID_Widget3DHighlight,
|
|
|
|
NS_RGB(255,255,255));
|
|
|
|
nscolor sdwColor =
|
|
|
|
LookAndFeel::GetColor(LookAndFeel::eColorID_Widget3DShadow,
|
|
|
|
NS_RGB(128,128,128));
|
1998-12-04 21:05:30 +03:00
|
|
|
|
2011-04-08 05:04:40 +04:00
|
|
|
nsRenderingContext::AutoPushTranslation
|
2011-04-08 05:04:39 +04:00
|
|
|
translate(&aRenderingContext, aPt);
|
2006-01-26 05:29:17 +03:00
|
|
|
|
2007-02-07 10:46:44 +03:00
|
|
|
nscoord widthInPixels = nsPresContext::AppUnitsToIntCSSPixels(mWidth);
|
|
|
|
nscoord pixelWidth = nsPresContext::CSSPixelsToAppUnits(1);
|
1998-08-06 23:40:37 +04:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
if (widthInPixels <= 0)
|
|
|
|
return;
|
1998-07-27 09:59:37 +04:00
|
|
|
|
2011-04-08 05:04:39 +04:00
|
|
|
nsPoint start(0,0);
|
|
|
|
nsPoint end((mVertical) ? 0 : mRect.width, (mVertical) ? mRect.height : 0);
|
1998-07-27 09:59:37 +04:00
|
|
|
|
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++) {
|
2011-04-08 05:04:39 +04:00
|
|
|
aRenderingContext.DrawLine (start, end);
|
1998-07-27 09:59:37 +04:00
|
|
|
if (mVertical) {
|
2011-04-08 05:04:39 +04:00
|
|
|
start.x += pixelWidth;
|
|
|
|
end.x = start.x;
|
1998-07-27 09:59:37 +04:00
|
|
|
} else {
|
2011-04-08 05:04:39 +04:00
|
|
|
start.y += pixelWidth;
|
|
|
|
end.y = start.y;
|
1998-07-27 09:59:37 +04:00
|
|
|
}
|
|
|
|
}
|
1998-08-06 23:40:37 +04:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
if (!mVisibility && !mVisibilityOverride)
|
|
|
|
return;
|
1998-08-06 23:40:37 +04:00
|
|
|
|
|
|
|
if (widthInPixels >= 5) {
|
1998-12-04 21:05:30 +03:00
|
|
|
aRenderingContext.SetColor(hltColor);
|
2011-04-08 05:04:39 +04:00
|
|
|
start.x = (mVertical) ? pixelWidth : 0;
|
|
|
|
start.y = (mVertical) ? 0 : pixelWidth;
|
|
|
|
end.x = (mVertical) ? start.x : mRect.width;
|
|
|
|
end.y = (mVertical) ? mRect.height : start.y;
|
|
|
|
aRenderingContext.DrawLine(start, end);
|
1998-08-06 23:40:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (widthInPixels >= 2) {
|
1998-12-04 21:05:30 +03:00
|
|
|
aRenderingContext.SetColor(sdwColor);
|
2011-04-08 05:04:39 +04:00
|
|
|
start.x = (mVertical) ? mRect.width - (2 * pixelWidth) : 0;
|
|
|
|
start.y = (mVertical) ? 0 : mRect.height - (2 * pixelWidth);
|
|
|
|
end.x = (mVertical) ? start.x : mRect.width;
|
|
|
|
end.y = (mVertical) ? mRect.height : start.y;
|
|
|
|
aRenderingContext.DrawLine(start, end);
|
1998-08-06 23:40:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (widthInPixels >= 1) {
|
1998-12-04 21:05:30 +03:00
|
|
|
aRenderingContext.SetColor(fgColor);
|
2011-04-08 05:04:39 +04:00
|
|
|
start.x = (mVertical) ? mRect.width - pixelWidth : 0;
|
|
|
|
start.y = (mVertical) ? 0 : mRect.height - pixelWidth;
|
|
|
|
end.x = (mVertical) ? start.x : mRect.width;
|
|
|
|
end.y = (mVertical) ? mRect.height : start.y;
|
|
|
|
aRenderingContext.DrawLine(start, end);
|
1998-08-06 23:40:37 +04:00
|
|
|
}
|
1998-07-27 09:59:37 +04:00
|
|
|
}
|
|
|
|
|
1998-09-03 05:16:27 +04:00
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
nsresult
|
2012-12-03 23:47:10 +04:00
|
|
|
nsHTMLFramesetBorderFrame::HandleEvent(nsPresContext* aPresContext,
|
2013-10-02 07:46:03 +04:00
|
|
|
WidgetGUIEvent* aEvent,
|
2012-12-03 23:47:10 +04: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;
|
|
|
|
}
|
|
|
|
|
2013-10-22 12:55:20 +04:00
|
|
|
if (aEvent->message == NS_MOUSE_BUTTON_DOWN &&
|
|
|
|
aEvent->AsMouseEvent()->button == WidgetMouseEvent::eLeftButton) {
|
2012-12-01 06:28:02 +04:00
|
|
|
nsHTMLFramesetFrame* parentFrame = do_QueryFrame(GetParent());
|
|
|
|
if (parentFrame) {
|
|
|
|
parentFrame->StartMouseDrag(aPresContext, this, aEvent);
|
|
|
|
*aEventStatus = nsEventStatus_eConsumeNoDefault;
|
|
|
|
}
|
1998-07-31 01:25:35 +04:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
nsresult
|
2004-12-31 00:56:11 +03:00
|
|
|
nsHTMLFramesetBorderFrame::GetCursor(const nsPoint& aPoint,
|
|
|
|
nsIFrame::Cursor& aCursor)
|
1998-11-18 08:25:26 +03:00
|
|
|
{
|
|
|
|
if (!mCanResize) {
|
2004-12-31 00:56:11 +03:00
|
|
|
aCursor.mCursor = NS_STYLE_CURSOR_DEFAULT;
|
2012-12-03 23:47:10 +04:00
|
|
|
} else {
|
2009-08-12 18:03:35 +04:00
|
|
|
aCursor.mCursor = (mVertical) ? NS_STYLE_CURSOR_EW_RESIZE : NS_STYLE_CURSOR_NS_RESIZE;
|
1999-03-10 09:13:35 +03:00
|
|
|
}
|
1998-11-18 08:25:26 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-01-06 03:31:14 +04:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-02-18 11:47:48 +04:00
|
|
|
nsresult 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
|
|
|
|
******************************************************************************/
|
|
|
|
|
2013-04-04 03:35:07 +04:00
|
|
|
NS_QUERYFRAME_HEAD(nsHTMLFramesetBlankFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsHTMLFramesetBlankFrame)
|
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsLeafFrame)
|
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsHTMLFramesetBlankFrame)
|
|
|
|
|
1998-08-06 02:24:56 +04:00
|
|
|
nsHTMLFramesetBlankFrame::~nsHTMLFramesetBlankFrame()
|
|
|
|
{
|
2000-10-29 02:17:53 +04:00
|
|
|
//printf("nsHTMLFramesetBlankFrame destructor %p \n", this);
|
1998-08-06 02:24:56 +04:00
|
|
|
}
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
nscoord nsHTMLFramesetBlankFrame::GetIntrinsicWidth()
|
1998-08-06 02:24:56 +04:00
|
|
|
{
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
// No intrinsic width
|
|
|
|
return 0;
|
1998-08-06 02:24:56 +04:00
|
|
|
}
|
|
|
|
|
2008-10-30 20:10:19 +03:00
|
|
|
nscoord nsHTMLFramesetBlankFrame::GetIntrinsicHeight()
|
|
|
|
{
|
|
|
|
// No intrinsic height
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
nsresult
|
2012-12-03 23:47:10 +04:00
|
|
|
nsHTMLFramesetBlankFrame::Reflow(nsPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-08-06 02:24:56 +04:00
|
|
|
{
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsHTMLFramesetBlankFrame");
|
|
|
|
|
|
|
|
// Override Reflow(), since we don't want to deal with what our
|
|
|
|
// computed values are.
|
|
|
|
SizeToAvailSize(aReflowState, aDesiredSize);
|
|
|
|
|
2010-10-07 08:25:46 +04:00
|
|
|
aDesiredSize.SetOverflowAreasToDesiredBounds();
|
1998-08-06 02:24:56 +04:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
class nsDisplayFramesetBlank : public nsDisplayItem {
|
|
|
|
public:
|
2010-08-13 14:01:13 +04:00
|
|
|
nsDisplayFramesetBlank(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsIFrame* aFrame) :
|
|
|
|
nsDisplayItem(aBuilder, aFrame) {
|
2006-01-29 21:48:58 +03:00
|
|
|
MOZ_COUNT_CTOR(nsDisplayFramesetBlank);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayFramesetBlank() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayFramesetBlank);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-02-24 18:41:56 +04:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder, nsRenderingContext* aCtx) MOZ_OVERRIDE;
|
2010-07-16 01:07:49 +04:00
|
|
|
NS_DISPLAY_DECL_NAME("FramesetBlank", TYPE_FRAMESET_BLANK)
|
2006-01-26 05:29:17 +03:00
|
|
|
};
|
2010-08-13 14:01:58 +04:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
void nsDisplayFramesetBlank::Paint(nsDisplayListBuilder* aBuilder,
|
2011-04-08 05:04:40 +04:00
|
|
|
nsRenderingContext* aCtx)
|
1998-08-06 02:24:56 +04:00
|
|
|
{
|
|
|
|
nscolor white = NS_RGB(255,255,255);
|
2009-09-07 04:35:14 +04:00
|
|
|
aCtx->SetColor(white);
|
|
|
|
aCtx->FillRect(mVisibleRect);
|
1998-08-06 02:24:56 +04:00
|
|
|
}
|
|
|
|
|
2013-02-14 15:12:27 +04:00
|
|
|
void
|
2006-01-26 05:29:17 +03:00
|
|
|
nsHTMLFramesetBlankFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
|
|
|
{
|
2013-02-14 15:08:08 +04:00
|
|
|
aLists.Content()->AppendNewToTop(
|
|
|
|
new (aBuilder) nsDisplayFramesetBlank(aBuilder, this));
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|