2017-10-27 17:33:53 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 11:12:37 +00: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 18:29:03 +00:00
|
|
|
|
|
|
|
/* rendering object for HTML <frameset> elements */
|
|
|
|
|
2013-09-25 01:43:43 +00:00
|
|
|
#include "nsFrameSetFrame.h"
|
|
|
|
|
2014-09-11 06:48:09 +00:00
|
|
|
#include "gfxContext.h"
|
2014-10-19 12:22:22 +00:00
|
|
|
#include "gfxUtils.h"
|
2018-03-22 18:20:41 +00:00
|
|
|
#include "mozilla/ComputedStyle.h"
|
2012-12-14 23:58:45 +00:00
|
|
|
#include "mozilla/DebugOnly.h"
|
2014-10-19 12:22:22 +00:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2014-10-20 09:55:48 +00:00
|
|
|
#include "mozilla/gfx/Helpers.h"
|
2012-12-14 23:58:45 +00:00
|
|
|
#include "mozilla/Likely.h"
|
2019-04-03 12:40:26 +00:00
|
|
|
#include "mozilla/PresShell.h"
|
2019-04-30 01:52:53 +00:00
|
|
|
#include "mozilla/PresShellInlines.h"
|
2012-12-14 23:58:45 +00:00
|
|
|
|
2005-01-12 19:45:38 +00:00
|
|
|
#include "nsGenericHTMLElement.h"
|
2012-09-30 16:40:24 +00:00
|
|
|
#include "nsAttrValueInlines.h"
|
1998-07-15 23:42:14 +00:00
|
|
|
#include "nsLeafFrame.h"
|
2011-12-27 20:18:48 +00:00
|
|
|
#include "nsContainerFrame.h"
|
2014-09-11 06:48:09 +00:00
|
|
|
#include "nsLayoutUtils.h"
|
2004-07-31 23:15:21 +00:00
|
|
|
#include "nsPresContext.h"
|
2018-02-13 22:38:20 +00:00
|
|
|
#include "nsIContentInlines.h"
|
2007-01-30 00:06:41 +00:00
|
|
|
#include "nsGkAtoms.h"
|
1998-09-09 23:30:30 +00:00
|
|
|
#include "nsStyleConsts.h"
|
1998-09-13 02:45:07 +00:00
|
|
|
#include "nsHTMLParts.h"
|
2014-02-27 23:04:46 +00:00
|
|
|
#include "nsNameSpaceManager.h"
|
2002-11-17 15:37:56 +00:00
|
|
|
#include "nsCSSAnonBoxes.h"
|
2018-03-29 11:15:46 +00:00
|
|
|
#include "mozilla/ServoStyleSet.h"
|
2019-04-16 21:18:30 +00:00
|
|
|
#include "mozilla/ServoStyleSetInlines.h"
|
2010-08-24 07:06:07 +00:00
|
|
|
#include "mozilla/dom/Element.h"
|
2006-01-26 02:29:17 +00:00
|
|
|
#include "nsDisplayList.h"
|
2006-07-02 07:23:10 +00:00
|
|
|
#include "nsNodeUtils.h"
|
2008-04-11 17:29:06 +00:00
|
|
|
#include "mozAutoDocUpdate.h"
|
2011-05-25 06:31:59 +00:00
|
|
|
#include "mozilla/Preferences.h"
|
Bug 1540220 - Remove some useless usage of LazyComputeBehavior::Allow. r=dholbert
This switches nsFrameSetFrame's hacky frame construction codepath to operate on
the flattened tree, since it made me a bit more comfortable about it (all layout
should operate on is the flattened tree, though in this cause this should not
cause any web-observable behavior change, since <frameset> can't be a shadow
host per spec, and we no longer support XBL-in-content).
That doesn't need to compute styles lazily. You only need to compute styles
lazily in descendants of display: none elements, and even though this code
doesn't check on display: none _on the children_, the parent element should
never have display: none (since we're creating an nsFrameSetFrame for it).
There are other places that still call into this (apart from getComputedStyle).
One is nsImageFrame's cursor code. Given the <area> elements referencing an
image map could be anywhere, we need to have lazy computation here.
The other is the viewport style propagation stuff. There shouldn't be a need for
LazyComputeBehavior::Allow on the document element in order to check the
viewport styles propagation, since the root element can't have display: none
ancestors. But we run that code before actually constructing the doc element
containing block, which is when we do the initial document styling.
We could remove that with some more effort, but it's not worth it right now,
since we need to keep using it for the <body>, since the document element could
be display: none itself, and we propagate the overflow styles in that case
still. I filed https://github.com/w3c/csswg-drafts/issues/3779 to potentially
change that.
Differential Revision: https://phabricator.services.mozilla.com/D25455
--HG--
extra : moz-landing-system : lando
2019-04-09 18:03:51 +00:00
|
|
|
#include "mozilla/dom/ChildIterator.h"
|
2012-12-21 14:06:50 +00:00
|
|
|
#include "mozilla/dom/HTMLFrameSetElement.h"
|
2011-09-09 02:27:13 +00:00
|
|
|
#include "mozilla/LookAndFeel.h"
|
2013-09-25 11:21:18 +00:00
|
|
|
#include "mozilla/MouseEvents.h"
|
2012-12-01 02:28:02 +00:00
|
|
|
#include "nsSubDocumentFrame.h"
|
2011-05-25 06:31:59 +00:00
|
|
|
|
|
|
|
using namespace mozilla;
|
2012-12-21 14:06:50 +00:00
|
|
|
using namespace mozilla::dom;
|
2014-10-19 12:22:22 +00:00
|
|
|
using namespace mozilla::gfx;
|
2001-07-16 02:40:48 +00:00
|
|
|
|
1998-07-30 21:25:35 +00:00
|
|
|
// masks for mEdgeVisibility
|
1998-09-03 01:16:27 +00: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 06:13:35 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
* nsFramesetDrag
|
|
|
|
******************************************************************************/
|
2012-12-03 19:47:10 +00:00
|
|
|
nsFramesetDrag::nsFramesetDrag() { UnSet(); }
|
1999-03-10 06:13:35 +00:00
|
|
|
|
2012-12-03 19:47:10 +00:00
|
|
|
void nsFramesetDrag::Reset(bool aVertical, int32_t aIndex, int32_t aChange,
|
|
|
|
nsHTMLFramesetFrame* aSource) {
|
1999-03-10 06:13:35 +00:00
|
|
|
mVertical = aVertical;
|
|
|
|
mIndex = aIndex;
|
|
|
|
mChange = aChange;
|
|
|
|
mSource = aSource;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsFramesetDrag::UnSet() {
|
2011-10-17 14:59:28 +00:00
|
|
|
mVertical = true;
|
1999-03-10 06:13:35 +00:00
|
|
|
mIndex = -1;
|
|
|
|
mChange = 0;
|
2012-07-30 14:20:58 +00:00
|
|
|
mSource = nullptr;
|
1999-03-10 06:13:35 +00:00
|
|
|
}
|
|
|
|
|
1998-07-27 05:59:37 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
* nsHTMLFramesetBorderFrame
|
|
|
|
******************************************************************************/
|
2017-04-30 15:30:08 +00:00
|
|
|
class nsHTMLFramesetBorderFrame final : public nsLeafFrame {
|
1998-07-27 05:59:37 +00:00
|
|
|
public:
|
2017-05-26 10:11:11 +00:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS(nsHTMLFramesetBorderFrame)
|
2009-09-12 16:49:24 +00:00
|
|
|
|
2014-01-05 23:31:14 +00:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual nsresult GetFrameName(nsAString& aResult) const override;
|
1999-11-01 22:12:45 +00:00
|
|
|
#endif
|
1998-07-27 05:59:37 +00:00
|
|
|
|
2014-02-18 07:47:48 +00:00
|
|
|
virtual nsresult HandleEvent(nsPresContext* aPresContext,
|
2014-02-18 08:36:33 +00:00
|
|
|
WidgetGUIEvent* aEvent,
|
2015-03-21 16:28:04 +00:00
|
|
|
nsEventStatus* aEventStatus) override;
|
1998-07-30 21:25:35 +00:00
|
|
|
|
2019-03-13 18:38:09 +00:00
|
|
|
Maybe<Cursor> GetCursor(const nsPoint&) override;
|
2012-12-03 19:47:10 +00:00
|
|
|
|
2013-02-14 11:12:27 +00:00
|
|
|
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
2015-03-21 16:28:04 +00:00
|
|
|
const nsDisplayListSet& aLists) override;
|
1998-07-27 05:59:37 +00:00
|
|
|
|
2014-05-13 00:47:52 +00:00
|
|
|
virtual void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,
|
2016-07-21 10:36:39 +00:00
|
|
|
const ReflowInput& aReflowInput,
|
2015-03-21 16:28:04 +00:00
|
|
|
nsReflowStatus& aStatus) override;
|
1998-07-27 05:59:37 +00:00
|
|
|
|
2015-07-21 04:22:02 +00:00
|
|
|
bool GetVisibility() { return mVisibility; }
|
2011-09-29 06:19:26 +00:00
|
|
|
void SetVisibility(bool aVisibility);
|
1998-09-03 01:16:27 +00:00
|
|
|
void SetColor(nscolor aColor);
|
1998-07-30 21:25:35 +00:00
|
|
|
|
2014-10-20 09:55:48 +00:00
|
|
|
void PaintBorder(DrawTarget* aDrawTarget, nsPoint aPt);
|
2006-01-26 02:29:17 +00:00
|
|
|
|
1998-07-27 05:59:37 +00:00
|
|
|
protected:
|
2019-02-05 16:45:54 +00:00
|
|
|
nsHTMLFramesetBorderFrame(ComputedStyle*, nsPresContext*, int32_t aWidth,
|
2018-03-22 18:20:41 +00:00
|
|
|
bool aVertical, bool aVisible);
|
1998-07-27 05:59:37 +00:00
|
|
|
virtual ~nsHTMLFramesetBorderFrame();
|
2015-03-21 16:28:04 +00: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 05:38:33 +00:00
|
|
|
|
2009-05-12 10:13:09 +00: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 15:56:38 +00:00
|
|
|
int32_t mPrevNeighbor;
|
|
|
|
int32_t mNextNeighbor;
|
2009-05-12 10:13:09 +00:00
|
|
|
nscolor mColor;
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t mWidth;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mVertical;
|
|
|
|
bool mVisibility;
|
|
|
|
bool mCanResize;
|
1998-07-27 05:59:37 +00:00
|
|
|
friend class nsHTMLFramesetFrame;
|
|
|
|
};
|
1998-08-05 22:24:56 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
* nsHTMLFramesetBlankFrame
|
|
|
|
******************************************************************************/
|
2017-04-30 15:30:08 +00:00
|
|
|
class nsHTMLFramesetBlankFrame final : public nsLeafFrame {
|
1998-08-05 22:24:56 +00:00
|
|
|
public:
|
2013-04-03 23:35:07 +00:00
|
|
|
NS_DECL_QUERYFRAME
|
2017-05-26 10:11:11 +00:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS(nsHTMLFramesetBlankFrame)
|
2009-09-12 16:49:24 +00:00
|
|
|
|
2014-01-05 23:31:14 +00:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual nsresult GetFrameName(nsAString& aResult) const override {
|
2013-04-30 18:38:52 +00:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("FramesetBlank"), aResult);
|
|
|
|
}
|
1999-11-01 22:12:45 +00:00
|
|
|
#endif
|
1998-08-05 22:24:56 +00:00
|
|
|
|
2013-02-14 11:12:27 +00:00
|
|
|
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
2015-03-21 16:28:04 +00:00
|
|
|
const nsDisplayListSet& aLists) override;
|
1998-08-05 22:24:56 +00:00
|
|
|
|
2014-05-13 00:47:52 +00:00
|
|
|
virtual void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,
|
2016-07-21 10:36:39 +00:00
|
|
|
const ReflowInput& aReflowInput,
|
2015-03-21 16:28:04 +00:00
|
|
|
nsReflowStatus& aStatus) override;
|
1998-08-05 22:24:56 +00:00
|
|
|
|
|
|
|
protected:
|
2019-02-05 16:45:54 +00:00
|
|
|
explicit nsHTMLFramesetBlankFrame(ComputedStyle* aStyle,
|
|
|
|
nsPresContext* aPresContext)
|
|
|
|
: nsLeafFrame(aStyle, aPresContext, kClassID) {}
|
2017-04-30 15:30:08 +00:00
|
|
|
|
1998-08-05 22:24:56 +00:00
|
|
|
virtual ~nsHTMLFramesetBlankFrame();
|
2015-03-21 16:28:04 +00: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 05:38:33 +00:00
|
|
|
|
1998-08-05 22:24:56 +00:00
|
|
|
friend class nsHTMLFramesetFrame;
|
|
|
|
friend class nsHTMLFrameset;
|
|
|
|
};
|
1998-07-27 05:59:37 +00:00
|
|
|
|
1998-07-15 23:42:14 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
* nsHTMLFramesetFrame
|
|
|
|
******************************************************************************/
|
2011-09-29 06:19:26 +00:00
|
|
|
bool nsHTMLFramesetFrame::gDragInProgress = false;
|
2001-11-02 02:19:49 +00:00
|
|
|
#define DEFAULT_BORDER_WIDTH_PX 6
|
1998-07-15 23:42:14 +00:00
|
|
|
|
2019-02-05 16:45:54 +00:00
|
|
|
nsHTMLFramesetFrame::nsHTMLFramesetFrame(ComputedStyle* aStyle,
|
|
|
|
nsPresContext* aPresContext)
|
|
|
|
: nsContainerFrame(aStyle, aPresContext, kClassID) {
|
1999-04-13 00:56:23 +00: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 01:18:50 +00:00
|
|
|
mFirstDragPoint.x = mFirstDragPoint.y = 0;
|
2007-02-07 07:46:44 +00:00
|
|
|
mMinDrag = nsPresContext::CSSPixelsToAppUnits(2);
|
1999-04-13 00:56:23 +00:00
|
|
|
mNonBorderChildCount = 0;
|
|
|
|
mNonBlankChildCount = 0;
|
2012-07-30 14:20:58 +00:00
|
|
|
mDragger = nullptr;
|
1999-04-13 00:56:23 +00:00
|
|
|
mChildCount = 0;
|
2012-07-30 14:20:58 +00:00
|
|
|
mTopLevelFrameset = nullptr;
|
1999-03-10 06:13:35 +00:00
|
|
|
mEdgeColors.Set(NO_COLOR);
|
1998-07-15 23:42:14 +00:00
|
|
|
}
|
|
|
|
|
1998-07-20 18:52:40 +00:00
|
|
|
nsHTMLFramesetFrame::~nsHTMLFramesetFrame() {}
|
1998-07-15 23:42:14 +00:00
|
|
|
|
2009-01-12 19:20:59 +00:00
|
|
|
NS_QUERYFRAME_HEAD(nsHTMLFramesetFrame)
|
2018-12-07 20:00:18 +00:00
|
|
|
NS_QUERYFRAME_ENTRY(nsHTMLFramesetFrame)
|
2011-12-27 20:18:48 +00:00
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
|
1998-09-03 01:16:27 +00:00
|
|
|
|
2014-05-24 22:20:40 +00:00
|
|
|
void nsHTMLFramesetFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow) {
|
2011-12-27 20:18:48 +00:00
|
|
|
nsContainerFrame::Init(aContent, aParent, aPrevInFlow);
|
1999-03-10 06:13:35 +00:00
|
|
|
// find the highest ancestor that is a frameset
|
2003-07-05 15:30:50 +00:00
|
|
|
nsIFrame* parentFrame = GetParent();
|
2012-12-01 02:28:02 +00:00
|
|
|
mTopLevelFrameset = this;
|
1999-03-10 06:13:35 +00:00
|
|
|
while (parentFrame) {
|
2009-01-12 19:20:59 +00:00
|
|
|
nsHTMLFramesetFrame* frameset = do_QueryFrame(parentFrame);
|
2003-04-21 23:57:47 +00:00
|
|
|
if (frameset) {
|
1999-03-10 06:13:35 +00:00
|
|
|
mTopLevelFrameset = frameset;
|
2003-07-05 15:30:50 +00:00
|
|
|
parentFrame = parentFrame->GetParent();
|
1999-03-10 06:13:35 +00: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 05:38:33 +00:00
|
|
|
|
2009-03-11 15:43:08 +00:00
|
|
|
nsPresContext* presContext = PresContext();
|
2019-04-03 12:40:26 +00:00
|
|
|
mozilla::PresShell* presShell = presContext->PresShell();
|
1999-11-19 15:33:29 +00:00
|
|
|
|
2001-12-07 19:40:07 +00:00
|
|
|
nsFrameborder frameborder = GetFrameBorder();
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t borderWidth = GetBorderWidth(presContext, false);
|
2001-10-07 00:19:01 +00:00
|
|
|
nscolor borderColor = GetBorderColor();
|
2012-12-03 19:47:10 +00:00
|
|
|
|
2002-08-06 01:06:50 +00:00
|
|
|
// Get the rows= cols= data
|
2018-03-21 21:39:04 +00:00
|
|
|
HTMLFrameSetElement* ourContent = HTMLFrameSetElement::FromNode(mContent);
|
2002-08-06 01:06:50 +00:00
|
|
|
NS_ASSERTION(ourContent, "Someone gave us a broken frameset element!");
|
2012-07-30 14:20:58 +00:00
|
|
|
const nsFramesetSpec* rowSpecs = nullptr;
|
|
|
|
const nsFramesetSpec* colSpecs = nullptr;
|
2013-03-20 01:47:48 +00: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 01:38:07 +00:00
|
|
|
|
2016-08-23 15:24:54 +00: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 20:16:13 +00:00
|
|
|
mRowSizes = MakeUnique<nscoord[]>(mNumRows);
|
|
|
|
mColSizes = MakeUnique<nscoord[]>(mNumCols);
|
2001-10-07 00:19:01 +00:00
|
|
|
|
2016-08-23 15:24:54 +00:00
|
|
|
static_assert(
|
|
|
|
NS_MAX_FRAMESET_SPEC_COUNT < INT32_MAX / NS_MAX_FRAMESET_SPEC_COUNT,
|
|
|
|
"Should not overflow numCells");
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t numCells = mNumRows * mNumCols;
|
2001-10-07 00:19:01 +00:00
|
|
|
|
2016-08-23 15:24:54 +00:00
|
|
|
static_assert(NS_MAX_FRAMESET_SPEC_COUNT <
|
|
|
|
UINT_MAX / sizeof(nsHTMLFramesetBorderFrame*),
|
|
|
|
"Should not overflow nsHTMLFramesetBorderFrame");
|
2015-10-29 20:16:13 +00:00
|
|
|
mVerBorders = MakeUnique<nsHTMLFramesetBorderFrame*[]>(
|
|
|
|
mNumCols); // 1 more than number of ver borders
|
2004-12-30 22:05:22 +00:00
|
|
|
|
2001-10-07 00:19:01 +00:00
|
|
|
for (int verX = 0; verX < mNumCols; verX++) mVerBorders[verX] = nullptr;
|
|
|
|
|
2015-10-29 20:16:13 +00:00
|
|
|
mHorBorders = MakeUnique<nsHTMLFramesetBorderFrame*[]>(
|
|
|
|
mNumRows); // 1 more than number of hor borders
|
2004-12-30 22:05:22 +00:00
|
|
|
|
2001-10-07 00:19:01 +00:00
|
|
|
for (int horX = 0; horX < mNumRows; horX++) mHorBorders[horX] = nullptr;
|
2012-12-03 19:47:10 +00:00
|
|
|
|
2016-08-23 15:24:54 +00: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 20:16:13 +00:00
|
|
|
mChildFrameborder = MakeUnique<nsFrameborder[]>(numCells);
|
|
|
|
mChildBorderColors = MakeUnique<nsBorderColor[]>(numCells);
|
2001-10-07 00:19:01 +00:00
|
|
|
|
|
|
|
// create the children frames; skip content which isn't <frameset> or <frame>
|
|
|
|
mChildCount = 0; // number of <frame> or <frameset> children
|
2003-09-27 04:18:26 +00:00
|
|
|
|
Bug 1540220 - Remove some useless usage of LazyComputeBehavior::Allow. r=dholbert
This switches nsFrameSetFrame's hacky frame construction codepath to operate on
the flattened tree, since it made me a bit more comfortable about it (all layout
should operate on is the flattened tree, though in this cause this should not
cause any web-observable behavior change, since <frameset> can't be a shadow
host per spec, and we no longer support XBL-in-content).
That doesn't need to compute styles lazily. You only need to compute styles
lazily in descendants of display: none elements, and even though this code
doesn't check on display: none _on the children_, the parent element should
never have display: none (since we're creating an nsFrameSetFrame for it).
There are other places that still call into this (apart from getComputedStyle).
One is nsImageFrame's cursor code. Given the <area> elements referencing an
image map could be anywhere, we need to have lazy computation here.
The other is the viewport style propagation stuff. There shouldn't be a need for
LazyComputeBehavior::Allow on the document element in order to check the
viewport styles propagation, since the root element can't have display: none
ancestors. But we run that code before actually constructing the doc element
containing block, which is when we do the initial document styling.
We could remove that with some more effort, but it's not worth it right now,
since we need to keep using it for the <body>, since the document element could
be display: none itself, and we propagate the overflow styles in that case
still. I filed https://github.com/w3c/csswg-drafts/issues/3779 to potentially
change that.
Differential Revision: https://phabricator.services.mozilla.com/D25455
--HG--
extra : moz-landing-system : lando
2019-04-09 18:03:51 +00:00
|
|
|
FlattenedChildIterator children(mContent);
|
|
|
|
for (nsIContent* child = children.GetNextChild(); child;
|
|
|
|
child = children.GetNextChild()) {
|
|
|
|
if (mChildCount == numCells) {
|
|
|
|
// we have more <frame> or <frameset> than cells
|
2011-03-04 15:27:02 +00:00
|
|
|
// Clear the lazy bits in the remaining children. Also clear
|
|
|
|
// the restyle flags, like nsCSSFrameConstructor::ProcessChildren does.
|
2017-10-25 08:20:58 +00:00
|
|
|
for (; child; child = child->GetNextSibling()) {
|
2011-03-04 15:27:02 +00:00
|
|
|
child->UnsetFlags(NODE_DESCENDANTS_NEED_FRAMES | NODE_NEEDS_FRAME);
|
2010-05-12 00:30:42 +00:00
|
|
|
}
|
2001-10-07 00:19:01 +00:00
|
|
|
break;
|
|
|
|
}
|
2010-05-12 00:30:42 +00:00
|
|
|
child->UnsetFlags(NODE_DESCENDANTS_NEED_FRAMES | NODE_NEEDS_FRAME);
|
2003-09-27 04:18:26 +00:00
|
|
|
|
2007-03-05 00:11:23 +00:00
|
|
|
// IMPORTANT: This must match the conditions in
|
2012-12-03 19:47:10 +00:00
|
|
|
// nsCSSFrameConstructor::ContentAppended/Inserted/Removed
|
2017-10-25 08:18:41 +00:00
|
|
|
if (!child->IsAnyOfHTMLElements(nsGkAtoms::frameset, nsGkAtoms::frame)) {
|
|
|
|
continue;
|
|
|
|
}
|
2001-10-07 00:19:01 +00:00
|
|
|
|
Bug 1540220 - Remove some useless usage of LazyComputeBehavior::Allow. r=dholbert
This switches nsFrameSetFrame's hacky frame construction codepath to operate on
the flattened tree, since it made me a bit more comfortable about it (all layout
should operate on is the flattened tree, though in this cause this should not
cause any web-observable behavior change, since <frameset> can't be a shadow
host per spec, and we no longer support XBL-in-content).
That doesn't need to compute styles lazily. You only need to compute styles
lazily in descendants of display: none elements, and even though this code
doesn't check on display: none _on the children_, the parent element should
never have display: none (since we're creating an nsFrameSetFrame for it).
There are other places that still call into this (apart from getComputedStyle).
One is nsImageFrame's cursor code. Given the <area> elements referencing an
image map could be anywhere, we need to have lazy computation here.
The other is the viewport style propagation stuff. There shouldn't be a need for
LazyComputeBehavior::Allow on the document element in order to check the
viewport styles propagation, since the root element can't have display: none
ancestors. But we run that code before actually constructing the doc element
containing block, which is when we do the initial document styling.
We could remove that with some more effort, but it's not worth it right now,
since we need to keep using it for the <body>, since the document element could
be display: none itself, and we propagate the overflow styles in that case
still. I filed https://github.com/w3c/csswg-drafts/issues/3779 to potentially
change that.
Differential Revision: https://phabricator.services.mozilla.com/D25455
--HG--
extra : moz-landing-system : lando
2019-04-09 18:03:51 +00:00
|
|
|
// FIXME(emilio): This doesn't even respect display: none, but that matches
|
|
|
|
// other browsers ;_;
|
|
|
|
//
|
|
|
|
// Maybe we should change that though.
|
|
|
|
RefPtr<ComputedStyle> kidStyle =
|
|
|
|
presShell->StyleSet()->ResolveServoStyle(*child->AsElement());
|
2017-10-25 08:18:41 +00:00
|
|
|
nsIFrame* frame;
|
|
|
|
if (child->IsHTMLElement(nsGkAtoms::frameset)) {
|
Bug 1540220 - Remove some useless usage of LazyComputeBehavior::Allow. r=dholbert
This switches nsFrameSetFrame's hacky frame construction codepath to operate on
the flattened tree, since it made me a bit more comfortable about it (all layout
should operate on is the flattened tree, though in this cause this should not
cause any web-observable behavior change, since <frameset> can't be a shadow
host per spec, and we no longer support XBL-in-content).
That doesn't need to compute styles lazily. You only need to compute styles
lazily in descendants of display: none elements, and even though this code
doesn't check on display: none _on the children_, the parent element should
never have display: none (since we're creating an nsFrameSetFrame for it).
There are other places that still call into this (apart from getComputedStyle).
One is nsImageFrame's cursor code. Given the <area> elements referencing an
image map could be anywhere, we need to have lazy computation here.
The other is the viewport style propagation stuff. There shouldn't be a need for
LazyComputeBehavior::Allow on the document element in order to check the
viewport styles propagation, since the root element can't have display: none
ancestors. But we run that code before actually constructing the doc element
containing block, which is when we do the initial document styling.
We could remove that with some more effort, but it's not worth it right now,
since we need to keep using it for the <body>, since the document element could
be display: none itself, and we propagate the overflow styles in that case
still. I filed https://github.com/w3c/csswg-drafts/issues/3779 to potentially
change that.
Differential Revision: https://phabricator.services.mozilla.com/D25455
--HG--
extra : moz-landing-system : lando
2019-04-09 18:03:51 +00:00
|
|
|
frame = NS_NewHTMLFramesetFrame(presShell, kidStyle);
|
2004-12-30 22:05:22 +00:00
|
|
|
|
2017-10-25 08:18:41 +00:00
|
|
|
nsHTMLFramesetFrame* childFrame = (nsHTMLFramesetFrame*)frame;
|
|
|
|
childFrame->SetParentFrameborder(frameborder);
|
|
|
|
childFrame->SetParentBorderWidth(borderWidth);
|
|
|
|
childFrame->SetParentBorderColor(borderColor);
|
|
|
|
frame->Init(child, this, nullptr);
|
2004-12-30 22:05:22 +00:00
|
|
|
|
2017-10-25 08:18:41 +00:00
|
|
|
mChildBorderColors[mChildCount].Set(childFrame->GetBorderColor());
|
|
|
|
} else { // frame
|
Bug 1540220 - Remove some useless usage of LazyComputeBehavior::Allow. r=dholbert
This switches nsFrameSetFrame's hacky frame construction codepath to operate on
the flattened tree, since it made me a bit more comfortable about it (all layout
should operate on is the flattened tree, though in this cause this should not
cause any web-observable behavior change, since <frameset> can't be a shadow
host per spec, and we no longer support XBL-in-content).
That doesn't need to compute styles lazily. You only need to compute styles
lazily in descendants of display: none elements, and even though this code
doesn't check on display: none _on the children_, the parent element should
never have display: none (since we're creating an nsFrameSetFrame for it).
There are other places that still call into this (apart from getComputedStyle).
One is nsImageFrame's cursor code. Given the <area> elements referencing an
image map could be anywhere, we need to have lazy computation here.
The other is the viewport style propagation stuff. There shouldn't be a need for
LazyComputeBehavior::Allow on the document element in order to check the
viewport styles propagation, since the root element can't have display: none
ancestors. But we run that code before actually constructing the doc element
containing block, which is when we do the initial document styling.
We could remove that with some more effort, but it's not worth it right now,
since we need to keep using it for the <body>, since the document element could
be display: none itself, and we propagate the overflow styles in that case
still. I filed https://github.com/w3c/csswg-drafts/issues/3779 to potentially
change that.
Differential Revision: https://phabricator.services.mozilla.com/D25455
--HG--
extra : moz-landing-system : lando
2019-04-09 18:03:51 +00:00
|
|
|
frame = NS_NewSubDocumentFrame(presShell, kidStyle);
|
2001-10-07 00:19:01 +00:00
|
|
|
|
2017-10-25 08:18:41 +00:00
|
|
|
frame->Init(child, this, nullptr);
|
2012-12-03 19:47:10 +00:00
|
|
|
|
2017-10-25 08:18:41 +00:00
|
|
|
mChildFrameborder[mChildCount] = GetFrameBorder(child);
|
|
|
|
mChildBorderColors[mChildCount].Set(GetBorderColor(child));
|
2001-10-07 00:19:01 +00:00
|
|
|
}
|
2017-10-25 08:18:41 +00:00
|
|
|
child->SetPrimaryFrame(frame);
|
|
|
|
|
|
|
|
mFrames.AppendFrame(nullptr, frame);
|
|
|
|
|
|
|
|
mChildCount++;
|
2001-10-07 00:19:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mNonBlankChildCount = mChildCount;
|
|
|
|
// add blank frames for frameset cells that had no content provided
|
|
|
|
for (int blankX = mChildCount; blankX < numCells; blankX++) {
|
2018-03-22 18:20:41 +00:00
|
|
|
RefPtr<ComputedStyle> pseudoComputedStyle;
|
|
|
|
pseudoComputedStyle =
|
2019-04-03 12:40:26 +00:00
|
|
|
presShell->StyleSet()->ResolveNonInheritingAnonymousBoxStyle(
|
2019-02-19 13:44:33 +00:00
|
|
|
PseudoStyleType::framesetBlank);
|
2004-12-30 22:05:22 +00:00
|
|
|
|
2012-12-03 19:47:10 +00: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
|
2019-04-03 12:40:26 +00:00
|
|
|
nsHTMLFramesetBlankFrame* blankFrame = new (presShell)
|
2019-02-05 16:45:54 +00:00
|
|
|
nsHTMLFramesetBlankFrame(pseudoComputedStyle, PresContext());
|
2006-03-26 21:30:36 +00:00
|
|
|
|
2013-03-20 01:47:48 +00:00
|
|
|
blankFrame->Init(mContent, this, nullptr);
|
2012-12-03 19:47:10 +00:00
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
mFrames.AppendFrame(nullptr, blankFrame);
|
2009-09-18 11:09:35 +00:00
|
|
|
|
2001-10-07 00:19:01 +00:00
|
|
|
mChildBorderColors[mChildCount].Set(NO_COLOR);
|
|
|
|
mChildCount++;
|
|
|
|
}
|
|
|
|
|
|
|
|
mNonBorderChildCount = mChildCount;
|
1999-03-10 06:13:35 +00:00
|
|
|
}
|
|
|
|
|
2011-08-24 20:54:30 +00:00
|
|
|
void nsHTMLFramesetFrame::SetInitialChildList(ChildListID aListID,
|
2009-07-28 12:53:20 +00:00
|
|
|
nsFrameList& aChildList) {
|
2009-01-19 18:31:31 +00:00
|
|
|
// We do this weirdness where we create our child frames in Init(). On the
|
2009-07-28 12:53:20 +00: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-24 20:54:30 +00:00
|
|
|
if (aListID == kPrincipalList && aChildList.IsEmpty()) {
|
2014-05-28 19:36:58 +00:00
|
|
|
return;
|
2009-01-19 18:31:31 +00:00
|
|
|
}
|
|
|
|
|
2014-05-28 19:36:58 +00:00
|
|
|
nsContainerFrame::SetInitialChildList(aListID, aChildList);
|
2009-01-19 18:31:31 +00:00
|
|
|
}
|
|
|
|
|
1998-11-28 18:59:38 +00:00
|
|
|
// XXX should this try to allocate twips based on an even pixel boundary?
|
2012-12-03 19:47:10 +00:00
|
|
|
void nsHTMLFramesetFrame::Scale(nscoord aDesired, int32_t aNumIndicies,
|
|
|
|
int32_t* aIndicies, int32_t aNumItems,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t* aItems) {
|
|
|
|
int32_t actual = 0;
|
|
|
|
int32_t i, j;
|
1998-11-28 18:59:38 +00:00
|
|
|
// get the actual total
|
|
|
|
for (i = 0; i < aNumIndicies; i++) {
|
|
|
|
j = aIndicies[i];
|
|
|
|
actual += aItems[j];
|
|
|
|
}
|
|
|
|
|
2003-09-13 19:42:43 +00: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 18:59:38 +00:00
|
|
|
}
|
|
|
|
|
2003-09-13 19:42:43 +00:00
|
|
|
if (aNumIndicies > 0 && aDesired != actual) {
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t unit = (aDesired > actual) ? 1 : -1;
|
2000-01-07 05:49:20 +00:00
|
|
|
for (i = 0; (i < aNumIndicies) && (aDesired != actual); i++) {
|
1998-11-28 18:59:38 +00:00
|
|
|
j = aIndicies[i];
|
2000-01-07 05:49:20 +00:00
|
|
|
if (j < aNumItems) {
|
|
|
|
aItems[j] += unit;
|
|
|
|
actual += unit;
|
|
|
|
}
|
1998-11-28 18:59:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-12-03 19:47:10 +00:00
|
|
|
|
1998-07-15 23:42:14 +00:00
|
|
|
/**
|
|
|
|
* Translate the rows/cols specs into an array of integer sizes for
|
1998-11-28 18:59:38 +00: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-15 23:42:14 +00:00
|
|
|
*/
|
2012-12-03 19:47:10 +00:00
|
|
|
void nsHTMLFramesetFrame::CalculateRowCol(nsPresContext* aPresContext,
|
|
|
|
nscoord aSize, int32_t aNumSpecs,
|
|
|
|
const nsFramesetSpec* aSpecs,
|
2002-08-06 01:06:50 +00:00
|
|
|
nscoord* aValues) {
|
2016-08-23 15:24:54 +00: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 01:38:07 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t fixedTotal = 0;
|
|
|
|
int32_t numFixed = 0;
|
2015-10-30 19:12:25 +00:00
|
|
|
auto fixed = MakeUnique<int32_t[]>(aNumSpecs);
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t numPercent = 0;
|
2015-10-30 19:12:25 +00:00
|
|
|
auto percent = MakeUnique<int32_t[]>(aNumSpecs);
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t relativeSums = 0;
|
|
|
|
int32_t numRelative = 0;
|
2015-10-30 19:12:25 +00:00
|
|
|
auto relative = MakeUnique<int32_t[]>(aNumSpecs);
|
2006-10-07 08:53:06 +00:00
|
|
|
|
2012-10-26 13:32:10 +00:00
|
|
|
if (MOZ_UNLIKELY(!fixed || !percent || !relative)) {
|
2006-10-07 08:53:06 +00:00
|
|
|
return; // NS_ERROR_OUT_OF_MEMORY
|
|
|
|
}
|
1998-11-28 18:59:38 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t i, j;
|
2012-12-03 19:47:10 +00:00
|
|
|
|
1998-11-28 18:59:38 +00:00
|
|
|
// initialize the fixed, percent, relative indices, allocate the fixed sizes
|
|
|
|
// and zero the others
|
2012-12-03 19:47:10 +00:00
|
|
|
for (i = 0; i < aNumSpecs; i++) {
|
1998-11-28 18:59:38 +00:00
|
|
|
aValues[i] = 0;
|
1998-07-15 23:42:14 +00:00
|
|
|
switch (aSpecs[i].mUnit) {
|
1998-11-28 18:59:38 +00:00
|
|
|
case eFramesetUnit_Fixed:
|
2007-02-07 07:46:44 +00:00
|
|
|
aValues[i] = nsPresContext::CSSPixelsToAppUnits(aSpecs[i].mValue);
|
1998-11-28 18:59:38 +00:00
|
|
|
fixedTotal += aValues[i];
|
|
|
|
fixed[numFixed] = i;
|
|
|
|
numFixed++;
|
1998-07-15 23:42:14 +00:00
|
|
|
break;
|
|
|
|
case eFramesetUnit_Percent:
|
1998-11-28 18:59:38 +00:00
|
|
|
percent[numPercent] = i;
|
|
|
|
numPercent++;
|
1998-07-15 23:42:14 +00:00
|
|
|
break;
|
1998-11-28 18:59:38 +00:00
|
|
|
case eFramesetUnit_Relative:
|
|
|
|
relative[numRelative] = i;
|
|
|
|
numRelative++;
|
|
|
|
relativeSums += aSpecs[i].mValue;
|
1998-07-15 23:42:14 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-11-28 18:59:38 +00:00
|
|
|
// scale the fixed sizes if they total too much (or too little and there
|
|
|
|
// aren't any percent or relative)
|
2012-12-03 19:47:10 +00:00
|
|
|
if ((fixedTotal > aSize) ||
|
|
|
|
((fixedTotal < aSize) && (0 == numPercent) && (0 == numRelative))) {
|
2015-10-30 19:12:25 +00:00
|
|
|
Scale(aSize, numFixed, fixed.get(), aNumSpecs, aValues);
|
1998-11-28 18:59:38 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t percentMax = aSize - fixedTotal;
|
|
|
|
int32_t percentTotal = 0;
|
1998-11-28 18:59:38 +00: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 00:28:00 +00:00
|
|
|
aValues[j] =
|
|
|
|
NSToCoordRound((float)aSpecs[j].mValue * (float)aSize / 100.0f);
|
1998-11-28 18:59:38 +00:00
|
|
|
percentTotal += aValues[j];
|
1998-07-15 23:42:14 +00:00
|
|
|
}
|
|
|
|
|
1998-11-28 18:59:38 +00:00
|
|
|
// scale the percent sizes if they total too much (or too little and there
|
|
|
|
// aren't any relative)
|
2012-12-03 19:47:10 +00:00
|
|
|
if ((percentTotal > percentMax) ||
|
|
|
|
((percentTotal < percentMax) && (0 == numRelative))) {
|
2015-10-30 19:12:25 +00:00
|
|
|
Scale(percentMax, numPercent, percent.get(), aNumSpecs, aValues);
|
1998-11-28 18:59:38 +00:00
|
|
|
return;
|
1998-07-15 23:42:14 +00:00
|
|
|
}
|
1998-11-28 18:59:38 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t relativeMax = percentMax - percentTotal;
|
|
|
|
int32_t relativeTotal = 0;
|
1998-11-28 18:59:38 +00: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 19:47:10 +00:00
|
|
|
if (relativeTotal != relativeMax) {
|
2015-10-30 19:12:25 +00:00
|
|
|
Scale(relativeMax, numRelative, relative.get(), aNumSpecs, aValues);
|
1998-07-15 23:42:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-06-11 00:51:05 +00: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 19:47:10 +00:00
|
|
|
void nsHTMLFramesetFrame::GenerateRowCol(nsPresContext* aPresContext,
|
|
|
|
nscoord aSize, int32_t aNumSpecs,
|
2002-08-06 01:06:50 +00:00
|
|
|
const nsFramesetSpec* aSpecs,
|
|
|
|
nscoord* aValues, nsString& aNewAttr) {
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t i;
|
2012-12-03 19:47:10 +00:00
|
|
|
|
2002-08-06 01:06:50 +00:00
|
|
|
for (i = 0; i < aNumSpecs; i++) {
|
2014-01-04 15:02:17 +00:00
|
|
|
if (!aNewAttr.IsEmpty()) aNewAttr.Append(char16_t(','));
|
2012-12-03 19:47:10 +00:00
|
|
|
|
1999-06-11 00:51:05 +00:00
|
|
|
switch (aSpecs[i].mUnit) {
|
|
|
|
case eFramesetUnit_Fixed:
|
2007-02-07 07:46:44 +00:00
|
|
|
aNewAttr.AppendInt(nsPresContext::AppUnitsToIntCSSPixels(aValues[i]));
|
1999-06-11 00:51:05 +00:00
|
|
|
break;
|
|
|
|
case eFramesetUnit_Percent: // XXX Only accurate to 1%, need 1 pixel
|
|
|
|
case eFramesetUnit_Relative:
|
2002-08-06 01:06:50 +00:00
|
|
|
// Add 0.5 to the percentage to make rounding work right.
|
2012-12-03 19:47:10 +00:00
|
|
|
aNewAttr.AppendInt(uint32_t((100.0 * aValues[i]) / aSize + 0.5));
|
2014-01-04 15:02:17 +00:00
|
|
|
aNewAttr.Append(char16_t('%'));
|
1999-06-11 00:51:05 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t nsHTMLFramesetFrame::GetBorderWidth(nsPresContext* aPresContext,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aTakeForcingIntoAccount) {
|
2015-07-21 04:18:17 +00:00
|
|
|
nsFrameborder frameborder = GetFrameBorder();
|
|
|
|
if (frameborder == eFrameborder_No) {
|
|
|
|
return 0;
|
2001-11-02 02:19:49 +00:00
|
|
|
}
|
2018-03-21 21:39:04 +00:00
|
|
|
nsGenericHTMLElement* content = nsGenericHTMLElement::FromNode(mContent);
|
2002-05-23 00:00:34 +00:00
|
|
|
|
|
|
|
if (content) {
|
2006-12-26 17:47:52 +00:00
|
|
|
const nsAttrValue* attr = content->GetParsedAttr(nsGkAtoms::border);
|
2005-01-25 00:02:58 +00:00
|
|
|
if (attr) {
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t intVal = 0;
|
2005-01-25 00:02:58 +00:00
|
|
|
if (attr->Type() == nsAttrValue::eInteger) {
|
|
|
|
intVal = attr->GetIntegerValue();
|
|
|
|
if (intVal < 0) {
|
|
|
|
intVal = 0;
|
|
|
|
}
|
1998-09-09 23:30:30 +00:00
|
|
|
}
|
2002-05-23 00:00:34 +00:00
|
|
|
|
2007-02-07 07:46:44 +00:00
|
|
|
return nsPresContext::CSSPixelsToAppUnits(intVal);
|
1998-08-06 19:40:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-21 04:18:17 +00:00
|
|
|
if (mParentBorderWidth >= 0) {
|
1998-08-06 19:40:37 +00:00
|
|
|
return mParentBorderWidth;
|
|
|
|
}
|
|
|
|
|
2007-02-07 07:46:44 +00:00
|
|
|
return nsPresContext::CSSPixelsToAppUnits(DEFAULT_BORDER_WIDTH_PX);
|
1998-07-27 05:59:37 +00:00
|
|
|
}
|
|
|
|
|
2012-12-03 19:47:10 +00:00
|
|
|
void nsHTMLFramesetFrame::GetDesiredSize(nsPresContext* aPresContext,
|
2016-07-21 10:36:39 +00:00
|
|
|
const ReflowInput& aReflowInput,
|
2016-07-21 10:36:38 +00:00
|
|
|
ReflowOutput& aDesiredSize) {
|
2016-07-21 10:36:39 +00:00
|
|
|
WritingMode wm = aReflowInput.GetWritingMode();
|
2014-07-24 08:30:07 +00:00
|
|
|
LogicalSize desiredSize(wm);
|
2012-12-01 02:28:02 +00:00
|
|
|
nsHTMLFramesetFrame* framesetParent = do_QueryFrame(GetParent());
|
2012-07-30 14:20:58 +00:00
|
|
|
if (nullptr == framesetParent) {
|
2006-11-24 08:12:17 +00:00
|
|
|
if (aPresContext->IsPaginated()) {
|
|
|
|
// XXX This needs to be changed when framesets paginate properly
|
2016-07-21 10:36:39 +00:00
|
|
|
desiredSize.ISize(wm) = aReflowInput.AvailableISize();
|
|
|
|
desiredSize.BSize(wm) = aReflowInput.AvailableBSize();
|
2006-11-24 08:12:17 +00:00
|
|
|
} else {
|
2014-07-24 08:30:07 +00:00
|
|
|
LogicalSize area(wm, aPresContext->GetVisibleArea().Size());
|
1998-07-15 23:42:14 +00:00
|
|
|
|
2014-07-24 08:30:07 +00:00
|
|
|
desiredSize.ISize(wm) = area.ISize(wm);
|
|
|
|
desiredSize.BSize(wm) = area.BSize(wm);
|
2006-11-24 08:12:17 +00:00
|
|
|
}
|
1998-07-15 23:42:14 +00:00
|
|
|
} else {
|
2014-07-24 08:30:07 +00:00
|
|
|
LogicalSize size(wm);
|
|
|
|
framesetParent->GetSizeOfChild(this, wm, size);
|
|
|
|
desiredSize.ISize(wm) = size.ISize(wm);
|
|
|
|
desiredSize.BSize(wm) = size.BSize(wm);
|
2012-12-03 19:47:10 +00:00
|
|
|
}
|
2014-07-24 08:30:07 +00:00
|
|
|
aDesiredSize.SetSize(wm, desiredSize);
|
1998-07-15 23:42:14 +00:00
|
|
|
}
|
|
|
|
|
1998-07-27 05:59:37 +00:00
|
|
|
// only valid for non border children
|
2012-12-03 19:47:10 +00:00
|
|
|
void nsHTMLFramesetFrame::GetSizeOfChildAt(int32_t aIndexInParent,
|
2014-07-24 08:30:07 +00:00
|
|
|
WritingMode aWM, LogicalSize& aSize,
|
2009-01-15 03:27:09 +00:00
|
|
|
nsIntPoint& aCellIndex) {
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t row = aIndexInParent / mNumCols;
|
|
|
|
int32_t col = aIndexInParent -
|
|
|
|
(row * mNumCols); // remainder from dividing index by mNumCols
|
1998-07-20 18:52:40 +00:00
|
|
|
if ((row < mNumRows) && (col < mNumCols)) {
|
2014-07-24 08:30:07 +00:00
|
|
|
aSize.ISize(aWM) = mColSizes[col];
|
|
|
|
aSize.BSize(aWM) = mRowSizes[row];
|
1998-07-20 18:52:40 +00:00
|
|
|
aCellIndex.x = col;
|
|
|
|
aCellIndex.y = row;
|
|
|
|
} else {
|
2014-07-24 08:30:07 +00:00
|
|
|
aSize.SizeTo(aWM, 0, 0);
|
2009-01-15 03:27:09 +00:00
|
|
|
aCellIndex.x = aCellIndex.y = 0;
|
1998-07-20 18:52:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-07-27 05:59:37 +00:00
|
|
|
// only valid for non border children
|
2012-12-03 19:47:10 +00:00
|
|
|
void nsHTMLFramesetFrame::GetSizeOfChild(nsIFrame* aChild, WritingMode aWM,
|
2014-07-24 08:30:07 +00:00
|
|
|
LogicalSize& aSize) {
|
1998-07-20 18:52:40 +00:00
|
|
|
// Reflow only creates children frames for <frameset> and <frame> content.
|
|
|
|
// this assumption is used here
|
1998-07-15 23:42:14 +00:00
|
|
|
int i = 0;
|
2015-06-29 20:02:21 +00:00
|
|
|
for (nsIFrame* child : mFrames) {
|
1998-07-15 23:42:14 +00:00
|
|
|
if (aChild == child) {
|
2009-01-15 03:27:09 +00:00
|
|
|
nsIntPoint ignore;
|
2014-07-24 08:30:07 +00:00
|
|
|
GetSizeOfChildAt(i, aWM, aSize, ignore);
|
1998-07-27 05:59:37 +00:00
|
|
|
return;
|
1998-07-15 23:42:14 +00:00
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
2014-07-24 08:30:07 +00:00
|
|
|
aSize.SizeTo(aWM, 0, 0);
|
2012-12-03 19:47:10 +00:00
|
|
|
}
|
1998-07-15 23:42:14 +00:00
|
|
|
|
2014-02-18 07:47:48 +00:00
|
|
|
nsresult nsHTMLFramesetFrame::HandleEvent(nsPresContext* aPresContext,
|
2013-10-02 03:46:03 +00:00
|
|
|
WidgetGUIEvent* aEvent,
|
2012-12-03 19:47:10 +00:00
|
|
|
nsEventStatus* aEventStatus) {
|
1999-11-24 06:03:41 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(aEventStatus);
|
1998-11-25 18:11:26 +00:00
|
|
|
if (mDragger) {
|
|
|
|
// the nsFramesetBorderFrame has captured NS_MOUSE_DOWN
|
2015-08-22 01:34:51 +00:00
|
|
|
switch (aEvent->mMessage) {
|
2015-08-28 23:58:29 +00:00
|
|
|
case eMouseMove:
|
1998-11-25 18:11:26 +00:00
|
|
|
MouseDrag(aPresContext, aEvent);
|
2016-07-08 07:07:06 +00:00
|
|
|
break;
|
2015-08-28 23:58:30 +00:00
|
|
|
case eMouseUp:
|
2019-04-21 20:13:34 +00:00
|
|
|
if (aEvent->AsMouseEvent()->mButton == MouseButton::eLeft) {
|
2006-11-16 21:35:39 +00:00
|
|
|
EndMouseDrag(aPresContext);
|
|
|
|
}
|
2016-07-08 07:07:06 +00:00
|
|
|
break;
|
2015-08-26 12:56:59 +00:00
|
|
|
default:
|
|
|
|
break;
|
1998-11-25 18:11:26 +00:00
|
|
|
}
|
1999-11-24 06:03:41 +00:00
|
|
|
*aEventStatus = nsEventStatus_eConsumeNoDefault;
|
1998-11-25 18:11:26 +00:00
|
|
|
} else {
|
1999-11-24 06:03:41 +00:00
|
|
|
*aEventStatus = nsEventStatus_eIgnore;
|
1998-11-18 05:25:26 +00:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2019-03-13 18:38:09 +00:00
|
|
|
Maybe<nsIFrame::Cursor> nsHTMLFramesetFrame::GetCursor(const nsPoint&) {
|
|
|
|
auto kind = StyleCursorKind::Default;
|
1999-03-10 06:13:35 +00:00
|
|
|
if (mDragger) {
|
2019-03-13 18:38:09 +00:00
|
|
|
kind = mDragger->mVertical ? StyleCursorKind::EwResize
|
|
|
|
: StyleCursorKind::NsResize;
|
1999-03-10 06:13:35 +00:00
|
|
|
}
|
2019-03-13 18:38:09 +00:00
|
|
|
return Some(Cursor{kind, AllowCustomCursorImage::No});
|
1999-03-10 06:13:35 +00:00
|
|
|
}
|
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
void nsHTMLFramesetFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayListSet& aLists) {
|
2017-08-07 02:23:35 +00:00
|
|
|
BuildDisplayListForInline(aBuilder, aLists);
|
2012-12-03 19:47:10 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
if (mDragger && aBuilder->IsForEventDelivery()) {
|
2019-04-01 16:53:11 +00:00
|
|
|
aLists.Content()->AppendNewToTop<nsDisplayEventReceiver>(aBuilder, this);
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
1998-07-15 23:42:14 +00:00
|
|
|
}
|
|
|
|
|
1998-10-02 04:10:00 +00:00
|
|
|
void nsHTMLFramesetFrame::ReflowPlaceChild(nsIFrame* aChild,
|
2012-12-03 19:47:10 +00:00
|
|
|
nsPresContext* aPresContext,
|
2016-07-21 10:36:39 +00:00
|
|
|
const ReflowInput& aReflowInput,
|
1998-10-02 04:10:00 +00:00
|
|
|
nsPoint& aOffset, nsSize& aSize,
|
2009-01-15 03:27:09 +00:00
|
|
|
nsIntPoint* aCellIndex) {
|
2000-03-24 04:42:40 +00:00
|
|
|
// reflow the child
|
2016-07-21 10:36:39 +00:00
|
|
|
ReflowInput reflowInput(aPresContext, aReflowInput, aChild,
|
2014-07-24 08:28:46 +00:00
|
|
|
LogicalSize(aChild->GetWritingMode(), aSize));
|
2016-07-21 10:36:39 +00:00
|
|
|
reflowInput.SetComputedWidth(std::max(
|
|
|
|
0,
|
|
|
|
aSize.width - reflowInput.ComputedPhysicalBorderPadding().LeftRight()));
|
|
|
|
reflowInput.SetComputedHeight(std::max(
|
|
|
|
0,
|
|
|
|
aSize.height - reflowInput.ComputedPhysicalBorderPadding().TopBottom()));
|
2016-07-26 09:10:52 +00:00
|
|
|
ReflowOutput reflowOutput(aReflowInput);
|
|
|
|
reflowOutput.Width() = aSize.width;
|
|
|
|
reflowOutput.Height() = aSize.height;
|
1999-10-30 02:52:11 +00:00
|
|
|
nsReflowStatus status;
|
2012-12-03 19:47:10 +00:00
|
|
|
|
2016-07-26 09:10:52 +00:00
|
|
|
ReflowChild(aChild, aPresContext, reflowOutput, reflowInput, aOffset.x,
|
1999-11-19 15:33:29 +00:00
|
|
|
aOffset.y, 0, status);
|
2017-02-11 14:45:07 +00:00
|
|
|
NS_ASSERTION(status.IsComplete(), "bad status");
|
2012-12-03 19:47:10 +00:00
|
|
|
|
1999-10-30 02:52:11 +00:00
|
|
|
// Place and size the child
|
2016-07-26 09:10:52 +00:00
|
|
|
reflowOutput.Width() = aSize.width;
|
|
|
|
reflowOutput.Height() = aSize.height;
|
|
|
|
FinishReflowChild(aChild, aPresContext, reflowOutput, nullptr, aOffset.x,
|
|
|
|
aOffset.y, 0);
|
1998-07-27 05:59:37 +00:00
|
|
|
}
|
|
|
|
|
2005-01-12 19:45:38 +00:00
|
|
|
static nsFrameborder GetFrameBorderHelper(nsGenericHTMLElement* aContent) {
|
2012-07-30 14:20:58 +00:00
|
|
|
if (nullptr != aContent) {
|
2006-12-26 17:47:52 +00:00
|
|
|
const nsAttrValue* attr = aContent->GetParsedAttr(nsGkAtoms::frameborder);
|
2005-01-25 00:02:58 +00: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 19:40:37 +00:00
|
|
|
}
|
|
|
|
}
|
1998-09-09 23:30:30 +00:00
|
|
|
return eFrameborder_Notset;
|
1998-08-06 19:40:37 +00:00
|
|
|
}
|
|
|
|
|
2012-12-03 19:47:10 +00:00
|
|
|
nsFrameborder nsHTMLFramesetFrame::GetFrameBorder() {
|
1998-09-09 23:30:30 +00:00
|
|
|
nsFrameborder result = eFrameborder_Notset;
|
2018-03-21 21:39:04 +00:00
|
|
|
nsGenericHTMLElement* content = nsGenericHTMLElement::FromNode(mContent);
|
2002-05-23 00:00:34 +00:00
|
|
|
|
2001-12-07 19:40:07 +00:00
|
|
|
if (content) {
|
|
|
|
result = GetFrameBorderHelper(content);
|
1998-09-09 23:30:30 +00:00
|
|
|
}
|
|
|
|
if (eFrameborder_Notset == result) {
|
|
|
|
return mParentFrameborder;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2001-12-07 19:40:07 +00:00
|
|
|
nsFrameborder nsHTMLFramesetFrame::GetFrameBorder(nsIContent* aContent) {
|
1998-09-09 23:30:30 +00:00
|
|
|
nsFrameborder result = eFrameborder_Notset;
|
2002-05-23 00:00:34 +00:00
|
|
|
|
2018-03-21 21:39:04 +00:00
|
|
|
nsGenericHTMLElement* content = nsGenericHTMLElement::FromNode(aContent);
|
2002-05-23 00:00:34 +00:00
|
|
|
|
|
|
|
if (content) {
|
2001-12-07 19:40:07 +00:00
|
|
|
result = GetFrameBorderHelper(content);
|
1998-09-09 23:30:30 +00:00
|
|
|
}
|
|
|
|
if (eFrameborder_Notset == result) {
|
2001-12-07 19:40:07 +00:00
|
|
|
return GetFrameBorder();
|
1998-07-30 21:25:35 +00:00
|
|
|
}
|
1998-09-09 23:30:30 +00:00
|
|
|
return result;
|
1998-07-30 21:25:35 +00:00
|
|
|
}
|
1998-07-27 05:59:37 +00:00
|
|
|
|
2012-12-03 19:47:10 +00:00
|
|
|
nscolor nsHTMLFramesetFrame::GetBorderColor() {
|
2018-03-21 21:39:04 +00:00
|
|
|
nsGenericHTMLElement* content = nsGenericHTMLElement::FromNode(mContent);
|
2002-05-23 00:00:34 +00:00
|
|
|
|
|
|
|
if (content) {
|
2006-12-26 17:47:52 +00:00
|
|
|
const nsAttrValue* attr = content->GetParsedAttr(nsGkAtoms::bordercolor);
|
2005-01-25 00:02:58 +00:00
|
|
|
if (attr) {
|
2004-02-11 00:38:12 +00:00
|
|
|
nscolor color;
|
2005-01-25 00:02:58 +00:00
|
|
|
if (attr->GetColorValue(color)) {
|
2004-02-11 00:38:12 +00:00
|
|
|
return color;
|
1998-09-09 23:30:30 +00:00
|
|
|
}
|
1998-09-03 01:16:27 +00:00
|
|
|
}
|
|
|
|
}
|
2004-02-11 00:38:12 +00:00
|
|
|
|
|
|
|
return mParentBorderColor;
|
1998-09-03 01:16:27 +00:00
|
|
|
}
|
|
|
|
|
2012-12-03 19:47:10 +00:00
|
|
|
nscolor nsHTMLFramesetFrame::GetBorderColor(nsIContent* aContent) {
|
2018-03-21 21:39:04 +00:00
|
|
|
nsGenericHTMLElement* content = nsGenericHTMLElement::FromNode(aContent);
|
2002-05-23 00:00:34 +00:00
|
|
|
|
|
|
|
if (content) {
|
2006-12-26 17:47:52 +00:00
|
|
|
const nsAttrValue* attr = content->GetParsedAttr(nsGkAtoms::bordercolor);
|
2005-01-25 00:02:58 +00:00
|
|
|
if (attr) {
|
2004-02-11 00:38:12 +00:00
|
|
|
nscolor color;
|
2005-01-25 00:02:58 +00:00
|
|
|
if (attr->GetColorValue(color)) {
|
2004-02-11 00:38:12 +00:00
|
|
|
return color;
|
1998-09-09 23:30:30 +00:00
|
|
|
}
|
1998-09-03 01:16:27 +00:00
|
|
|
}
|
1998-09-09 23:30:30 +00:00
|
|
|
}
|
2004-02-11 00:38:12 +00:00
|
|
|
return GetBorderColor();
|
1998-09-03 01:16:27 +00:00
|
|
|
}
|
|
|
|
|
2012-12-03 19:47:10 +00:00
|
|
|
void nsHTMLFramesetFrame::Reflow(nsPresContext* aPresContext,
|
2016-07-21 10:36:38 +00:00
|
|
|
ReflowOutput& aDesiredSize,
|
2016-07-21 10:36:39 +00:00
|
|
|
const ReflowInput& aReflowInput,
|
1998-10-02 04:10:00 +00:00
|
|
|
nsReflowStatus& aStatus) {
|
2015-03-29 22:38:40 +00: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 05:38:33 +00:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsHTMLFramesetFrame");
|
2016-07-21 10:36:39 +00:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowInput, aDesiredSize, aStatus);
|
2017-09-13 10:00:25 +00:00
|
|
|
MOZ_ASSERT(aStatus.IsEmpty(), "Caller should pass a fresh reflow status!");
|
|
|
|
|
2019-04-03 12:40:26 +00:00
|
|
|
mozilla::PresShell* presShell = aPresContext->PresShell();
|
|
|
|
ServoStyleSet* styleSet = presShell->StyleSet();
|
2003-12-21 05:36:36 +00:00
|
|
|
|
2015-06-18 06:33:50 +00:00
|
|
|
GetParent()->AddStateBits(NS_FRAME_CONTAINS_RELATIVE_BSIZE);
|
2012-12-03 19:47:10 +00:00
|
|
|
|
2018-11-27 22:08:11 +00:00
|
|
|
// printf("FramesetFrame2::Reflow %X (%d,%d) \n", this,
|
|
|
|
// aReflowInput.AvailableWidth(), aReflowInput.AvailableHeight());
|
1998-07-15 23:42:14 +00:00
|
|
|
// Always get the size so that the caller knows how big we are
|
2016-07-21 10:36:39 +00:00
|
|
|
GetDesiredSize(aPresContext, aReflowInput, aDesiredSize);
|
2012-12-03 19:47:10 +00:00
|
|
|
|
2016-07-21 10:36:39 +00:00
|
|
|
nscoord width = (aDesiredSize.Width() <= aReflowInput.AvailableWidth())
|
|
|
|
? aDesiredSize.Width()
|
|
|
|
: aReflowInput.AvailableWidth();
|
|
|
|
nscoord height = (aDesiredSize.Height() <= aReflowInput.AvailableHeight())
|
|
|
|
? aDesiredSize.Height()
|
|
|
|
: aReflowInput.AvailableHeight();
|
2001-11-02 02:19:49 +00:00
|
|
|
|
2015-11-10 05:42:29 +00: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 19:47:10 +00:00
|
|
|
|
1998-07-27 05:59:37 +00: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 15:56:38 +00:00
|
|
|
int32_t borderWidth = GetBorderWidth(aPresContext, true);
|
2000-09-21 05:07:06 +00:00
|
|
|
|
1998-07-27 05:59:37 +00:00
|
|
|
width -= (mNumCols - 1) * borderWidth;
|
2000-09-21 05:07:06 +00:00
|
|
|
if (width < 0) width = 0;
|
|
|
|
|
1998-07-27 05:59:37 +00:00
|
|
|
height -= (mNumRows - 1) * borderWidth;
|
2000-09-21 05:07:06 +00:00
|
|
|
if (height < 0) height = 0;
|
1998-07-15 23:42:14 +00:00
|
|
|
|
2018-03-21 21:39:04 +00:00
|
|
|
HTMLFrameSetElement* ourContent = HTMLFrameSetElement::FromNode(mContent);
|
2007-03-22 23:57:55 +00:00
|
|
|
NS_ASSERTION(ourContent, "Someone gave us a broken frameset element!");
|
2012-07-30 14:20:58 +00:00
|
|
|
const nsFramesetSpec* rowSpecs = nullptr;
|
|
|
|
const nsFramesetSpec* colSpecs = nullptr;
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t rows = 0;
|
|
|
|
int32_t cols = 0;
|
2007-03-22 23:57:55 +00: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 19:08:21 +00:00
|
|
|
if (mNumRows != rows || mNumCols != cols) {
|
|
|
|
mDrag.UnSet();
|
2016-07-21 10:36:39 +00:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aDesiredSize);
|
2014-05-13 00:47:52 +00:00
|
|
|
return;
|
2007-04-10 19:08:21 +00:00
|
|
|
}
|
2007-03-22 23:57:55 +00:00
|
|
|
|
2015-10-29 20:16:13 +00:00
|
|
|
CalculateRowCol(aPresContext, width, mNumCols, colSpecs, mColSizes.get());
|
|
|
|
CalculateRowCol(aPresContext, height, mNumRows, rowSpecs, mRowSizes.get());
|
1998-07-20 18:52:40 +00:00
|
|
|
|
2015-10-30 19:12:25 +00:00
|
|
|
UniquePtr<bool[]> verBordersVis; // vertical borders visibility
|
|
|
|
UniquePtr<nscolor[]> verBorderColors;
|
|
|
|
UniquePtr<bool[]> horBordersVis; // horizontal borders visibility
|
|
|
|
UniquePtr<nscolor[]> horBorderColors;
|
2006-10-07 08:53:06 +00:00
|
|
|
nscolor borderColor = GetBorderColor();
|
|
|
|
nsFrameborder frameborder = GetFrameBorder();
|
2001-04-11 07:56:13 +00:00
|
|
|
|
1998-07-30 21:25:35 +00:00
|
|
|
if (firstTime) {
|
2011-01-25 01:38:07 +00: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 15:24:54 +00: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 01:38:07 +00:00
|
|
|
|
2015-10-30 19:12:25 +00:00
|
|
|
verBordersVis = MakeUnique<bool[]>(mNumCols);
|
|
|
|
verBorderColors = MakeUnique<nscolor[]>(mNumCols);
|
1998-07-30 21:25:35 +00:00
|
|
|
for (int verX = 0; verX < mNumCols; verX++) {
|
2011-10-17 14:59:28 +00:00
|
|
|
verBordersVis[verX] = false;
|
1998-09-03 01:16:27 +00:00
|
|
|
verBorderColors[verX] = NO_COLOR;
|
1998-07-30 21:25:35 +00:00
|
|
|
}
|
2001-10-07 00:19:01 +00:00
|
|
|
|
2015-10-30 19:12:25 +00:00
|
|
|
horBordersVis = MakeUnique<bool[]>(mNumRows);
|
|
|
|
horBorderColors = MakeUnique<nscolor[]>(mNumRows);
|
1998-07-30 21:25:35 +00:00
|
|
|
for (int horX = 0; horX < mNumRows; horX++) {
|
2011-10-17 14:59:28 +00:00
|
|
|
horBordersVis[horX] = false;
|
1998-09-03 01:16:27 +00:00
|
|
|
horBorderColors[horX] = NO_COLOR;
|
1998-07-30 21:25:35 +00:00
|
|
|
}
|
1998-07-20 18:52:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// reflow the children
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t lastRow = 0;
|
|
|
|
int32_t lastCol = 0;
|
|
|
|
int32_t borderChildX = mNonBorderChildCount; // index of border children
|
2012-07-30 14:20:58 +00:00
|
|
|
nsHTMLFramesetBorderFrame* borderFrame = nullptr;
|
1998-07-20 18:52:40 +00:00
|
|
|
nsPoint offset(0, 0);
|
1998-07-27 05:59:37 +00:00
|
|
|
nsSize size, lastSize;
|
2014-07-24 08:30:07 +00:00
|
|
|
WritingMode wm = GetWritingMode();
|
|
|
|
LogicalSize logicalSize(wm);
|
1999-01-15 22:53:39 +00:00
|
|
|
nsIFrame* child = mFrames.FirstChild();
|
1998-07-30 21:25:35 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
for (int32_t childX = 0; childX < mNonBorderChildCount; childX++) {
|
2009-01-15 03:27:09 +00:00
|
|
|
nsIntPoint cellIndex;
|
2014-07-24 08:30:07 +00:00
|
|
|
GetSizeOfChildAt(childX, wm, logicalSize, cellIndex);
|
|
|
|
size = logicalSize.GetPhysicalSize(wm);
|
1998-07-20 18:52:40 +00:00
|
|
|
|
|
|
|
if (lastRow != cellIndex.y) { // changed to next row
|
|
|
|
offset.x = 0;
|
1998-07-27 05:59:37 +00:00
|
|
|
offset.y += lastSize.height;
|
2001-11-02 02:19:49 +00:00
|
|
|
if (firstTime) { // create horizontal border
|
2006-03-26 21:30:36 +00:00
|
|
|
|
2018-03-22 18:20:41 +00:00
|
|
|
RefPtr<ComputedStyle> pseudoComputedStyle;
|
2018-08-15 05:46:39 +00:00
|
|
|
pseudoComputedStyle = styleSet->ResolveNonInheritingAnonymousBoxStyle(
|
2019-02-19 13:44:33 +00:00
|
|
|
PseudoStyleType::horizontalFramesetBorder);
|
2006-03-26 21:30:36 +00:00
|
|
|
|
2019-04-03 12:40:26 +00:00
|
|
|
borderFrame = new (presShell) nsHTMLFramesetBorderFrame(
|
2019-02-05 16:45:54 +00:00
|
|
|
pseudoComputedStyle, PresContext(), borderWidth, false, false);
|
2013-08-03 04:11:06 +00: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 02:19:49 +00:00
|
|
|
} else {
|
|
|
|
borderFrame = (nsHTMLFramesetBorderFrame*)mFrames.FrameAt(borderChildX);
|
2013-08-03 04:11:06 +00:00
|
|
|
borderFrame->mWidth = borderWidth;
|
|
|
|
borderChildX++;
|
1998-08-06 19:40:37 +00:00
|
|
|
}
|
2013-12-27 17:59:52 +00:00
|
|
|
nsSize borderSize(aDesiredSize.Width(), borderWidth);
|
2016-07-21 10:36:39 +00:00
|
|
|
ReflowPlaceChild(borderFrame, aPresContext, aReflowInput, offset,
|
|
|
|
borderSize);
|
2013-08-03 04:11:06 +00:00
|
|
|
borderFrame = nullptr;
|
2001-11-02 02:19:49 +00:00
|
|
|
offset.y += borderWidth;
|
1998-07-27 05:59:37 +00:00
|
|
|
} else {
|
2001-11-02 02:19:49 +00:00
|
|
|
if (cellIndex.x > 0) { // moved to next col in same row
|
1998-07-27 05:59:37 +00:00
|
|
|
if (0 == cellIndex.y) { // in 1st row
|
|
|
|
if (firstTime) { // create vertical border
|
2012-12-03 19:47:10 +00:00
|
|
|
|
2018-03-22 18:20:41 +00:00
|
|
|
RefPtr<ComputedStyle> pseudoComputedStyle;
|
|
|
|
pseudoComputedStyle =
|
2018-08-15 05:46:39 +00:00
|
|
|
styleSet->ResolveNonInheritingAnonymousBoxStyle(
|
2019-02-19 13:44:33 +00:00
|
|
|
PseudoStyleType::verticalFramesetBorder);
|
2006-03-26 21:30:36 +00:00
|
|
|
|
2019-04-03 12:40:26 +00:00
|
|
|
borderFrame = new (presShell) nsHTMLFramesetBorderFrame(
|
2019-02-05 16:45:54 +00:00
|
|
|
pseudoComputedStyle, PresContext(), borderWidth, true, false);
|
2013-08-03 04:11:06 +00: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 19:47:10 +00:00
|
|
|
} else {
|
1999-01-15 22:53:39 +00:00
|
|
|
borderFrame =
|
|
|
|
(nsHTMLFramesetBorderFrame*)mFrames.FrameAt(borderChildX);
|
2013-08-03 04:11:06 +00:00
|
|
|
borderFrame->mWidth = borderWidth;
|
|
|
|
borderChildX++;
|
1998-07-27 05:59:37 +00:00
|
|
|
}
|
2013-12-27 17:59:52 +00:00
|
|
|
nsSize borderSize(borderWidth, aDesiredSize.Height());
|
2016-07-21 10:36:39 +00:00
|
|
|
ReflowPlaceChild(borderFrame, aPresContext, aReflowInput, offset,
|
|
|
|
borderSize);
|
2013-08-03 04:11:06 +00:00
|
|
|
borderFrame = nullptr;
|
1998-07-27 05:59:37 +00:00
|
|
|
}
|
|
|
|
offset.x += borderWidth;
|
|
|
|
}
|
1998-07-20 18:52:40 +00:00
|
|
|
}
|
1998-07-27 05:59:37 +00:00
|
|
|
|
2016-07-21 10:36:39 +00:00
|
|
|
ReflowPlaceChild(child, aPresContext, aReflowInput, offset, size,
|
|
|
|
&cellIndex);
|
1998-07-27 05:59:37 +00:00
|
|
|
|
1998-07-30 21:25:35 +00:00
|
|
|
if (firstTime) {
|
2012-12-01 02:28:02 +00: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 00:19:01 +00:00
|
|
|
if (eFrameborder_Yes == mChildFrameborder[childX]) {
|
1998-09-03 01:16:27 +00:00
|
|
|
childVis = ALL_VIS;
|
2001-10-07 00:19:01 +00:00
|
|
|
} else if (eFrameborder_No == mChildFrameborder[childX]) {
|
1998-09-03 01:16:27 +00:00
|
|
|
childVis = NONE_VIS;
|
1998-08-06 19:40:37 +00:00
|
|
|
} else { // notset
|
1998-09-03 01:16:27 +00:00
|
|
|
childVis = (eFrameborder_No == frameborder) ? NONE_VIS : ALL_VIS;
|
1998-08-06 19:40:37 +00:00
|
|
|
}
|
2012-12-03 19:47:10 +00:00
|
|
|
} else { // blank
|
2016-07-19 18:28:54 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
nsHTMLFramesetBlankFrame* blank = do_QueryFrame(child);
|
|
|
|
MOZ_ASSERT(blank, "unexpected child frame type");
|
|
|
|
#endif
|
1998-09-03 01:16:27 +00:00
|
|
|
childVis = NONE_VIS;
|
1998-07-30 21:25:35 +00:00
|
|
|
}
|
2001-10-07 00:19:01 +00:00
|
|
|
nsBorderColor childColors = mChildBorderColors[childX];
|
1998-09-03 01:16:27 +00: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-30 21:25:35 +00:00
|
|
|
}
|
1998-09-03 01:16:27 +00:00
|
|
|
if (0 == cellIndex.y) {
|
|
|
|
if (!(mEdgeVisibility & TOP_VIS)) {
|
|
|
|
mEdgeVisibility |= (TOP_VIS & childVis);
|
|
|
|
}
|
|
|
|
if (NO_COLOR == mEdgeColors.mTop) {
|
|
|
|
mEdgeColors.mTop = childColors.mTop;
|
|
|
|
}
|
1998-07-30 21:25:35 +00:00
|
|
|
}
|
1998-09-03 01:16:27 +00: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-30 21:25:35 +00:00
|
|
|
}
|
1998-09-03 01:16:27 +00: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-30 21:25:35 +00:00
|
|
|
}
|
|
|
|
// set the visibility of borders that the child may affect
|
1998-09-03 01:16:27 +00:00
|
|
|
if (childVis & RIGHT_VIS) {
|
2011-10-17 14:59:28 +00:00
|
|
|
verBordersVis[cellIndex.x] = true;
|
1998-07-30 21:25:35 +00:00
|
|
|
}
|
1998-09-03 01:16:27 +00:00
|
|
|
if (childVis & BOTTOM_VIS) {
|
2011-10-17 14:59:28 +00:00
|
|
|
horBordersVis[cellIndex.y] = true;
|
1998-07-30 21:25:35 +00:00
|
|
|
}
|
1998-09-03 01:16:27 +00:00
|
|
|
if ((cellIndex.x > 0) && (childVis & LEFT_VIS)) {
|
2011-10-17 14:59:28 +00:00
|
|
|
verBordersVis[cellIndex.x - 1] = true;
|
1998-07-30 21:25:35 +00:00
|
|
|
}
|
1998-09-03 01:16:27 +00:00
|
|
|
if ((cellIndex.y > 0) && (childVis & TOP_VIS)) {
|
2011-10-17 14:59:28 +00:00
|
|
|
horBordersVis[cellIndex.y - 1] = true;
|
1998-07-30 21:25:35 +00:00
|
|
|
}
|
1998-09-03 01:16:27 +00:00
|
|
|
// set the colors of borders that the child may affect
|
|
|
|
if (NO_COLOR == verBorderColors[cellIndex.x]) {
|
2001-10-07 00:19:01 +00:00
|
|
|
verBorderColors[cellIndex.x] = mChildBorderColors[childX].mRight;
|
1998-09-03 01:16:27 +00:00
|
|
|
}
|
|
|
|
if (NO_COLOR == horBorderColors[cellIndex.y]) {
|
2001-10-07 00:19:01 +00:00
|
|
|
horBorderColors[cellIndex.y] = mChildBorderColors[childX].mBottom;
|
1998-09-03 01:16:27 +00:00
|
|
|
}
|
|
|
|
if ((cellIndex.x > 0) && (NO_COLOR == verBorderColors[cellIndex.x - 1])) {
|
2001-10-07 00:19:01 +00:00
|
|
|
verBorderColors[cellIndex.x - 1] = mChildBorderColors[childX].mLeft;
|
1998-09-03 01:16:27 +00:00
|
|
|
}
|
|
|
|
if ((cellIndex.y > 0) && (NO_COLOR == horBorderColors[cellIndex.y - 1])) {
|
2001-10-07 00:19:01 +00:00
|
|
|
horBorderColors[cellIndex.y - 1] = mChildBorderColors[childX].mTop;
|
1998-09-03 01:16:27 +00:00
|
|
|
}
|
1998-07-30 21:25:35 +00:00
|
|
|
}
|
1998-07-27 05:59:37 +00:00
|
|
|
lastRow = cellIndex.y;
|
1998-09-03 01:16:27 +00:00
|
|
|
lastCol = cellIndex.x;
|
1998-07-27 05:59:37 +00:00
|
|
|
lastSize = size;
|
|
|
|
offset.x += size.width;
|
2003-07-05 15:30:50 +00:00
|
|
|
child = child->GetNextSibling();
|
1998-07-20 18:52:40 +00:00
|
|
|
}
|
|
|
|
|
1998-07-30 21:25:35 +00:00
|
|
|
if (firstTime) {
|
1998-09-03 01:16:27 +00:00
|
|
|
nscolor childColor;
|
|
|
|
// set the visibility, color, mouse sensitivity of borders
|
1998-07-30 21:25:35 +00:00
|
|
|
for (int verX = 0; verX < mNumCols - 1; verX++) {
|
2001-04-12 08:16:54 +00:00
|
|
|
if (mVerBorders[verX]) {
|
|
|
|
mVerBorders[verX]->SetVisibility(verBordersVis[verX]);
|
2015-07-21 04:18:17 +00:00
|
|
|
SetBorderResize(mVerBorders[verX]);
|
1998-09-03 01:16:27 +00:00
|
|
|
childColor = (NO_COLOR == verBorderColors[verX])
|
|
|
|
? borderColor
|
|
|
|
: verBorderColors[verX];
|
2001-04-12 08:16:54 +00:00
|
|
|
mVerBorders[verX]->SetColor(childColor);
|
1998-07-31 17:47:50 +00:00
|
|
|
}
|
1998-07-30 21:25:35 +00:00
|
|
|
}
|
|
|
|
for (int horX = 0; horX < mNumRows - 1; horX++) {
|
2001-04-12 08:16:54 +00:00
|
|
|
if (mHorBorders[horX]) {
|
|
|
|
mHorBorders[horX]->SetVisibility(horBordersVis[horX]);
|
2015-07-21 04:18:17 +00:00
|
|
|
SetBorderResize(mHorBorders[horX]);
|
2012-12-03 19:47:10 +00:00
|
|
|
childColor = (NO_COLOR == horBorderColors[horX])
|
|
|
|
? borderColor
|
|
|
|
: horBorderColors[horX];
|
2001-04-12 08:16:54 +00:00
|
|
|
mHorBorders[horX]->SetColor(childColor);
|
1998-07-31 17:47:50 +00:00
|
|
|
}
|
1998-07-30 21:25:35 +00:00
|
|
|
}
|
|
|
|
|
2015-10-29 20:16:13 +00:00
|
|
|
mChildFrameborder.reset();
|
|
|
|
mChildBorderColors.reset();
|
1998-07-30 21:25:35 +00:00
|
|
|
}
|
|
|
|
|
1999-03-10 06:13:35 +00:00
|
|
|
mDrag.UnSet();
|
2002-05-28 22:50:43 +00:00
|
|
|
|
2010-10-07 04:25:46 +00:00
|
|
|
aDesiredSize.SetOverflowAreasToDesiredBounds();
|
2014-03-03 08:54:39 +00:00
|
|
|
FinishAndStoreOverflow(&aDesiredSize);
|
2007-06-27 16:37:50 +00:00
|
|
|
|
2016-07-21 10:36:39 +00:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aDesiredSize);
|
1998-07-15 23:42:14 +00:00
|
|
|
}
|
|
|
|
|
2014-01-05 23:31:14 +00:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
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 05:38:33 +00:00
|
|
|
nsresult nsHTMLFramesetFrame::GetFrameName(nsAString& aResult) const {
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("Frameset"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-12-03 19:47:10 +00:00
|
|
|
bool nsHTMLFramesetFrame::CanResize(bool aVertical, bool aLeft) {
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t childX;
|
|
|
|
int32_t startX;
|
1998-09-03 01:16:27 +00:00
|
|
|
if (aVertical) {
|
|
|
|
startX = (aLeft) ? 0 : mNumCols - 1;
|
|
|
|
for (childX = startX; childX < mNonBorderChildCount; childX += mNumCols) {
|
2012-12-01 02:28:02 +00:00
|
|
|
if (!CanChildResize(aVertical, aLeft, childX)) {
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
1998-09-03 01:16:27 +00:00
|
|
|
}
|
2012-12-03 19:47:10 +00:00
|
|
|
}
|
1998-09-03 01:16:27 +00:00
|
|
|
} else {
|
|
|
|
startX = (aLeft) ? 0 : (mNumRows - 1) * mNumCols;
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t endX = startX + mNumCols;
|
1998-09-03 01:16:27 +00:00
|
|
|
for (childX = startX; childX < endX; childX++) {
|
2012-12-01 02:28:02 +00:00
|
|
|
if (!CanChildResize(aVertical, aLeft, childX)) {
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
1998-09-03 01:16:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
1998-09-03 01:16:27 +00:00
|
|
|
}
|
|
|
|
|
2012-12-03 19:47:10 +00:00
|
|
|
bool nsHTMLFramesetFrame::GetNoResize(nsIFrame* aChildFrame) {
|
2003-07-05 15:30:50 +00:00
|
|
|
nsIContent* content = aChildFrame->GetContent();
|
2002-05-23 00:00:34 +00:00
|
|
|
|
2017-12-07 18:13:50 +00:00
|
|
|
return content && content->IsElement() &&
|
|
|
|
content->AsElement()->HasAttr(kNameSpaceID_None, nsGkAtoms::noresize);
|
1998-09-09 23:30:30 +00:00
|
|
|
}
|
|
|
|
|
2012-12-01 02:28:02 +00:00
|
|
|
bool nsHTMLFramesetFrame::CanChildResize(bool aVertical, bool aLeft,
|
|
|
|
int32_t aChildX) {
|
1999-01-15 22:53:39 +00:00
|
|
|
nsIFrame* child = mFrames.FrameAt(aChildX);
|
2012-12-01 02:28:02 +00:00
|
|
|
nsHTMLFramesetFrame* frameset = do_QueryFrame(child);
|
|
|
|
return frameset ? frameset->CanResize(aVertical, aLeft) : !GetNoResize(child);
|
1998-09-03 01:16:27 +00:00
|
|
|
}
|
|
|
|
|
2001-04-12 08:16:54 +00:00
|
|
|
// This calculates and sets the resizability of all border frames
|
|
|
|
|
|
|
|
void nsHTMLFramesetFrame::RecalculateBorderResize() {
|
|
|
|
if (!mContent) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-08-23 15:24:54 +00: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 02:19:49 +00:00
|
|
|
// set the visibility and mouse sensitivity of borders
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t verX;
|
2001-04-12 08:16:54 +00:00
|
|
|
for (verX = 0; verX < mNumCols - 1; verX++) {
|
|
|
|
if (mVerBorders[verX]) {
|
2011-10-17 14:59:28 +00:00
|
|
|
mVerBorders[verX]->mCanResize = true;
|
2015-07-21 04:18:17 +00:00
|
|
|
SetBorderResize(mVerBorders[verX]);
|
2001-04-12 08:16:54 +00:00
|
|
|
}
|
|
|
|
}
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t horX;
|
2001-04-12 08:16:54 +00:00
|
|
|
for (horX = 0; horX < mNumRows - 1; horX++) {
|
|
|
|
if (mHorBorders[horX]) {
|
2011-10-17 14:59:28 +00:00
|
|
|
mHorBorders[horX]->mCanResize = true;
|
2015-07-21 04:18:17 +00:00
|
|
|
SetBorderResize(mHorBorders[horX]);
|
2001-04-12 08:16:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-01 02:28:02 +00:00
|
|
|
void nsHTMLFramesetFrame::SetBorderResize(
|
|
|
|
nsHTMLFramesetBorderFrame* aBorderFrame) {
|
1998-09-03 01:16:27 +00:00
|
|
|
if (aBorderFrame->mVertical) {
|
|
|
|
for (int rowX = 0; rowX < mNumRows; rowX++) {
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t childX = aBorderFrame->mPrevNeighbor + (rowX * mNumCols);
|
2012-12-01 02:28:02 +00:00
|
|
|
if (!CanChildResize(true, false, childX) ||
|
|
|
|
!CanChildResize(true, true, childX + 1)) {
|
2011-10-17 14:59:28 +00:00
|
|
|
aBorderFrame->mCanResize = false;
|
1998-09-03 01:16:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t childX = aBorderFrame->mPrevNeighbor * mNumCols;
|
|
|
|
int32_t endX = childX + mNumCols;
|
1998-09-03 01:16:27 +00:00
|
|
|
for (; childX < endX; childX++) {
|
2012-12-01 02:28:02 +00:00
|
|
|
if (!CanChildResize(false, false, childX)) {
|
2011-10-17 14:59:28 +00:00
|
|
|
aBorderFrame->mCanResize = false;
|
1998-09-03 01:16:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
endX = endX + mNumCols;
|
|
|
|
for (; childX < endX; childX++) {
|
2012-12-01 02:28:02 +00:00
|
|
|
if (!CanChildResize(false, true, childX)) {
|
2011-10-17 14:59:28 +00:00
|
|
|
aBorderFrame->mCanResize = false;
|
1998-09-03 01:16:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-12-03 19:47:10 +00:00
|
|
|
|
|
|
|
void nsHTMLFramesetFrame::StartMouseDrag(nsPresContext* aPresContext,
|
|
|
|
nsHTMLFramesetBorderFrame* aBorder,
|
2013-10-02 03:46:03 +00:00
|
|
|
WidgetGUIEvent* aEvent) {
|
1998-09-19 03:24:26 +00:00
|
|
|
#if 0
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t index;
|
1998-09-03 01:16:27 +00:00
|
|
|
IndexOf(aBorder, index);
|
2012-07-30 14:20:58 +00:00
|
|
|
NS_ASSERTION((nullptr != aBorder) && (index >= 0), "invalid dragger");
|
1998-09-19 03:24:26 +00:00
|
|
|
#endif
|
1999-02-26 17:12:16 +00:00
|
|
|
|
2019-04-25 05:02:20 +00:00
|
|
|
PresShell::SetCapturingContent(GetContent(),
|
|
|
|
CaptureFlags::IgnoreAllowedState);
|
2009-09-13 13:13:16 +00:00
|
|
|
|
|
|
|
mDragger = aBorder;
|
|
|
|
|
2016-04-18 14:09:02 +00:00
|
|
|
mFirstDragPoint = aEvent->mRefPoint;
|
2009-09-13 13:13:16 +00: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 01:16:27 +00:00
|
|
|
}
|
2009-09-13 13:13:16 +00:00
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
gDragInProgress = true;
|
1998-09-03 01:16:27 +00:00
|
|
|
}
|
2012-12-03 19:47:10 +00:00
|
|
|
|
|
|
|
void nsHTMLFramesetFrame::MouseDrag(nsPresContext* aPresContext,
|
2013-10-02 03:46:03 +00:00
|
|
|
WidgetGUIEvent* aEvent) {
|
2009-09-28 14:17:01 +00:00
|
|
|
// if the capture ended, reset the drag state
|
2019-04-30 00:26:57 +00:00
|
|
|
if (PresShell::GetCapturingContent() != GetContent()) {
|
2012-07-30 14:20:58 +00:00
|
|
|
mDragger = nullptr;
|
2011-10-17 14:59:28 +00:00
|
|
|
gDragInProgress = false;
|
2009-09-28 14:17:01 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t change; // measured positive from left-to-right or top-to-bottom
|
2017-03-01 17:03:14 +00:00
|
|
|
AutoWeakFrame weakFrame(this);
|
1998-09-03 01:16:27 +00:00
|
|
|
if (mDragger->mVertical) {
|
2016-04-18 14:09:02 +00:00
|
|
|
change = aPresContext->DevPixelsToAppUnits(aEvent->mRefPoint.x -
|
|
|
|
mFirstDragPoint.x);
|
1999-06-11 01:18:50 +00:00
|
|
|
if (change > mNextNeighborOrigSize - mMinDrag) {
|
|
|
|
change = mNextNeighborOrigSize - mMinDrag;
|
|
|
|
} else if (change <= mMinDrag - mPrevNeighborOrigSize) {
|
|
|
|
change = mMinDrag - mPrevNeighborOrigSize;
|
1998-09-03 01:16:27 +00:00
|
|
|
}
|
1999-06-11 01:18:50 +00:00
|
|
|
mColSizes[mDragger->mPrevNeighbor] = mPrevNeighborOrigSize + change;
|
|
|
|
mColSizes[mDragger->mNextNeighbor] = mNextNeighborOrigSize - change;
|
1999-06-11 00:51:05 +00:00
|
|
|
|
2002-08-06 01:06:50 +00:00
|
|
|
if (change != 0) {
|
|
|
|
// Recompute the specs from the new sizes.
|
2011-10-17 14:59:28 +00:00
|
|
|
nscoord width =
|
|
|
|
mRect.width - (mNumCols - 1) * GetBorderWidth(aPresContext, true);
|
2018-03-21 21:39:04 +00:00
|
|
|
HTMLFrameSetElement* ourContent = HTMLFrameSetElement::FromNode(mContent);
|
2002-08-06 01:06:50 +00:00
|
|
|
NS_ASSERTION(ourContent, "Someone gave us a broken frameset element!");
|
2012-07-30 14:20:58 +00:00
|
|
|
const nsFramesetSpec* colSpecs = nullptr;
|
2002-08-06 01:06:50 +00:00
|
|
|
ourContent->GetColSpec(&mNumCols, &colSpecs);
|
|
|
|
nsAutoString newColAttr;
|
2015-10-29 20:16:13 +00:00
|
|
|
GenerateRowCol(aPresContext, width, mNumCols, colSpecs, mColSizes.get(),
|
2002-08-06 01:06:50 +00:00
|
|
|
newColAttr);
|
|
|
|
// Setting the attr will trigger a reflow
|
2017-12-05 17:05:51 +00:00
|
|
|
mContent->AsElement()->SetAttr(kNameSpaceID_None, nsGkAtoms::cols,
|
|
|
|
newColAttr, true);
|
2002-08-06 01:06:50 +00:00
|
|
|
}
|
1998-09-03 01:16:27 +00:00
|
|
|
} else {
|
2016-04-18 14:09:02 +00:00
|
|
|
change = aPresContext->DevPixelsToAppUnits(aEvent->mRefPoint.y -
|
|
|
|
mFirstDragPoint.y);
|
1999-06-11 01:18:50 +00:00
|
|
|
if (change > mNextNeighborOrigSize - mMinDrag) {
|
|
|
|
change = mNextNeighborOrigSize - mMinDrag;
|
|
|
|
} else if (change <= mMinDrag - mPrevNeighborOrigSize) {
|
|
|
|
change = mMinDrag - mPrevNeighborOrigSize;
|
1998-09-03 01:16:27 +00:00
|
|
|
}
|
1999-06-11 01:18:50 +00:00
|
|
|
mRowSizes[mDragger->mPrevNeighbor] = mPrevNeighborOrigSize + change;
|
|
|
|
mRowSizes[mDragger->mNextNeighbor] = mNextNeighborOrigSize - change;
|
1999-06-11 00:51:05 +00:00
|
|
|
|
2002-08-06 01:06:50 +00:00
|
|
|
if (change != 0) {
|
|
|
|
// Recompute the specs from the new sizes.
|
2011-10-17 14:59:28 +00:00
|
|
|
nscoord height =
|
|
|
|
mRect.height - (mNumRows - 1) * GetBorderWidth(aPresContext, true);
|
2018-03-21 21:39:04 +00:00
|
|
|
HTMLFrameSetElement* ourContent = HTMLFrameSetElement::FromNode(mContent);
|
2002-08-06 01:06:50 +00:00
|
|
|
NS_ASSERTION(ourContent, "Someone gave us a broken frameset element!");
|
2012-07-30 14:20:58 +00:00
|
|
|
const nsFramesetSpec* rowSpecs = nullptr;
|
2002-08-06 01:06:50 +00:00
|
|
|
ourContent->GetRowSpec(&mNumRows, &rowSpecs);
|
|
|
|
nsAutoString newRowAttr;
|
2015-10-29 20:16:13 +00:00
|
|
|
GenerateRowCol(aPresContext, height, mNumRows, rowSpecs, mRowSizes.get(),
|
2002-08-06 01:06:50 +00:00
|
|
|
newRowAttr);
|
|
|
|
// Setting the attr will trigger a reflow
|
2017-12-05 17:05:51 +00:00
|
|
|
mContent->AsElement()->SetAttr(kNameSpaceID_None, nsGkAtoms::rows,
|
|
|
|
newRowAttr, true);
|
2002-08-06 01:06:50 +00:00
|
|
|
}
|
1998-09-03 01:16:27 +00:00
|
|
|
}
|
|
|
|
|
2018-08-13 09:42:00 +00:00
|
|
|
NS_ENSURE_TRUE_VOID(weakFrame.IsAlive());
|
1998-09-03 01:16:27 +00:00
|
|
|
if (change != 0) {
|
1999-03-10 06:13:35 +00:00
|
|
|
mDrag.Reset(mDragger->mVertical, mDragger->mPrevNeighbor, change, this);
|
1998-09-03 01:16:27 +00:00
|
|
|
}
|
2012-12-03 19:47:10 +00:00
|
|
|
}
|
1998-09-03 01:16:27 +00:00
|
|
|
|
2004-07-31 23:15:21 +00:00
|
|
|
void nsHTMLFramesetFrame::EndMouseDrag(nsPresContext* aPresContext) {
|
2019-04-25 05:02:20 +00:00
|
|
|
PresShell::ReleaseCapturingContent();
|
2012-07-30 14:20:58 +00:00
|
|
|
mDragger = nullptr;
|
2011-10-17 14:59:28 +00:00
|
|
|
gDragInProgress = false;
|
2009-09-13 13:13:16 +00:00
|
|
|
}
|
1998-09-03 01:16:27 +00:00
|
|
|
|
2019-04-16 07:24:49 +00:00
|
|
|
nsIFrame* NS_NewHTMLFramesetFrame(PresShell* aPresShell,
|
2018-03-22 18:20:41 +00:00
|
|
|
ComputedStyle* aStyle) {
|
2009-01-19 18:31:31 +00:00
|
|
|
#ifdef DEBUG
|
2018-03-22 18:20:41 +00:00
|
|
|
const nsStyleDisplay* disp = aStyle->StyleDisplay();
|
2012-08-02 11:38:50 +00:00
|
|
|
NS_ASSERTION(!disp->IsAbsolutelyPositionedStyle() && !disp->IsFloatingStyle(),
|
2009-01-19 18:31:31 +00:00
|
|
|
"Framesets should not be positioned and should not float");
|
|
|
|
#endif
|
|
|
|
|
2019-02-05 16:45:54 +00:00
|
|
|
return new (aPresShell)
|
|
|
|
nsHTMLFramesetFrame(aStyle, aPresShell->GetPresContext());
|
1998-07-15 23:42:14 +00:00
|
|
|
}
|
|
|
|
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsHTMLFramesetFrame)
|
|
|
|
|
1998-07-27 05:59:37 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
* nsHTMLFramesetBorderFrame
|
|
|
|
******************************************************************************/
|
2019-02-05 16:45:54 +00:00
|
|
|
nsHTMLFramesetBorderFrame::nsHTMLFramesetBorderFrame(
|
|
|
|
ComputedStyle* aStyle, nsPresContext* aPresContext, int32_t aWidth,
|
|
|
|
bool aVertical, bool aVisibility)
|
|
|
|
: nsLeafFrame(aStyle, aPresContext, kClassID),
|
2017-04-30 15:30:08 +00:00
|
|
|
mWidth(aWidth),
|
|
|
|
mVertical(aVertical),
|
|
|
|
mVisibility(aVisibility) {
|
2011-10-17 14:59:28 +00:00
|
|
|
mCanResize = true;
|
1999-04-13 00:56:23 +00:00
|
|
|
mColor = NO_COLOR;
|
|
|
|
mPrevNeighbor = 0;
|
|
|
|
mNextNeighbor = 0;
|
1998-07-27 05:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsHTMLFramesetBorderFrame::~nsHTMLFramesetBorderFrame() {
|
2000-10-28 22:17:53 +00:00
|
|
|
// printf("nsHTMLFramesetBorderFrame destructor %p \n", this);
|
1998-07-27 05:59:37 +00:00
|
|
|
}
|
|
|
|
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsHTMLFramesetBorderFrame)
|
|
|
|
|
2014-07-24 17:03:26 +00:00
|
|
|
nscoord nsHTMLFramesetBorderFrame::GetIntrinsicISize() {
|
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 05:38:33 +00:00
|
|
|
// No intrinsic width
|
|
|
|
return 0;
|
1998-07-27 05:59:37 +00:00
|
|
|
}
|
|
|
|
|
2014-07-24 17:03:26 +00:00
|
|
|
nscoord nsHTMLFramesetBorderFrame::GetIntrinsicBSize() {
|
2008-10-30 17:10:19 +00:00
|
|
|
// No intrinsic height
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
void nsHTMLFramesetBorderFrame::SetVisibility(bool aVisibility) {
|
2012-12-03 19:47:10 +00:00
|
|
|
mVisibility = aVisibility;
|
1998-07-30 21:25:35 +00:00
|
|
|
}
|
|
|
|
|
1998-09-03 01:16:27 +00:00
|
|
|
void nsHTMLFramesetBorderFrame::SetColor(nscolor aColor) { mColor = aColor; }
|
1998-07-30 21:25:35 +00:00
|
|
|
|
2012-12-03 19:47:10 +00:00
|
|
|
void nsHTMLFramesetBorderFrame::Reflow(nsPresContext* aPresContext,
|
2016-07-21 10:36:38 +00:00
|
|
|
ReflowOutput& aDesiredSize,
|
2016-07-21 10:36:39 +00:00
|
|
|
const ReflowInput& aReflowInput,
|
1998-10-02 04:10:00 +00:00
|
|
|
nsReflowStatus& 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 05:38:33 +00:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsHTMLFramesetBorderFrame");
|
2016-07-21 10:36:39 +00:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowInput, aDesiredSize, aStatus);
|
2017-09-13 10:00:25 +00:00
|
|
|
MOZ_ASSERT(aStatus.IsEmpty(), "Caller should pass a fresh reflow status!");
|
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 05:38:33 +00:00
|
|
|
|
|
|
|
// Override Reflow(), since we don't want to deal with what our
|
|
|
|
// computed values are.
|
2016-07-21 10:36:39 +00: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 05:38:33 +00:00
|
|
|
|
2010-10-07 04:25:46 +00:00
|
|
|
aDesiredSize.SetOverflowAreasToDesiredBounds();
|
1998-07-27 05:59:37 +00:00
|
|
|
}
|
1998-07-15 23:42:14 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
class nsDisplayFramesetBorder : public nsDisplayItem {
|
|
|
|
public:
|
2010-08-13 10:01:13 +00:00
|
|
|
nsDisplayFramesetBorder(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsHTMLFramesetBorderFrame* aFrame)
|
|
|
|
: nsDisplayItem(aBuilder, aFrame) {
|
2006-01-29 18:48:58 +00:00
|
|
|
MOZ_COUNT_CTOR(nsDisplayFramesetBorder);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayFramesetBorder() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayFramesetBorder);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
// REVIEW: see old GetFrameForPoint
|
|
|
|
// Receives events in its bounds
|
2010-04-08 00:31:26 +00:00
|
|
|
virtual void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
|
2014-02-24 14:41:56 +00:00
|
|
|
HitTestState* aState,
|
2015-03-21 16:28:04 +00:00
|
|
|
nsTArray<nsIFrame*>* aOutFrames) override {
|
2010-04-08 00:31:26 +00:00
|
|
|
aOutFrames->AppendElement(mFrame);
|
|
|
|
}
|
2009-09-07 00:35:14 +00:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override;
|
2010-07-15 21:07:49 +00:00
|
|
|
NS_DISPLAY_DECL_NAME("FramesetBorder", TYPE_FRAMESET_BORDER)
|
2006-01-26 02:29:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void nsDisplayFramesetBorder::Paint(nsDisplayListBuilder* aBuilder,
|
2017-06-09 19:14:53 +00:00
|
|
|
gfxContext* aCtx) {
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<nsHTMLFramesetBorderFrame*>(mFrame)->PaintBorder(
|
2014-10-20 09:55:48 +00:00
|
|
|
aCtx->GetDrawTarget(), ToReferenceFrame());
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsHTMLFramesetBorderFrame::BuildDisplayList(
|
|
|
|
nsDisplayListBuilder* aBuilder, const nsDisplayListSet& aLists) {
|
2019-04-01 16:53:11 +00:00
|
|
|
aLists.Content()->AppendNewToTop<nsDisplayFramesetBorder>(aBuilder, this);
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
|
|
|
|
2014-10-20 09:55:48 +00:00
|
|
|
void nsHTMLFramesetBorderFrame::PaintBorder(DrawTarget* aDrawTarget,
|
2006-01-26 02:29:17 +00:00
|
|
|
nsPoint aPt) {
|
2007-02-07 07:46:44 +00:00
|
|
|
nscoord widthInPixels = nsPresContext::AppUnitsToIntCSSPixels(mWidth);
|
|
|
|
nscoord pixelWidth = nsPresContext::CSSPixelsToAppUnits(1);
|
1998-08-06 19:40:37 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
if (widthInPixels <= 0) return;
|
1998-07-27 05:59:37 +00:00
|
|
|
|
2014-10-20 09:55:48 +00: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 05:59:37 +00:00
|
|
|
|
2014-10-20 09:55:48 +00: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 04:22:02 +00:00
|
|
|
if (mVisibility) {
|
2014-10-20 09:55:48 +00:00
|
|
|
color =
|
|
|
|
(NO_COLOR == mColor) ? bgColor : ColorPattern(ToDeviceColor(mColor));
|
1998-09-03 01:16:27 +00:00
|
|
|
}
|
2014-10-20 09:55:48 +00: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 19:40:37 +00:00
|
|
|
// draw grey or white first
|
|
|
|
for (int i = 0; i < widthInPixels; i++) {
|
2014-10-20 09:55:48 +00:00
|
|
|
StrokeLineWithSnapping(start, end, appUnitsPerDevPixel, *aDrawTarget,
|
|
|
|
color);
|
1998-07-27 05:59:37 +00:00
|
|
|
if (mVertical) {
|
2011-04-08 01:04:39 +00:00
|
|
|
start.x += pixelWidth;
|
|
|
|
end.x = start.x;
|
1998-07-27 05:59:37 +00:00
|
|
|
} else {
|
2011-04-08 01:04:39 +00:00
|
|
|
start.y += pixelWidth;
|
|
|
|
end.y = start.y;
|
1998-07-27 05:59:37 +00:00
|
|
|
}
|
|
|
|
}
|
1998-08-06 19:40:37 +00:00
|
|
|
|
2015-07-21 04:22:02 +00:00
|
|
|
if (!mVisibility) return;
|
1998-08-06 19:40:37 +00:00
|
|
|
|
|
|
|
if (widthInPixels >= 5) {
|
2011-04-08 01:04:39 +00: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 09:55:48 +00:00
|
|
|
StrokeLineWithSnapping(start, end, appUnitsPerDevPixel, *aDrawTarget,
|
|
|
|
hltColor);
|
1998-08-06 19:40:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (widthInPixels >= 2) {
|
2011-04-08 01:04:39 +00: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 09:55:48 +00:00
|
|
|
StrokeLineWithSnapping(start, end, appUnitsPerDevPixel, *aDrawTarget,
|
|
|
|
sdwColor);
|
1998-08-06 19:40:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (widthInPixels >= 1) {
|
2011-04-08 01:04:39 +00: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 09:55:48 +00:00
|
|
|
StrokeLineWithSnapping(start, end, appUnitsPerDevPixel, *aDrawTarget,
|
|
|
|
fgColor);
|
1998-08-06 19:40:37 +00:00
|
|
|
}
|
1998-07-27 05:59:37 +00:00
|
|
|
}
|
|
|
|
|
2012-12-03 19:47:10 +00:00
|
|
|
nsresult nsHTMLFramesetBorderFrame::HandleEvent(nsPresContext* aPresContext,
|
2013-10-02 03:46:03 +00:00
|
|
|
WidgetGUIEvent* aEvent,
|
2012-12-03 19:47:10 +00:00
|
|
|
nsEventStatus* aEventStatus) {
|
1999-11-24 06:03:41 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(aEventStatus);
|
|
|
|
*aEventStatus = nsEventStatus_eIgnore;
|
1998-11-18 05:25:26 +00:00
|
|
|
|
|
|
|
// XXX Mouse setting logic removed. The remaining logic should also move.
|
1998-09-03 01:16:27 +00:00
|
|
|
if (!mCanResize) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-08-28 23:58:30 +00:00
|
|
|
if (aEvent->mMessage == eMouseDown &&
|
2019-04-21 20:13:34 +00:00
|
|
|
aEvent->AsMouseEvent()->mButton == MouseButton::eLeft) {
|
2012-12-01 02:28:02 +00:00
|
|
|
nsHTMLFramesetFrame* parentFrame = do_QueryFrame(GetParent());
|
|
|
|
if (parentFrame) {
|
|
|
|
parentFrame->StartMouseDrag(aPresContext, this, aEvent);
|
|
|
|
*aEventStatus = nsEventStatus_eConsumeNoDefault;
|
|
|
|
}
|
1998-07-30 21:25:35 +00:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2019-03-13 18:38:09 +00:00
|
|
|
Maybe<nsIFrame::Cursor> nsHTMLFramesetBorderFrame::GetCursor(const nsPoint&) {
|
|
|
|
auto kind = StyleCursorKind::Default;
|
|
|
|
if (mCanResize) {
|
|
|
|
kind = mVertical ? StyleCursorKind::EwResize : StyleCursorKind::NsResize;
|
1999-03-10 06:13:35 +00:00
|
|
|
}
|
2019-03-13 18:38:09 +00:00
|
|
|
return Some(Cursor{kind, AllowCustomCursorImage::No});
|
1998-11-18 05:25:26 +00:00
|
|
|
}
|
|
|
|
|
2014-01-05 23:31:14 +00:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-02-18 07:47:48 +00:00
|
|
|
nsresult nsHTMLFramesetBorderFrame::GetFrameName(nsAString& aResult) const {
|
2001-11-14 01:33:42 +00:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("FramesetBorder"), aResult);
|
1998-07-27 05:59:37 +00:00
|
|
|
}
|
1999-11-01 22:12:45 +00:00
|
|
|
#endif
|
1998-07-15 23:42:14 +00:00
|
|
|
|
1998-08-05 22:24:56 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
* nsHTMLFramesetBlankFrame
|
|
|
|
******************************************************************************/
|
|
|
|
|
2013-04-03 23:35:07 +00:00
|
|
|
NS_QUERYFRAME_HEAD(nsHTMLFramesetBlankFrame)
|
2018-12-07 20:00:18 +00:00
|
|
|
NS_QUERYFRAME_ENTRY(nsHTMLFramesetBlankFrame)
|
2013-04-03 23:35:07 +00:00
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsLeafFrame)
|
|
|
|
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsHTMLFramesetBlankFrame)
|
|
|
|
|
1998-08-05 22:24:56 +00:00
|
|
|
nsHTMLFramesetBlankFrame::~nsHTMLFramesetBlankFrame() {
|
2000-10-28 22:17:53 +00:00
|
|
|
// printf("nsHTMLFramesetBlankFrame destructor %p \n", this);
|
1998-08-05 22:24:56 +00:00
|
|
|
}
|
|
|
|
|
2014-07-24 17:03:26 +00:00
|
|
|
nscoord nsHTMLFramesetBlankFrame::GetIntrinsicISize() {
|
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 05:38:33 +00:00
|
|
|
// No intrinsic width
|
|
|
|
return 0;
|
1998-08-05 22:24:56 +00:00
|
|
|
}
|
|
|
|
|
2014-07-24 17:03:26 +00:00
|
|
|
nscoord nsHTMLFramesetBlankFrame::GetIntrinsicBSize() {
|
2008-10-30 17:10:19 +00:00
|
|
|
// No intrinsic height
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-12-03 19:47:10 +00:00
|
|
|
void nsHTMLFramesetBlankFrame::Reflow(nsPresContext* aPresContext,
|
2016-07-21 10:36:38 +00:00
|
|
|
ReflowOutput& aDesiredSize,
|
2016-07-21 10:36:39 +00:00
|
|
|
const ReflowInput& aReflowInput,
|
1998-10-02 04:10:00 +00:00
|
|
|
nsReflowStatus& 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 05:38:33 +00:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsHTMLFramesetBlankFrame");
|
2017-09-13 10:00:25 +00:00
|
|
|
MOZ_ASSERT(aStatus.IsEmpty(), "Caller should pass a fresh reflow status!");
|
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 05:38:33 +00:00
|
|
|
|
|
|
|
// Override Reflow(), since we don't want to deal with what our
|
|
|
|
// computed values are.
|
2016-07-21 10:36:39 +00: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 05:38:33 +00:00
|
|
|
|
2010-10-07 04:25:46 +00:00
|
|
|
aDesiredSize.SetOverflowAreasToDesiredBounds();
|
1998-08-05 22:24:56 +00:00
|
|
|
}
|
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
class nsDisplayFramesetBlank : public nsDisplayItem {
|
|
|
|
public:
|
2010-08-13 10:01:13 +00:00
|
|
|
nsDisplayFramesetBlank(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame)
|
|
|
|
: nsDisplayItem(aBuilder, aFrame) {
|
2006-01-29 18:48:58 +00:00
|
|
|
MOZ_COUNT_CTOR(nsDisplayFramesetBlank);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayFramesetBlank() { MOZ_COUNT_DTOR(nsDisplayFramesetBlank); }
|
|
|
|
#endif
|
|
|
|
|
2014-02-24 14:41:56 +00:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) override;
|
2010-07-15 21:07:49 +00:00
|
|
|
NS_DISPLAY_DECL_NAME("FramesetBlank", TYPE_FRAMESET_BLANK)
|
2006-01-26 02:29:17 +00:00
|
|
|
};
|
2010-08-13 10:01:58 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
void nsDisplayFramesetBlank::Paint(nsDisplayListBuilder* aBuilder,
|
2017-06-09 19:14:53 +00:00
|
|
|
gfxContext* aCtx) {
|
2014-10-19 12:22:22 +00:00
|
|
|
DrawTarget* drawTarget = aCtx->GetDrawTarget();
|
|
|
|
int32_t appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel();
|
2014-10-22 11:29:06 +00:00
|
|
|
Rect rect =
|
2018-05-16 03:56:32 +00:00
|
|
|
NSRectToSnappedRect(GetPaintRect(), appUnitsPerDevPixel, *drawTarget);
|
2014-10-19 12:22:22 +00:00
|
|
|
ColorPattern white(ToDeviceColor(Color(1.f, 1.f, 1.f, 1.f)));
|
|
|
|
drawTarget->FillRect(rect, white);
|
1998-08-05 22:24:56 +00:00
|
|
|
}
|
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
void nsHTMLFramesetBlankFrame::BuildDisplayList(
|
|
|
|
nsDisplayListBuilder* aBuilder, const nsDisplayListSet& aLists) {
|
2019-04-01 16:53:11 +00:00
|
|
|
aLists.Content()->AppendNewToTop<nsDisplayFramesetBlank>(aBuilder, this);
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|