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"
|
|
|
|
|
2014-09-11 10:48:09 +04:00
|
|
|
#include "gfxContext.h"
|
2014-10-19 16:22:22 +04:00
|
|
|
#include "gfxUtils.h"
|
2012-12-15 03:58:45 +04:00
|
|
|
#include "mozilla/DebugOnly.h"
|
2014-10-19 16:22:22 +04:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2014-10-20 13:55:48 +04:00
|
|
|
#include "mozilla/gfx/Helpers.h"
|
2012-12-15 03:58:45 +04:00
|
|
|
#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"
|
2014-09-11 10:48:09 +04:00
|
|
|
#include "nsLayoutUtils.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"
|
2001-11-02 05:19:49 +03:00
|
|
|
#include "nsIDOMMutationEvent.h"
|
2014-02-28 03:04:46 +04:00
|
|
|
#include "nsNameSpaceManager.h"
|
2002-11-17 18:37:56 +03:00
|
|
|
#include "nsCSSAnonBoxes.h"
|
2016-02-24 10:01:11 +03:00
|
|
|
#include "mozilla/StyleSetHandle.h"
|
|
|
|
#include "mozilla/StyleSetHandleInlines.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;
|
2014-10-19 16:22:22 +04:00
|
|
|
using namespace mozilla::gfx;
|
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
|
|
|
|
******************************************************************************/
|
2017-04-30 18:30:08 +03:00
|
|
|
class nsHTMLFramesetBorderFrame final : public nsLeafFrame
|
2009-09-12 20:49:24 +04:00
|
|
|
{
|
1998-07-27 09:59:37 +04:00
|
|
|
public:
|
2017-05-26 13:11:11 +03:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS(nsHTMLFramesetBorderFrame)
|
2009-09-12 20:49:24 +04:00
|
|
|
|
2014-01-06 03:31:14 +04:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsresult GetFrameName(nsAString& aResult) const 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,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsEventStatus* aEventStatus) override;
|
1998-07-31 01:25:35 +04:00
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
virtual nsresult GetCursor(const nsPoint& aPoint,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsIFrame::Cursor& aCursor) override;
|
2012-12-03 23:47:10 +04:00
|
|
|
|
2013-02-14 15:12:27 +04:00
|
|
|
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
2017-08-10 15:40:21 +03:00
|
|
|
const nsRect& aDirtyRect,
|
2015-03-21 19:28:04 +03:00
|
|
|
const nsDisplayListSet& aLists) override;
|
1998-07-27 09:59:37 +04:00
|
|
|
|
2014-05-13 04:47:52 +04:00
|
|
|
virtual void Reflow(nsPresContext* aPresContext,
|
2016-07-21 13:36:38 +03:00
|
|
|
ReflowOutput& aDesiredSize,
|
2016-07-21 13:36:39 +03:00
|
|
|
const ReflowInput& aReflowInput,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsReflowStatus& aStatus) override;
|
1998-07-27 09:59:37 +04:00
|
|
|
|
2015-07-21 07:22:02 +03:00
|
|
|
bool GetVisibility() { return mVisibility; }
|
2011-09-29 10:19:26 +04:00
|
|
|
void SetVisibility(bool aVisibility);
|
1998-09-03 05:16:27 +04:00
|
|
|
void SetColor(nscolor aColor);
|
1998-07-31 01:25:35 +04:00
|
|
|
|
2014-10-20 13:55:48 +04:00
|
|
|
void PaintBorder(DrawTarget* aDrawTarget, 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();
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nscoord GetIntrinsicISize() override;
|
|
|
|
virtual nscoord GetIntrinsicBSize() 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 mCanResize;
|
1998-07-27 09:59:37 +04:00
|
|
|
friend class nsHTMLFramesetFrame;
|
|
|
|
};
|
1998-08-06 02:24:56 +04:00
|
|
|
/*******************************************************************************
|
|
|
|
* nsHTMLFramesetBlankFrame
|
|
|
|
******************************************************************************/
|
2017-04-30 18:30:08 +03:00
|
|
|
class nsHTMLFramesetBlankFrame final : public nsLeafFrame
|
2009-09-12 20:49:24 +04:00
|
|
|
{
|
1998-08-06 02:24:56 +04:00
|
|
|
public:
|
2013-04-04 03:35:07 +04:00
|
|
|
NS_DECL_QUERYFRAME
|
2017-05-26 13:11:11 +03:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS(nsHTMLFramesetBlankFrame)
|
2009-09-12 20:49:24 +04:00
|
|
|
|
2014-01-06 03:31:14 +04:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsresult GetFrameName(nsAString& aResult) const 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,
|
2017-08-10 15:40:21 +03:00
|
|
|
const nsRect& aDirtyRect,
|
2015-03-21 19:28:04 +03:00
|
|
|
const nsDisplayListSet& aLists) override;
|
1998-08-06 02:24:56 +04:00
|
|
|
|
2014-05-13 04:47:52 +04:00
|
|
|
virtual void Reflow(nsPresContext* aPresContext,
|
2016-07-21 13:36:38 +03:00
|
|
|
ReflowOutput& aDesiredSize,
|
2016-07-21 13:36:39 +03:00
|
|
|
const ReflowInput& aReflowInput,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsReflowStatus& aStatus) override;
|
1998-08-06 02:24:56 +04:00
|
|
|
|
|
|
|
protected:
|
2017-04-30 18:30:08 +03:00
|
|
|
explicit nsHTMLFramesetBlankFrame(nsStyleContext* aContext)
|
2017-05-26 13:11:11 +03:00
|
|
|
: nsLeafFrame(aContext, kClassID)
|
2017-04-30 18:30:08 +03:00
|
|
|
{}
|
|
|
|
|
1998-08-06 02:24:56 +04:00
|
|
|
virtual ~nsHTMLFramesetBlankFrame();
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nscoord GetIntrinsicISize() override;
|
|
|
|
virtual nscoord GetIntrinsicBSize() 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 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)
|
2017-05-26 13:11:11 +03:00
|
|
|
: nsContainerFrame(aContext, kClassID)
|
1998-07-16 03:42:14 +04:00
|
|
|
{
|
1999-04-13 04:56:23 +04:00
|
|
|
mNumRows = 0;
|
|
|
|
mNumCols = 0;
|
|
|
|
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);
|
1998-07-16 03:42:14 +04:00
|
|
|
}
|
|
|
|
|
1998-07-20 22:52:40 +04:00
|
|
|
nsHTMLFramesetFrame::~nsHTMLFramesetFrame()
|
|
|
|
{
|
|
|
|
}
|
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
|
|
|
|
2013-03-20 05:47:48 +04:00
|
|
|
void
|
2014-05-25 02:20:40 +04:00
|
|
|
nsHTMLFramesetFrame::Init(nsIContent* aContent,
|
|
|
|
nsContainerFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
1999-03-10 09:13:35 +03:00
|
|
|
{
|
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
|
|
|
|
2016-08-23 18:24:54 +03:00
|
|
|
static_assert(NS_MAX_FRAMESET_SPEC_COUNT < UINT_MAX / sizeof(nscoord),
|
|
|
|
"Maximum value of mNumRows and mNumCols is NS_MAX_FRAMESET_SPEC_COUNT");
|
2015-10-29 23:16:13 +03:00
|
|
|
mRowSizes = MakeUnique<nscoord[]>(mNumRows);
|
|
|
|
mColSizes = MakeUnique<nscoord[]>(mNumCols);
|
2001-10-07 04:19:01 +04:00
|
|
|
|
2016-08-23 18:24:54 +03:00
|
|
|
static_assert(NS_MAX_FRAMESET_SPEC_COUNT < INT32_MAX / NS_MAX_FRAMESET_SPEC_COUNT,
|
|
|
|
"Should not overflow numCells");
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t numCells = mNumRows*mNumCols;
|
2001-10-07 04:19:01 +04:00
|
|
|
|
2016-08-23 18:24:54 +03:00
|
|
|
static_assert(NS_MAX_FRAMESET_SPEC_COUNT < UINT_MAX / sizeof(nsHTMLFramesetBorderFrame*),
|
|
|
|
"Should not overflow nsHTMLFramesetBorderFrame");
|
2015-10-29 23:16:13 +03:00
|
|
|
mVerBorders = MakeUnique<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
|
|
|
|
2015-10-29 23:16:13 +03:00
|
|
|
mHorBorders = MakeUnique<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
|
|
|
|
2016-08-23 18:24:54 +03:00
|
|
|
static_assert(NS_MAX_FRAMESET_SPEC_COUNT
|
|
|
|
< UINT_MAX / sizeof(int32_t) / NS_MAX_FRAMESET_SPEC_COUNT,
|
|
|
|
"Should not overflow numCells");
|
|
|
|
static_assert(NS_MAX_FRAMESET_SPEC_COUNT
|
|
|
|
< UINT_MAX / sizeof(nsFrameborder) / NS_MAX_FRAMESET_SPEC_COUNT,
|
|
|
|
"Should not overflow numCells");
|
|
|
|
static_assert(NS_MAX_FRAMESET_SPEC_COUNT
|
|
|
|
< UINT_MAX / sizeof(nsBorderColor) / NS_MAX_FRAMESET_SPEC_COUNT,
|
|
|
|
"Should not overflow numCells");
|
2015-10-29 23:16:13 +03:00
|
|
|
mChildFrameborder = MakeUnique<nsFrameborder[]>(numCells);
|
|
|
|
mChildBorderColors = MakeUnique<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);
|
2016-07-08 10:07:06 +03:00
|
|
|
child->UnsetRestyleFlagsIfGecko();
|
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.
|
2016-07-08 10:07:06 +03:00
|
|
|
child->UnsetRestyleFlagsIfGecko();
|
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
|
2015-03-03 14:08:59 +03:00
|
|
|
if (!child->IsHTMLElement())
|
2001-10-07 04:19:01 +04:00
|
|
|
continue;
|
2003-09-27 08:18:26 +04:00
|
|
|
|
2015-03-03 14:09:00 +03:00
|
|
|
if (child->IsAnyOfHTMLElements(nsGkAtoms::frameset, nsGkAtoms::frame)) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsStyleContext> kidSC;
|
2001-10-07 04:19:01 +04:00
|
|
|
|
2010-04-30 17:12:06 +04:00
|
|
|
kidSC = shell->StyleSet()->ResolveStyleFor(child->AsElement(),
|
2016-11-02 09:11:24 +03:00
|
|
|
mStyleContext,
|
|
|
|
LazyComputeBehavior::Allow);
|
2015-03-03 14:09:00 +03:00
|
|
|
if (child->IsHTMLElement(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++) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsStyleContext> pseudoStyleContext;
|
2006-03-27 01:30:36 +04:00
|
|
|
pseudoStyleContext = shell->StyleSet()->
|
2017-03-15 21:00:43 +03:00
|
|
|
ResolveNonInheritingAnonymousBoxStyle(nsCSSAnonBoxes::framesetBlank);
|
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-05-28 23:36:58 +04:00
|
|
|
void
|
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()) {
|
2014-05-28 23:36:58 +04:00
|
|
|
return;
|
2009-01-19 21:31:31 +03:00
|
|
|
}
|
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
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
|
|
|
{
|
2016-08-23 18:24:54 +03:00
|
|
|
static_assert(NS_MAX_FRAMESET_SPEC_COUNT < UINT_MAX / sizeof(int32_t),
|
|
|
|
"aNumSpecs maximum value is NS_MAX_FRAMESET_SPEC_COUNT");
|
2011-01-25 04:38:07 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t fixedTotal = 0;
|
|
|
|
int32_t numFixed = 0;
|
2015-10-30 22:12:25 +03:00
|
|
|
auto fixed = MakeUnique<int32_t[]>(aNumSpecs);
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t numPercent = 0;
|
2015-10-30 22:12:25 +03:00
|
|
|
auto percent = MakeUnique<int32_t[]>(aNumSpecs);
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t relativeSums = 0;
|
|
|
|
int32_t numRelative = 0;
|
2015-10-30 22:12:25 +03:00
|
|
|
auto relative = MakeUnique<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))) {
|
2015-10-30 22:12:25 +03:00
|
|
|
Scale(aSize, numFixed, fixed.get(), 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))) {
|
2015-10-30 22:12:25 +03:00
|
|
|
Scale(percentMax, numPercent, percent.get(), 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) {
|
2015-10-30 22:12:25 +03:00
|
|
|
Scale(relativeMax, numRelative, relative.get(), 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
|
|
|
{
|
2015-07-21 07:18:17 +03:00
|
|
|
nsFrameborder frameborder = GetFrameBorder();
|
|
|
|
if (frameborder == eFrameborder_No) {
|
|
|
|
return 0;
|
2001-11-02 05:19:49 +03: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::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
|
|
|
|
2007-02-07 10:46:44 +03:00
|
|
|
return nsPresContext::CSSPixelsToAppUnits(intVal);
|
1998-08-06 23:40:37 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-21 07:18:17 +03:00
|
|
|
if (mParentBorderWidth >= 0) {
|
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,
|
2016-07-21 13:36:39 +03:00
|
|
|
const ReflowInput& aReflowInput,
|
2016-07-21 13:36:38 +03:00
|
|
|
ReflowOutput& aDesiredSize)
|
1998-07-16 03:42:14 +04:00
|
|
|
{
|
2016-07-21 13:36:39 +03:00
|
|
|
WritingMode wm = aReflowInput.GetWritingMode();
|
2014-07-24 12:30:07 +04:00
|
|
|
LogicalSize desiredSize(wm);
|
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
|
2016-07-21 13:36:39 +03:00
|
|
|
desiredSize.ISize(wm) = aReflowInput.AvailableISize();
|
|
|
|
desiredSize.BSize(wm) = aReflowInput.AvailableBSize();
|
2006-11-24 11:12:17 +03:00
|
|
|
} else {
|
2014-07-24 12:30:07 +04:00
|
|
|
LogicalSize area(wm, aPresContext->GetVisibleArea().Size());
|
1998-07-16 03:42:14 +04:00
|
|
|
|
2014-07-24 12:30:07 +04:00
|
|
|
desiredSize.ISize(wm) = area.ISize(wm);
|
|
|
|
desiredSize.BSize(wm) = area.BSize(wm);
|
2006-11-24 11:12:17 +03:00
|
|
|
}
|
1998-07-16 03:42:14 +04:00
|
|
|
} else {
|
2014-07-24 12:30:07 +04:00
|
|
|
LogicalSize size(wm);
|
|
|
|
framesetParent->GetSizeOfChild(this, wm, size);
|
|
|
|
desiredSize.ISize(wm) = size.ISize(wm);
|
|
|
|
desiredSize.BSize(wm) = size.BSize(wm);
|
2012-12-03 23:47:10 +04:00
|
|
|
}
|
2014-07-24 12:30:07 +04:00
|
|
|
aDesiredSize.SetSize(wm, desiredSize);
|
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,
|
2014-07-24 12:30:07 +04:00
|
|
|
WritingMode aWM,
|
|
|
|
LogicalSize& 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)) {
|
2014-07-24 12:30:07 +04:00
|
|
|
aSize.ISize(aWM) = mColSizes[col];
|
|
|
|
aSize.BSize(aWM) = mRowSizes[row];
|
1998-07-20 22:52:40 +04:00
|
|
|
aCellIndex.x = col;
|
|
|
|
aCellIndex.y = row;
|
|
|
|
} else {
|
2014-07-24 12:30:07 +04:00
|
|
|
aSize.SizeTo(aWM, 0, 0);
|
2009-01-15 06:27:09 +03:00
|
|
|
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,
|
2014-07-24 12:30:07 +04:00
|
|
|
WritingMode aWM,
|
|
|
|
LogicalSize& 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;
|
2015-06-29 23:02:21 +03:00
|
|
|
for (nsIFrame* child : mFrames) {
|
1998-07-16 03:42:14 +04:00
|
|
|
if (aChild == child) {
|
2009-01-15 06:27:09 +03:00
|
|
|
nsIntPoint ignore;
|
2014-07-24 12:30:07 +04:00
|
|
|
GetSizeOfChildAt(i, aWM, aSize, ignore);
|
1998-07-27 09:59:37 +04:00
|
|
|
return;
|
1998-07-16 03:42:14 +04:00
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
2014-07-24 12:30:07 +04:00
|
|
|
aSize.SizeTo(aWM, 0, 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
|
2015-08-22 04:34:51 +03:00
|
|
|
switch (aEvent->mMessage) {
|
2015-08-29 02:58:29 +03:00
|
|
|
case eMouseMove:
|
1998-11-25 21:11:26 +03:00
|
|
|
MouseDrag(aPresContext, aEvent);
|
2016-07-08 10:07:06 +03:00
|
|
|
break;
|
2015-08-29 02:58:30 +03:00
|
|
|
case eMouseUp:
|
2013-10-22 12:55:20 +04:00
|
|
|
if (aEvent->AsMouseEvent()->button == WidgetMouseEvent::eLeftButton) {
|
2006-11-17 00:35:39 +03:00
|
|
|
EndMouseDrag(aPresContext);
|
|
|
|
}
|
2016-07-08 10:07:06 +03:00
|
|
|
break;
|
2015-08-26 15:56:59 +03:00
|
|
|
default:
|
|
|
|
break;
|
1998-11-25 21:11:26 +03:00
|
|
|
}
|
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
|
|
|
{
|
2016-11-28 14:59:02 +03:00
|
|
|
aCursor.mLoading = false;
|
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,
|
2017-08-10 15:40:21 +03:00
|
|
|
const nsRect& aDirtyRect,
|
2006-01-26 05:29:17 +03:00
|
|
|
const nsDisplayListSet& aLists)
|
1998-07-16 03:42:14 +04:00
|
|
|
{
|
2017-08-10 15:40:21 +03: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,
|
2016-07-21 13:36:39 +03:00
|
|
|
const ReflowInput& aReflowInput,
|
1998-10-02 08:10:00 +04:00
|
|
|
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
|
2016-07-21 13:36:39 +03:00
|
|
|
ReflowInput reflowInput(aPresContext, aReflowInput, aChild,
|
2014-07-24 12:28:46 +04:00
|
|
|
LogicalSize(aChild->GetWritingMode(), aSize));
|
2016-07-21 13:36:39 +03:00
|
|
|
reflowInput.SetComputedWidth(std::max(0, aSize.width - reflowInput.ComputedPhysicalBorderPadding().LeftRight()));
|
|
|
|
reflowInput.SetComputedHeight(std::max(0, aSize.height - reflowInput.ComputedPhysicalBorderPadding().TopBottom()));
|
2016-07-26 12:10:52 +03:00
|
|
|
ReflowOutput reflowOutput(aReflowInput);
|
|
|
|
reflowOutput.Width() = aSize.width;
|
|
|
|
reflowOutput.Height() = aSize.height;
|
1999-10-30 06:52:11 +04:00
|
|
|
nsReflowStatus status;
|
2012-12-03 23:47:10 +04:00
|
|
|
|
2016-07-26 12:10:52 +03:00
|
|
|
ReflowChild(aChild, aPresContext, reflowOutput, reflowInput, aOffset.x,
|
1999-11-19 18:33:29 +03:00
|
|
|
aOffset.y, 0, status);
|
2017-02-11 17:45:07 +03:00
|
|
|
NS_ASSERTION(status.IsComplete(), "bad status");
|
2012-12-03 23:47:10 +04:00
|
|
|
|
1999-10-30 06:52:11 +04:00
|
|
|
// Place and size the child
|
2016-07-26 12:10:52 +03:00
|
|
|
reflowOutput.Width() = aSize.width;
|
|
|
|
reflowOutput.Height() = aSize.height;
|
|
|
|
FinishReflowChild(aChild, aPresContext, reflowOutput, 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;
|
|
|
|
|
|
|
|
case NS_STYLE_FRAME_NO:
|
|
|
|
case NS_STYLE_FRAME_0:
|
|
|
|
return eFrameborder_No;
|
|
|
|
}
|
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-05-13 04:47:52 +04:00
|
|
|
void
|
2012-12-03 23:47:10 +04:00
|
|
|
nsHTMLFramesetFrame::Reflow(nsPresContext* aPresContext,
|
2016-07-21 13:36:38 +03:00
|
|
|
ReflowOutput& aDesiredSize,
|
2016-07-21 13:36:39 +03:00
|
|
|
const ReflowInput& aReflowInput,
|
1998-10-02 08:10:00 +04:00
|
|
|
nsReflowStatus& aStatus)
|
1998-09-03 05:16:27 +04:00
|
|
|
{
|
2015-03-30 01:38:40 +03:00
|
|
|
MarkInReflow();
|
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");
|
2016-07-21 13:36:39 +03:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowInput, aDesiredSize, aStatus);
|
2003-12-21 08:36:36 +03:00
|
|
|
nsIPresShell *shell = aPresContext->PresShell();
|
2016-02-24 10:01:11 +03:00
|
|
|
StyleSetHandle styleSet = shell->StyleSet();
|
2003-12-21 08:36:36 +03:00
|
|
|
|
2015-06-18 09:33:50 +03:00
|
|
|
GetParent()->AddStateBits(NS_FRAME_CONTAINS_RELATIVE_BSIZE);
|
2012-12-03 23:47:10 +04:00
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
//printf("FramesetFrame2::Reflow %X (%d,%d) \n", this, aReflowInput.AvailableWidth(), aReflowInput.AvailableHeight());
|
1998-07-16 03:42:14 +04:00
|
|
|
// Always get the size so that the caller knows how big we are
|
2016-07-21 13:36:39 +03:00
|
|
|
GetDesiredSize(aPresContext, aReflowInput, aDesiredSize);
|
2012-12-03 23:47:10 +04:00
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
nscoord width = (aDesiredSize.Width() <= aReflowInput.AvailableWidth())
|
|
|
|
? aDesiredSize.Width() : aReflowInput.AvailableWidth();
|
|
|
|
nscoord height = (aDesiredSize.Height() <= aReflowInput.AvailableHeight())
|
|
|
|
? aDesiredSize.Height() : aReflowInput.AvailableHeight();
|
2001-11-02 05:19:49 +03:00
|
|
|
|
2015-11-10 08:42:29 +03:00
|
|
|
// We might be reflowed more than once with NS_FRAME_FIRST_REFLOW;
|
|
|
|
// that's allowed. (Though it will only happen for misuse of frameset
|
|
|
|
// that includes it within other content.) So measure firstTime by
|
|
|
|
// what we care about, which is whether we've processed the data we
|
|
|
|
// process below if firstTime is true.
|
|
|
|
MOZ_ASSERT(!mChildFrameborder == !mChildBorderColors);
|
|
|
|
bool firstTime = !!mChildFrameborder;
|
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) {
|
2017-02-14 12:55:48 +03:00
|
|
|
aStatus.Reset();
|
2007-04-10 23:08:21 +04:00
|
|
|
mDrag.UnSet();
|
2016-07-21 13:36:39 +03:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aDesiredSize);
|
2014-05-13 04:47:52 +04:00
|
|
|
return;
|
2007-04-10 23:08:21 +04:00
|
|
|
}
|
2007-03-23 02:57:55 +03:00
|
|
|
|
2015-10-29 23:16:13 +03:00
|
|
|
CalculateRowCol(aPresContext, width, mNumCols, colSpecs, mColSizes.get());
|
|
|
|
CalculateRowCol(aPresContext, height, mNumRows, rowSpecs, mRowSizes.get());
|
1998-07-20 22:52:40 +04:00
|
|
|
|
2015-10-30 22:12:25 +03:00
|
|
|
UniquePtr<bool[]> verBordersVis; // vertical borders visibility
|
|
|
|
UniquePtr<nscolor[]> verBorderColors;
|
|
|
|
UniquePtr<bool[]> horBordersVis; // horizontal borders visibility
|
|
|
|
UniquePtr<nscolor[]> horBorderColors;
|
2006-10-07 12:53:06 +04:00
|
|
|
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.
|
2016-08-23 18:24:54 +03:00
|
|
|
static_assert(NS_MAX_FRAMESET_SPEC_COUNT < UINT_MAX / sizeof(bool),
|
|
|
|
"Check for overflow");
|
|
|
|
static_assert(NS_MAX_FRAMESET_SPEC_COUNT < UINT_MAX / sizeof(nscolor),
|
|
|
|
"Check for overflow");
|
2011-01-25 04:38:07 +03:00
|
|
|
|
2015-10-30 22:12:25 +03:00
|
|
|
verBordersVis = MakeUnique<bool[]>(mNumCols);
|
|
|
|
verBorderColors = MakeUnique<nscolor[]>(mNumCols);
|
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
|
|
|
|
2015-10-30 22:12:25 +03:00
|
|
|
horBordersVis = MakeUnique<bool[]>(mNumRows);
|
|
|
|
horBorderColors = MakeUnique<nscolor[]>(mNumRows);
|
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;
|
2014-07-24 12:30:07 +04:00
|
|
|
WritingMode wm = GetWritingMode();
|
|
|
|
LogicalSize logicalSize(wm);
|
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;
|
2014-07-24 12:30:07 +04:00
|
|
|
GetSizeOfChildAt(childX, wm, logicalSize, cellIndex);
|
|
|
|
size = logicalSize.GetPhysicalSize(wm);
|
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
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsStyleContext> pseudoStyleContext;
|
2009-12-11 10:37:40 +03:00
|
|
|
pseudoStyleContext = styleSet->
|
2017-03-15 21:00:43 +03:00
|
|
|
ResolveNonInheritingAnonymousBoxStyle(nsCSSAnonBoxes::horizontalFramesetBorder);
|
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);
|
2016-07-21 13:36:39 +03:00
|
|
|
ReflowPlaceChild(borderFrame, aPresContext, aReflowInput, offset, borderSize);
|
2013-08-03 08:11:06 +04:00
|
|
|
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
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsStyleContext> pseudoStyleContext;
|
2009-12-11 10:37:40 +03:00
|
|
|
pseudoStyleContext = styleSet->
|
2017-03-15 21:00:43 +03:00
|
|
|
ResolveNonInheritingAnonymousBoxStyle(nsCSSAnonBoxes::verticalFramesetBorder);
|
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());
|
2016-07-21 13:36:39 +03:00
|
|
|
ReflowPlaceChild(borderFrame, aPresContext, aReflowInput, offset, borderSize);
|
2013-08-03 08:11:06 +04:00
|
|
|
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
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
ReflowPlaceChild(child, aPresContext, aReflowInput, 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
|
2016-07-19 21:28:54 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
nsHTMLFramesetBlankFrame* blank = do_QueryFrame(child);
|
|
|
|
MOZ_ASSERT(blank, "unexpected child frame type");
|
|
|
|
#endif
|
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]);
|
2015-07-21 07:18:17 +03:00
|
|
|
SetBorderResize(mVerBorders[verX]);
|
1998-09-03 05:16:27 +04:00
|
|
|
childColor = (NO_COLOR == verBorderColors[verX]) ? borderColor : verBorderColors[verX];
|
2001-04-12 12:16:54 +04:00
|
|
|
mVerBorders[verX]->SetColor(childColor);
|
1998-07-31 21:47:50 +04:00
|
|
|
}
|
1998-07-31 01:25:35 +04:00
|
|
|
}
|
|
|
|
for (int horX = 0; horX < mNumRows-1; horX++) {
|
2001-04-12 12:16:54 +04:00
|
|
|
if (mHorBorders[horX]) {
|
|
|
|
mHorBorders[horX]->SetVisibility(horBordersVis[horX]);
|
2015-07-21 07:18:17 +03:00
|
|
|
SetBorderResize(mHorBorders[horX]);
|
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
|
|
|
}
|
|
|
|
|
2015-10-29 23:16:13 +03:00
|
|
|
mChildFrameborder.reset();
|
|
|
|
mChildBorderColors.reset();
|
1998-07-31 01:25:35 +04:00
|
|
|
}
|
|
|
|
|
2017-02-14 12:55:48 +03:00
|
|
|
aStatus.Reset();
|
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();
|
2014-03-03 12:54:39 +04:00
|
|
|
FinishAndStoreOverflow(&aDesiredSize);
|
2007-06-27 20:37:50 +04:00
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aDesiredSize);
|
1998-07-16 03:42:14 +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
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2016-08-23 18:24:54 +03:00
|
|
|
static_assert(NS_MAX_FRAMESET_SPEC_COUNT < INT32_MAX / NS_MAX_FRAMESET_SPEC_COUNT,
|
|
|
|
"Check for overflow");
|
|
|
|
static_assert(NS_MAX_FRAMESET_SPEC_COUNT
|
|
|
|
< UINT_MAX / sizeof(int32_t) / NS_MAX_FRAMESET_SPEC_COUNT,
|
|
|
|
"Check for overflow");
|
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;
|
2015-07-21 07:18:17 +03:00
|
|
|
SetBorderResize(mVerBorders[verX]);
|
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;
|
2015-07-21 07:18:17 +03:00
|
|
|
SetBorderResize(mHorBorders[horX]);
|
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;
|
|
|
|
|
2016-04-18 17:09:02 +03:00
|
|
|
mFirstDragPoint = aEvent->mRefPoint;
|
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
|
2017-03-01 20:03:14 +03:00
|
|
|
AutoWeakFrame weakFrame(this);
|
1998-09-03 05:16:27 +04:00
|
|
|
if (mDragger->mVertical) {
|
2016-04-18 17:09:02 +03:00
|
|
|
change = aPresContext->DevPixelsToAppUnits(
|
|
|
|
aEvent->mRefPoint.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;
|
2015-10-29 23:16:13 +03:00
|
|
|
GenerateRowCol(aPresContext, width, mNumCols, colSpecs, mColSizes.get(),
|
2002-08-06 05:06:50 +04:00
|
|
|
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 {
|
2016-04-18 17:09:02 +03:00
|
|
|
change = aPresContext->DevPixelsToAppUnits(
|
|
|
|
aEvent->mRefPoint.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;
|
2015-10-29 23:16:13 +03:00
|
|
|
GenerateRowCol(aPresContext, height, mNumRows, rowSpecs, mRowSizes.get(),
|
2002-08-06 05:06:50 +04:00
|
|
|
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,
|
2017-04-30 18:30:08 +03:00
|
|
|
bool aVertical,
|
|
|
|
bool aVisibility)
|
2017-05-26 13:11:11 +03:00
|
|
|
: nsLeafFrame(aContext, kClassID)
|
2017-04-30 18:30:08 +03:00
|
|
|
, mWidth(aWidth)
|
|
|
|
, mVertical(aVertical)
|
|
|
|
, mVisibility(aVisibility)
|
1998-07-27 09:59:37 +04:00
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
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)
|
|
|
|
|
2014-07-24 21:03:26 +04:00
|
|
|
nscoord nsHTMLFramesetBorderFrame::GetIntrinsicISize()
|
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
|
|
|
}
|
|
|
|
|
2014-07-24 21:03:26 +04:00
|
|
|
nscoord nsHTMLFramesetBorderFrame::GetIntrinsicBSize()
|
2008-10-30 20:10:19 +03:00
|
|
|
{
|
|
|
|
// 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-05-13 04:47:52 +04:00
|
|
|
void
|
2012-12-03 23:47:10 +04:00
|
|
|
nsHTMLFramesetBorderFrame::Reflow(nsPresContext* aPresContext,
|
2016-07-21 13:36:38 +03:00
|
|
|
ReflowOutput& aDesiredSize,
|
2016-07-21 13:36:39 +03:00
|
|
|
const ReflowInput& aReflowInput,
|
1998-10-02 08:10:00 +04:00
|
|
|
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");
|
2016-07-21 13:36:39 +03:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowInput, aDesiredSize, aStatus);
|
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
|
|
|
|
|
|
|
// Override Reflow(), since we don't want to deal with what our
|
|
|
|
// computed values are.
|
2016-07-21 13:36:39 +03:00
|
|
|
SizeToAvailSize(aReflowInput, aDesiredSize);
|
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
|
|
|
|
2010-10-07 08:25:46 +04:00
|
|
|
aDesiredSize.SetOverflowAreasToDesiredBounds();
|
2017-02-14 12:55:48 +03:00
|
|
|
aStatus.Reset();
|
1998-07-27 09:59:37 +04:00
|
|
|
}
|
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,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsTArray<nsIFrame*> *aOutFrames) 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,
|
2017-06-09 22:14:53 +03:00
|
|
|
gfxContext* aCtx) 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,
|
2017-06-09 22:14:53 +03:00
|
|
|
gfxContext* aCtx)
|
2006-01-26 05:29:17 +03:00
|
|
|
{
|
2007-07-08 11:08:04 +04:00
|
|
|
static_cast<nsHTMLFramesetBorderFrame*>(mFrame)->
|
2014-10-20 13:55:48 +04:00
|
|
|
PaintBorder(aCtx->GetDrawTarget(), 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,
|
2017-08-10 15:40:21 +03:00
|
|
|
const nsRect& aDirtyRect,
|
2006-01-26 05:29:17 +03:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2014-10-20 13:55:48 +04:00
|
|
|
void nsHTMLFramesetBorderFrame::PaintBorder(DrawTarget* aDrawTarget,
|
2006-01-26 05:29:17 +03:00
|
|
|
nsPoint aPt)
|
1998-07-27 09:59:37 +04: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
|
|
|
|
2014-10-20 13:55:48 +04:00
|
|
|
ColorPattern bgColor(ToDeviceColor(
|
|
|
|
LookAndFeel::GetColor(LookAndFeel::eColorID_WidgetBackground,
|
|
|
|
NS_RGB(200, 200, 200))));
|
|
|
|
|
|
|
|
ColorPattern fgColor(ToDeviceColor(
|
|
|
|
LookAndFeel::GetColor(LookAndFeel::eColorID_WidgetForeground,
|
|
|
|
NS_RGB(0, 0, 0))));
|
|
|
|
|
|
|
|
ColorPattern hltColor(ToDeviceColor(
|
|
|
|
LookAndFeel::GetColor(LookAndFeel::eColorID_Widget3DHighlight,
|
|
|
|
NS_RGB(255, 255, 255))));
|
1998-07-27 09:59:37 +04:00
|
|
|
|
2014-10-20 13:55:48 +04:00
|
|
|
ColorPattern sdwColor(ToDeviceColor(
|
|
|
|
LookAndFeel::GetColor(LookAndFeel::eColorID_Widget3DShadow,
|
|
|
|
NS_RGB(128, 128, 128))));
|
|
|
|
|
|
|
|
ColorPattern color(ToDeviceColor(NS_RGB(255, 255, 255))); // default to white
|
2015-07-21 07:22:02 +03:00
|
|
|
if (mVisibility) {
|
2014-10-20 13:55:48 +04:00
|
|
|
color = (NO_COLOR == mColor) ? bgColor :
|
|
|
|
ColorPattern(ToDeviceColor(mColor));
|
1998-09-03 05:16:27 +04:00
|
|
|
}
|
2014-10-20 13:55:48 +04:00
|
|
|
|
|
|
|
int32_t appUnitsPerDevPixel = PresContext()->AppUnitsPerDevPixel();
|
|
|
|
|
|
|
|
Point toRefFrame = NSPointToPoint(aPt, appUnitsPerDevPixel);
|
|
|
|
|
|
|
|
AutoRestoreTransform autoRestoreTransform(aDrawTarget);
|
|
|
|
aDrawTarget->SetTransform(
|
|
|
|
aDrawTarget->GetTransform().PreTranslate(toRefFrame));
|
|
|
|
|
|
|
|
nsPoint start(0, 0);
|
|
|
|
nsPoint end = mVertical ? nsPoint(0, mRect.height) : nsPoint(mRect.width, 0);
|
|
|
|
|
1998-08-06 23:40:37 +04:00
|
|
|
// draw grey or white first
|
|
|
|
for (int i = 0; i < widthInPixels; i++) {
|
2014-10-20 13:55:48 +04:00
|
|
|
StrokeLineWithSnapping(start, end, appUnitsPerDevPixel, *aDrawTarget,
|
|
|
|
color);
|
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
|
|
|
|
2015-07-21 07:22:02 +03:00
|
|
|
if (!mVisibility)
|
2006-01-26 05:29:17 +03:00
|
|
|
return;
|
1998-08-06 23:40:37 +04:00
|
|
|
|
|
|
|
if (widthInPixels >= 5) {
|
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;
|
2014-10-20 13:55:48 +04:00
|
|
|
StrokeLineWithSnapping(start, end, appUnitsPerDevPixel, *aDrawTarget,
|
|
|
|
hltColor);
|
1998-08-06 23:40:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (widthInPixels >= 2) {
|
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;
|
2014-10-20 13:55:48 +04:00
|
|
|
StrokeLineWithSnapping(start, end, appUnitsPerDevPixel, *aDrawTarget,
|
|
|
|
sdwColor);
|
1998-08-06 23:40:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (widthInPixels >= 1) {
|
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;
|
2014-10-20 13:55:48 +04:00
|
|
|
StrokeLineWithSnapping(start, end, appUnitsPerDevPixel, *aDrawTarget,
|
|
|
|
fgColor);
|
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;
|
|
|
|
}
|
|
|
|
|
2015-08-29 02:58:30 +03:00
|
|
|
if (aEvent->mMessage == eMouseDown &&
|
2013-10-22 12:55:20 +04:00
|
|
|
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
|
|
|
{
|
2016-11-28 14:59:02 +03:00
|
|
|
aCursor.mLoading = false;
|
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
|
|
|
}
|
|
|
|
|
2014-07-24 21:03:26 +04:00
|
|
|
nscoord nsHTMLFramesetBlankFrame::GetIntrinsicISize()
|
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
|
|
|
}
|
|
|
|
|
2014-07-24 21:03:26 +04:00
|
|
|
nscoord nsHTMLFramesetBlankFrame::GetIntrinsicBSize()
|
2008-10-30 20:10:19 +03:00
|
|
|
{
|
|
|
|
// No intrinsic height
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-05-13 04:47:52 +04:00
|
|
|
void
|
2012-12-03 23:47:10 +04:00
|
|
|
nsHTMLFramesetBlankFrame::Reflow(nsPresContext* aPresContext,
|
2016-07-21 13:36:38 +03:00
|
|
|
ReflowOutput& aDesiredSize,
|
2016-07-21 13:36:39 +03:00
|
|
|
const ReflowInput& aReflowInput,
|
1998-10-02 08:10:00 +04:00
|
|
|
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.
|
2016-07-21 13:36:39 +03:00
|
|
|
SizeToAvailSize(aReflowInput, aDesiredSize);
|
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
|
|
|
|
2010-10-07 08:25:46 +04:00
|
|
|
aDesiredSize.SetOverflowAreasToDesiredBounds();
|
2017-02-14 12:55:48 +03:00
|
|
|
aStatus.Reset();
|
1998-08-06 02:24:56 +04:00
|
|
|
}
|
|
|
|
|
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,
|
2017-06-09 22:14:53 +03:00
|
|
|
gfxContext* aCtx) 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,
|
2017-06-09 22:14:53 +03:00
|
|
|
gfxContext* aCtx)
|
1998-08-06 02:24:56 +04:00
|
|
|
{
|
2014-10-19 16:22:22 +04:00
|
|
|
DrawTarget* drawTarget = aCtx->GetDrawTarget();
|
|
|
|
int32_t appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel();
|
2014-10-22 15:29:06 +04:00
|
|
|
Rect rect =
|
|
|
|
NSRectToSnappedRect(mVisibleRect, appUnitsPerDevPixel, *drawTarget);
|
2014-10-19 16:22:22 +04:00
|
|
|
ColorPattern white(ToDeviceColor(Color(1.f, 1.f, 1.f, 1.f)));
|
|
|
|
drawTarget->FillRect(rect, white);
|
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,
|
2017-08-10 15:40:21 +03:00
|
|
|
const nsRect& aDirtyRect,
|
2006-01-26 05:29:17 +03:00
|
|
|
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
|
|
|
}
|