2017-10-27 20:33:53 +03: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 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-03-27 04:35:55 +03:00
|
|
|
|
|
|
|
//
|
|
|
|
// Eric Vaughan
|
|
|
|
// Netscape Communications
|
|
|
|
//
|
|
|
|
// See documentation in associated header file
|
|
|
|
//
|
|
|
|
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
// How boxes layout
|
|
|
|
// ----------------
|
|
|
|
// Boxes layout a bit differently than html. html does a bottom up layout. Where
|
2018-12-05 21:44:05 +03:00
|
|
|
// boxes do a top down.
|
|
|
|
//
|
|
|
|
// 1) First thing a box does it goes out and askes each child for its min, max,
|
|
|
|
// and preferred sizes.
|
|
|
|
//
|
|
|
|
// 2) It then adds them up to determine its size.
|
|
|
|
//
|
|
|
|
// 3) If the box was asked to layout it self intrinically it will layout its
|
|
|
|
// children at their preferred size otherwise it will layout the child at
|
|
|
|
// the size it was told to. It will squeeze or stretch its children if
|
|
|
|
// Necessary.
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
//
|
2017-07-06 15:00:35 +03:00
|
|
|
// However there is a catch. Some html components like block frames can not
|
2005-11-21 01:05:24 +03:00
|
|
|
// determine their preferred size. this is their size if they were laid out
|
|
|
|
// intrinsically. So the box will flow the child to determine this can cache the
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
// value.
|
|
|
|
|
|
|
|
// Boxes and Incremental Reflow
|
|
|
|
// ----------------------------
|
2005-11-21 01:05:24 +03:00
|
|
|
// Boxes layout out top down by adding up their children's min, max, and
|
|
|
|
// preferred sizes. Only problem is if a incremental reflow occurs. The
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
// preferred size of a child deep in the hierarchy could change. And this could
|
|
|
|
// change any number of syblings around the box. Basically any children in the
|
|
|
|
// reflow chain must have their caches cleared so when asked for there current
|
2017-07-06 15:00:35 +03:00
|
|
|
// size they can relayout themselves.
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
|
1999-03-27 04:35:55 +03:00
|
|
|
#include "nsBoxFrame.h"
|
2014-10-17 18:06:34 +04:00
|
|
|
|
|
|
|
#include "gfxUtils.h"
|
|
|
|
#include "mozilla/gfx/2D.h"
|
|
|
|
#include "nsBoxLayoutState.h"
|
2013-04-05 12:49:00 +04:00
|
|
|
#include "mozilla/dom/Touch.h"
|
2014-10-20 13:55:48 +04:00
|
|
|
#include "mozilla/Move.h"
|
2018-03-22 21:20:41 +03:00
|
|
|
#include "mozilla/ComputedStyle.h"
|
2019-04-06 09:02:28 +03:00
|
|
|
#include "mozilla/PresShell.h"
|
2013-06-01 09:14:03 +04:00
|
|
|
#include "nsPlaceholderFrame.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
1999-03-27 04:35:55 +03:00
|
|
|
#include "nsCOMPtr.h"
|
2014-02-28 03:04:46 +04:00
|
|
|
#include "nsNameSpaceManager.h"
|
2007-01-30 03:06:41 +03:00
|
|
|
#include "nsGkAtoms.h"
|
1999-05-10 01:46:24 +04:00
|
|
|
#include "nsIContent.h"
|
1999-07-02 09:28:32 +04:00
|
|
|
#include "nsHTMLParts.h"
|
2013-01-05 07:12:24 +04:00
|
|
|
#include "nsViewManager.h"
|
2013-01-03 17:23:11 +04:00
|
|
|
#include "nsView.h"
|
1999-09-10 04:57:01 +04:00
|
|
|
#include "nsCSSRendering.h"
|
2000-03-02 10:13:02 +03:00
|
|
|
#include "nsIServiceManager.h"
|
2011-07-11 18:05:10 +04:00
|
|
|
#include "nsBoxLayout.h"
|
2000-03-31 11:02:06 +04:00
|
|
|
#include "nsSprocketLayout.h"
|
2000-05-22 13:15:54 +04:00
|
|
|
#include "nsIScrollableFrame.h"
|
2000-06-22 04:48:49 +04:00
|
|
|
#include "nsWidgetsCID.h"
|
2002-11-17 18:37:56 +03:00
|
|
|
#include "nsCSSAnonBoxes.h"
|
2011-12-28 00:18:48 +04:00
|
|
|
#include "nsContainerFrame.h"
|
2002-01-08 03:43:20 +03:00
|
|
|
#include "nsITheme.h"
|
2002-06-18 03:35:15 +04:00
|
|
|
#include "nsTransform2D.h"
|
2014-04-01 08:09:23 +04:00
|
|
|
#include "mozilla/EventStateManager.h"
|
2019-03-22 21:28:42 +03:00
|
|
|
#include "mozilla/gfx/gfxVars.h"
|
2006-01-26 05:29:17 +03:00
|
|
|
#include "nsDisplayList.h"
|
2011-05-25 10:31:59 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
2018-07-25 16:03:45 +03:00
|
|
|
#include "nsStyleConsts.h"
|
2013-10-01 01:26:04 +04:00
|
|
|
#include "nsLayoutUtils.h"
|
2015-04-13 06:03:02 +03:00
|
|
|
#include "nsSliderFrame.h"
|
2013-01-15 16:22:03 +04:00
|
|
|
#include <algorithm>
|
2000-06-22 04:48:49 +04:00
|
|
|
|
2002-01-23 05:53:02 +03:00
|
|
|
// Needed for Print Preview
|
|
|
|
#include "nsIURI.h"
|
|
|
|
|
2013-09-25 15:21:16 +04:00
|
|
|
#include "mozilla/TouchEvents.h"
|
|
|
|
|
2011-05-25 10:31:59 +04:00
|
|
|
using namespace mozilla;
|
2013-04-05 12:49:00 +04:00
|
|
|
using namespace mozilla::dom;
|
2014-10-17 18:06:34 +04:00
|
|
|
using namespace mozilla::gfx;
|
2011-05-25 10:31:59 +04:00
|
|
|
|
2019-04-16 10:24:49 +03:00
|
|
|
nsIFrame* NS_NewBoxFrame(PresShell* aPresShell, ComputedStyle* aStyle,
|
2018-03-22 21:20:41 +03:00
|
|
|
bool aIsRoot, nsBoxLayout* aLayoutManager) {
|
|
|
|
return new (aPresShell)
|
2019-02-05 19:45:54 +03:00
|
|
|
nsBoxFrame(aStyle, aPresShell->GetPresContext(), nsBoxFrame::kClassID,
|
|
|
|
aIsRoot, aLayoutManager);
|
2009-09-12 20:49:24 +04:00
|
|
|
}
|
1999-03-27 04:35:55 +03:00
|
|
|
|
2019-04-16 10:24:49 +03:00
|
|
|
nsIFrame* NS_NewBoxFrame(PresShell* aPresShell, ComputedStyle* aStyle) {
|
2019-02-05 19:45:54 +03:00
|
|
|
return new (aPresShell) nsBoxFrame(aStyle, aPresShell->GetPresContext());
|
2009-01-19 21:31:33 +03:00
|
|
|
}
|
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsBoxFrame)
|
|
|
|
|
2014-01-18 11:08:22 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
NS_QUERYFRAME_HEAD(nsBoxFrame)
|
2018-12-07 23:00:18 +03:00
|
|
|
NS_QUERYFRAME_ENTRY(nsBoxFrame)
|
2014-01-18 11:08:22 +04:00
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
|
|
|
|
#endif
|
|
|
|
|
2019-02-05 19:45:54 +03:00
|
|
|
nsBoxFrame::nsBoxFrame(ComputedStyle* aStyle, nsPresContext* aPresContext,
|
|
|
|
ClassID aID, bool aIsRoot, nsBoxLayout* aLayoutManager)
|
|
|
|
: nsContainerFrame(aStyle, aPresContext, aID), mFlex(0), mAscent(0) {
|
2017-08-24 14:09:42 +03:00
|
|
|
AddStateBits(NS_STATE_IS_HORIZONTAL | NS_STATE_AUTO_STRETCH);
|
2000-02-17 02:00:52 +03:00
|
|
|
|
2017-08-24 14:09:42 +03:00
|
|
|
if (aIsRoot) AddStateBits(NS_STATE_IS_ROOT);
|
2000-03-02 06:01:30 +03:00
|
|
|
|
2002-10-10 10:39:30 +04:00
|
|
|
mValign = vAlign_Top;
|
|
|
|
mHalign = hAlign_Left;
|
2017-05-03 18:43:06 +03:00
|
|
|
|
2000-04-05 04:19:00 +04:00
|
|
|
// if no layout manager specified us the static sprocket layout
|
2011-07-11 18:05:10 +04:00
|
|
|
nsCOMPtr<nsBoxLayout> layout = aLayoutManager;
|
2000-04-05 04:19:00 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
if (layout == nullptr) {
|
2015-12-08 02:27:01 +03:00
|
|
|
NS_NewSprocketLayout(layout);
|
2000-04-05 04:19:00 +04:00
|
|
|
}
|
|
|
|
|
2016-04-21 07:28:33 +03:00
|
|
|
SetXULLayoutManager(layout);
|
1999-08-27 10:06:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsBoxFrame::~nsBoxFrame() {}
|
1999-03-27 04:35:55 +03:00
|
|
|
|
2011-08-25 00:54:30 +04:00
|
|
|
void nsBoxFrame::SetInitialChildList(ChildListID aListID,
|
2009-07-28 16:53:20 +04:00
|
|
|
nsFrameList& aChildList) {
|
2014-05-28 23:36:58 +04:00
|
|
|
nsContainerFrame::SetInitialChildList(aListID, aChildList);
|
2016-01-28 02:11:00 +03:00
|
|
|
if (aListID == kPrincipalList) {
|
|
|
|
// initialize our list of infos.
|
|
|
|
nsBoxLayoutState state(PresContext());
|
|
|
|
CheckBoxOrder();
|
|
|
|
if (mLayoutManager)
|
|
|
|
mLayoutManager->ChildrenSet(this, state, mFrames.FirstChild());
|
|
|
|
}
|
1999-12-02 04:07:27 +03:00
|
|
|
}
|
|
|
|
|
2019-02-26 01:09:24 +03:00
|
|
|
/* virtual */
|
|
|
|
void nsBoxFrame::DidSetComputedStyle(ComputedStyle* aOldComputedStyle) {
|
2018-03-22 21:20:41 +03:00
|
|
|
nsContainerFrame::DidSetComputedStyle(aOldComputedStyle);
|
2008-10-14 02:03:28 +04:00
|
|
|
|
2006-04-18 03:58:17 +04:00
|
|
|
// The values that CacheAttributes() computes depend on our style,
|
|
|
|
// so we need to recompute them here...
|
|
|
|
CacheAttributes();
|
|
|
|
}
|
|
|
|
|
1999-05-10 01:46:24 +04:00
|
|
|
/**
|
|
|
|
* Initialize us. This is a good time to get the alignment of the box
|
|
|
|
*/
|
2014-05-25 02:20:40 +04:00
|
|
|
void nsBoxFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow) {
|
2013-03-20 05:47:48 +04:00
|
|
|
nsContainerFrame::Init(aContent, aParent, aPrevInFlow);
|
2000-01-08 05:18:14 +03:00
|
|
|
|
2012-04-17 02:32:12 +04:00
|
|
|
if (GetStateBits() & NS_FRAME_FONT_INFLATION_CONTAINER) {
|
|
|
|
AddStateBits(NS_FRAME_FONT_INFLATION_FLOW_ROOT);
|
|
|
|
}
|
|
|
|
|
2014-07-24 21:03:26 +04:00
|
|
|
MarkIntrinsicISizesDirty();
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
2002-10-10 10:39:30 +04:00
|
|
|
CacheAttributes();
|
2000-03-02 06:01:30 +03:00
|
|
|
|
2007-06-19 03:22:46 +04:00
|
|
|
UpdateMouseThrough();
|
|
|
|
|
2002-02-21 16:39:39 +03:00
|
|
|
// register access key
|
2013-03-20 05:47:48 +04:00
|
|
|
RegUnregAccessKey(true);
|
2001-12-04 02:41:13 +03:00
|
|
|
}
|
|
|
|
|
2007-06-19 03:22:46 +04:00
|
|
|
void nsBoxFrame::UpdateMouseThrough() {
|
2017-12-07 21:13:50 +03:00
|
|
|
static Element::AttrValuesArray strings[] = {nsGkAtoms::never,
|
2018-04-03 06:21:06 +03:00
|
|
|
nsGkAtoms::always, nullptr};
|
2017-12-07 21:13:50 +03:00
|
|
|
switch (mContent->AsElement()->FindAttrValueIn(
|
|
|
|
kNameSpaceID_None, nsGkAtoms::mousethrough, strings, eCaseMatters)) {
|
|
|
|
case 0:
|
|
|
|
AddStateBits(NS_FRAME_MOUSE_THROUGH_NEVER);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
AddStateBits(NS_FRAME_MOUSE_THROUGH_ALWAYS);
|
|
|
|
break;
|
|
|
|
case 2: {
|
|
|
|
RemoveStateBits(NS_FRAME_MOUSE_THROUGH_ALWAYS);
|
|
|
|
RemoveStateBits(NS_FRAME_MOUSE_THROUGH_NEVER);
|
|
|
|
break;
|
2007-06-19 03:22:46 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-10 10:39:30 +04:00
|
|
|
void nsBoxFrame::CacheAttributes() {
|
2000-06-23 09:15:04 +04:00
|
|
|
/*
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("Caching: ");
|
2016-04-21 07:28:34 +03:00
|
|
|
XULDumpBox(stdout);
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("\n");
|
2000-06-23 09:15:04 +04:00
|
|
|
*/
|
|
|
|
|
2002-10-10 10:39:30 +04:00
|
|
|
mValign = vAlign_Top;
|
|
|
|
mHalign = hAlign_Left;
|
2000-06-23 09:15:04 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool orient = false;
|
2017-07-06 15:00:35 +03:00
|
|
|
GetInitialOrientation(orient);
|
2000-06-23 09:15:04 +04:00
|
|
|
if (orient)
|
2017-08-24 14:09:42 +03:00
|
|
|
AddStateBits(NS_STATE_IS_HORIZONTAL);
|
2001-08-02 04:09:27 +04:00
|
|
|
else
|
2017-08-24 12:55:28 +03:00
|
|
|
RemoveStateBits(NS_STATE_IS_HORIZONTAL);
|
2000-06-23 09:15:04 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool normal = true;
|
2017-07-06 15:00:35 +03:00
|
|
|
GetInitialDirection(normal);
|
2001-08-15 08:09:41 +04:00
|
|
|
if (normal)
|
2017-08-24 14:09:42 +03:00
|
|
|
AddStateBits(NS_STATE_IS_DIRECTION_NORMAL);
|
2001-08-15 08:09:41 +04:00
|
|
|
else
|
2017-08-24 12:55:28 +03:00
|
|
|
RemoveStateBits(NS_STATE_IS_DIRECTION_NORMAL);
|
2001-08-15 08:09:41 +04:00
|
|
|
|
2002-10-10 10:39:30 +04:00
|
|
|
GetInitialVAlignment(mValign);
|
|
|
|
GetInitialHAlignment(mHalign);
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool equalSize = false;
|
2017-07-06 15:00:35 +03:00
|
|
|
GetInitialEqualSize(equalSize);
|
2000-06-23 09:15:04 +04:00
|
|
|
if (equalSize)
|
2017-08-24 14:09:42 +03:00
|
|
|
AddStateBits(NS_STATE_EQUAL_SIZE);
|
2000-06-23 09:15:04 +04:00
|
|
|
else
|
2017-08-24 12:55:28 +03:00
|
|
|
RemoveStateBits(NS_STATE_EQUAL_SIZE);
|
2000-06-23 09:15:04 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool autostretch = !!(mState & NS_STATE_AUTO_STRETCH);
|
2002-10-10 10:39:30 +04:00
|
|
|
GetInitialAutoStretch(autostretch);
|
2000-06-23 09:15:04 +04:00
|
|
|
if (autostretch)
|
2017-08-24 14:09:42 +03:00
|
|
|
AddStateBits(NS_STATE_AUTO_STRETCH);
|
2000-06-23 09:15:04 +04:00
|
|
|
else
|
2017-08-24 12:55:28 +03:00
|
|
|
RemoveStateBits(NS_STATE_AUTO_STRETCH);
|
2000-03-02 06:01:30 +03:00
|
|
|
}
|
|
|
|
|
2000-02-14 04:42:09 +03:00
|
|
|
bool nsBoxFrame::GetInitialHAlignment(nsBoxFrame::Halignment& aHalign) {
|
2019-11-19 23:30:54 +03:00
|
|
|
if (!GetContent()) return false;
|
2000-02-14 04:42:09 +03:00
|
|
|
|
2019-11-19 23:30:54 +03:00
|
|
|
// For horizontal boxes we're checking PACK. For vertical boxes we are
|
|
|
|
// checking ALIGN.
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStyleXUL* boxInfo = StyleXUL();
|
2016-04-21 07:28:34 +03:00
|
|
|
if (IsXULHorizontal()) {
|
2001-08-02 04:09:27 +04:00
|
|
|
switch (boxInfo->mBoxPack) {
|
2016-08-26 10:11:54 +03:00
|
|
|
case StyleBoxPack::Start:
|
2001-08-02 04:09:27 +04:00
|
|
|
aHalign = nsBoxFrame::hAlign_Left;
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2016-08-26 10:11:54 +03:00
|
|
|
case StyleBoxPack::Center:
|
2001-08-02 04:09:27 +04:00
|
|
|
aHalign = nsBoxFrame::hAlign_Center;
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2016-08-26 10:11:54 +03:00
|
|
|
case StyleBoxPack::End:
|
2001-08-02 04:09:27 +04:00
|
|
|
aHalign = nsBoxFrame::hAlign_Right;
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2001-08-02 04:09:27 +04:00
|
|
|
default: // Nonsensical value. Just bail.
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2001-08-02 04:09:27 +04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
switch (boxInfo->mBoxAlign) {
|
2016-08-26 10:09:19 +03:00
|
|
|
case StyleBoxAlign::Start:
|
2001-08-02 04:09:27 +04:00
|
|
|
aHalign = nsBoxFrame::hAlign_Left;
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2016-08-26 10:09:19 +03:00
|
|
|
case StyleBoxAlign::Center:
|
2001-08-02 04:09:27 +04:00
|
|
|
aHalign = nsBoxFrame::hAlign_Center;
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2016-08-26 10:09:19 +03:00
|
|
|
case StyleBoxAlign::End:
|
2001-08-02 04:09:27 +04:00
|
|
|
aHalign = nsBoxFrame::hAlign_Right;
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2001-08-02 04:09:27 +04:00
|
|
|
default: // Nonsensical value. Just bail.
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2001-08-02 04:09:27 +04:00
|
|
|
}
|
|
|
|
}
|
2000-02-14 04:42:09 +03:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2000-02-14 04:42:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool nsBoxFrame::GetInitialVAlignment(nsBoxFrame::Valignment& aValign) {
|
2019-11-19 23:30:54 +03:00
|
|
|
if (!GetContent()) return false;
|
|
|
|
// For horizontal boxes we're checking ALIGN. For vertical boxes we are
|
|
|
|
// checking PACK.
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStyleXUL* boxInfo = StyleXUL();
|
2016-04-21 07:28:34 +03:00
|
|
|
if (IsXULHorizontal()) {
|
2001-08-02 04:09:27 +04:00
|
|
|
switch (boxInfo->mBoxAlign) {
|
2016-08-26 10:09:19 +03:00
|
|
|
case StyleBoxAlign::Start:
|
2001-08-02 04:09:27 +04:00
|
|
|
aValign = nsBoxFrame::vAlign_Top;
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2016-08-26 10:09:19 +03:00
|
|
|
case StyleBoxAlign::Center:
|
2001-08-02 04:09:27 +04:00
|
|
|
aValign = nsBoxFrame::vAlign_Middle;
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2016-08-26 10:09:19 +03:00
|
|
|
case StyleBoxAlign::Baseline:
|
2001-08-02 04:09:27 +04:00
|
|
|
aValign = nsBoxFrame::vAlign_BaseLine;
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2016-08-26 10:09:19 +03:00
|
|
|
case StyleBoxAlign::End:
|
2001-08-02 04:09:27 +04:00
|
|
|
aValign = nsBoxFrame::vAlign_Bottom;
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2001-08-02 04:09:27 +04:00
|
|
|
default: // Nonsensical value. Just bail.
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2001-08-02 04:09:27 +04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
switch (boxInfo->mBoxPack) {
|
2016-08-26 10:11:54 +03:00
|
|
|
case StyleBoxPack::Start:
|
2001-08-02 04:09:27 +04:00
|
|
|
aValign = nsBoxFrame::vAlign_Top;
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2016-08-26 10:11:54 +03:00
|
|
|
case StyleBoxPack::Center:
|
2001-08-02 04:09:27 +04:00
|
|
|
aValign = nsBoxFrame::vAlign_Middle;
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2016-08-26 10:11:54 +03:00
|
|
|
case StyleBoxPack::End:
|
2001-08-02 04:09:27 +04:00
|
|
|
aValign = nsBoxFrame::vAlign_Bottom;
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2001-08-02 04:09:27 +04:00
|
|
|
default: // Nonsensical value. Just bail.
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2001-08-02 04:09:27 +04:00
|
|
|
}
|
|
|
|
}
|
2000-02-14 04:42:09 +03:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
1999-11-19 00:05:43 +03:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
void nsBoxFrame::GetInitialOrientation(bool& aIsHorizontal) {
|
1999-11-19 00:05:43 +03:00
|
|
|
// see if we are a vertical or horizontal box.
|
2007-05-23 07:48:43 +04:00
|
|
|
if (!GetContent()) return;
|
2001-03-06 05:27:50 +03:00
|
|
|
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStyleXUL* boxInfo = StyleXUL();
|
2016-08-26 10:18:41 +03:00
|
|
|
if (boxInfo->mBoxOrient == StyleBoxOrient::Horizontal) {
|
2011-10-17 18:59:28 +04:00
|
|
|
aIsHorizontal = true;
|
2016-08-26 10:18:41 +03:00
|
|
|
} else {
|
2011-10-17 18:59:28 +04:00
|
|
|
aIsHorizontal = false;
|
2016-08-26 10:18:41 +03:00
|
|
|
}
|
2000-02-14 04:42:09 +03:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
void nsBoxFrame::GetInitialDirection(bool& aIsNormal) {
|
2007-05-23 07:48:43 +04:00
|
|
|
if (!GetContent()) return;
|
2001-08-15 08:09:41 +04:00
|
|
|
|
2016-04-21 07:28:34 +03:00
|
|
|
if (IsXULHorizontal()) {
|
2001-08-15 08:09:41 +04:00
|
|
|
// For horizontal boxes only, we initialize our value based off the CSS
|
|
|
|
// 'direction' property. This means that BiDI users will end up with
|
|
|
|
// horizontally inverted chrome.
|
2013-02-17 01:51:02 +04:00
|
|
|
aIsNormal = (StyleVisibility()->mDirection ==
|
|
|
|
NS_STYLE_DIRECTION_LTR); // If text runs RTL then so do we.
|
2019-11-16 02:03:40 +03:00
|
|
|
if (GetContent()->IsElement()) {
|
|
|
|
Element* element = GetContent()->AsElement();
|
|
|
|
|
|
|
|
// Now see if we have an attribute. The attribute overrides
|
|
|
|
// the style system 'direction' property.
|
|
|
|
static Element::AttrValuesArray strings[] = {nsGkAtoms::ltr,
|
|
|
|
nsGkAtoms::rtl, nullptr};
|
|
|
|
int32_t index = element->FindAttrValueIn(
|
|
|
|
kNameSpaceID_None, nsGkAtoms::dir, strings, eCaseMatters);
|
|
|
|
if (index >= 0) {
|
|
|
|
bool values[] = {true, false};
|
|
|
|
aIsNormal = values[index];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2011-10-17 18:59:28 +04:00
|
|
|
aIsNormal = true; // Assume a normal direction in the vertical case.
|
2019-11-16 02:03:40 +03:00
|
|
|
}
|
2001-08-15 08:09:41 +04:00
|
|
|
|
|
|
|
// Now check the style system to see if we should invert aIsNormal.
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStyleXUL* boxInfo = StyleXUL();
|
2016-08-26 10:17:09 +03:00
|
|
|
if (boxInfo->mBoxDirection == StyleBoxDirection::Reverse) {
|
2001-08-15 08:09:41 +04:00
|
|
|
aIsNormal = !aIsNormal; // Invert our direction.
|
2016-08-26 10:17:09 +03:00
|
|
|
}
|
2001-08-15 08:09:41 +04:00
|
|
|
}
|
|
|
|
|
2000-06-23 09:15:04 +04:00
|
|
|
/* Returns true if it was set.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool nsBoxFrame::GetInitialEqualSize(bool& aEqualSize) {
|
2000-06-23 09:15:04 +04:00
|
|
|
// see if we are a vertical or horizontal box.
|
2017-12-07 21:13:50 +03:00
|
|
|
if (!GetContent() || !GetContent()->IsElement()) return false;
|
2007-05-23 07:48:43 +04:00
|
|
|
|
2017-12-07 21:13:50 +03:00
|
|
|
if (GetContent()->AsElement()->AttrValueIs(kNameSpaceID_None,
|
|
|
|
nsGkAtoms::equalsize,
|
|
|
|
nsGkAtoms::always, eCaseMatters)) {
|
2011-10-17 18:59:28 +04:00
|
|
|
aEqualSize = true;
|
|
|
|
return true;
|
2007-05-23 07:48:43 +04:00
|
|
|
}
|
2000-06-23 09:15:04 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2000-06-23 09:15:04 +04:00
|
|
|
}
|
|
|
|
|
2000-02-14 04:42:09 +03:00
|
|
|
/* Returns true if it was set.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool nsBoxFrame::GetInitialAutoStretch(bool& aStretch) {
|
2007-05-23 07:48:43 +04:00
|
|
|
if (!GetContent()) return false;
|
2017-07-06 15:00:35 +03:00
|
|
|
|
107642 - XUL syntax/cleanup landing. Fixes 94470, 96008, 96019, 76800, 102637, 80399, 108303, and removes over a thousand unnecessary or nonsensical attributes. Also fixes 108302, 102366, 102367, 105815. r=sspitzer,cmanske on appropriate parts sr=ben
2001-11-03 07:17:02 +03:00
|
|
|
// Check the CSS box-align property.
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStyleXUL* boxInfo = StyleXUL();
|
2016-08-26 10:09:19 +03:00
|
|
|
aStretch = (boxInfo->mBoxAlign == StyleBoxAlign::Stretch);
|
2001-08-02 04:09:27 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
1999-11-19 00:05:43 +03:00
|
|
|
}
|
1999-07-02 09:28:32 +04:00
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
void nsBoxFrame::DidReflow(nsPresContext* aPresContext,
|
2017-12-14 18:21:49 +03:00
|
|
|
const ReflowInput* aReflowInput) {
|
2003-06-02 00:03:13 +04:00
|
|
|
nsFrameState preserveBits =
|
|
|
|
mState & (NS_FRAME_IS_DIRTY | NS_FRAME_HAS_DIRTY_CHILDREN);
|
2017-12-14 18:21:49 +03:00
|
|
|
nsFrame::DidReflow(aPresContext, aReflowInput);
|
2017-08-24 14:09:42 +03:00
|
|
|
AddStateBits(preserveBits);
|
2019-07-02 00:56:43 +03:00
|
|
|
if (preserveBits & NS_FRAME_IS_DIRTY) {
|
|
|
|
this->MarkSubtreeDirty();
|
|
|
|
}
|
1999-09-10 04:57:01 +04:00
|
|
|
}
|
|
|
|
|
2007-10-12 22:37:51 +04:00
|
|
|
bool nsBoxFrame::HonorPrintBackgroundSettings() {
|
2017-12-07 21:13:50 +03:00
|
|
|
return !mContent->IsInNativeAnonymousSubtree() &&
|
2007-10-12 22:37:51 +04:00
|
|
|
nsContainerFrame::HonorPrintBackgroundSettings();
|
|
|
|
}
|
|
|
|
|
2000-08-23 15:02:19 +04:00
|
|
|
#ifdef DO_NOISY_REFLOW
|
|
|
|
static int myCounter = 0;
|
2017-07-06 15:00:35 +03:00
|
|
|
static void printSize(char* aDesc, nscoord aSize) {
|
2000-10-29 02:17:53 +04:00
|
|
|
printf(" %s: ", aDesc);
|
2000-08-23 15:02:19 +04:00
|
|
|
if (aSize == NS_UNCONSTRAINEDSIZE) {
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("UC");
|
2000-08-23 15:02:19 +04:00
|
|
|
} else {
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("%d", aSize);
|
2000-08-23 15:02:19 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-02-26 01:09:24 +03:00
|
|
|
/* virtual */
|
|
|
|
nscoord nsBoxFrame::GetMinISize(gfxContext* aRenderingContext) {
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
nscoord result;
|
2018-09-12 15:35:47 +03:00
|
|
|
DISPLAY_MIN_INLINE_SIZE(this, result);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
2007-03-31 01:11:41 +04:00
|
|
|
nsBoxLayoutState state(PresContext(), aRenderingContext);
|
2016-04-21 07:28:31 +03:00
|
|
|
nsSize minSize = GetXULMinSize(state);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
2016-04-21 07:28:31 +03:00
|
|
|
// GetXULMinSize returns border-box width, and we want to return content
|
2019-04-11 23:27:37 +03:00
|
|
|
// width. Since Reflow uses the reflow input's border and padding, we
|
2016-04-21 07:28:31 +03:00
|
|
|
// actually just want to subtract what GetXULMinSize added, which is the
|
2016-04-21 07:28:32 +03:00
|
|
|
// result of GetXULBorderAndPadding.
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
nsMargin bp;
|
2016-04-21 07:28:32 +03:00
|
|
|
GetXULBorderAndPadding(bp);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
|
|
|
result = minSize.width - bp.LeftRight();
|
2013-01-15 16:22:03 +04:00
|
|
|
result = std::max(result, 0);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2019-02-26 01:09:24 +03:00
|
|
|
/* virtual */
|
|
|
|
nscoord nsBoxFrame::GetPrefISize(gfxContext* aRenderingContext) {
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
nscoord result;
|
2018-09-12 15:35:47 +03:00
|
|
|
DISPLAY_PREF_INLINE_SIZE(this, result);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
2007-03-31 01:11:41 +04:00
|
|
|
nsBoxLayoutState state(PresContext(), aRenderingContext);
|
2016-04-21 07:28:31 +03:00
|
|
|
nsSize prefSize = GetXULPrefSize(state);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
2016-04-21 07:28:31 +03:00
|
|
|
// GetXULPrefSize returns border-box width, and we want to return content
|
2019-04-11 23:27:37 +03:00
|
|
|
// width. Since Reflow uses the reflow input's border and padding, we
|
2016-04-21 07:28:31 +03:00
|
|
|
// actually just want to subtract what GetXULPrefSize added, which is the
|
2016-04-21 07:28:32 +03:00
|
|
|
// result of GetXULBorderAndPadding.
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
nsMargin bp;
|
2016-04-21 07:28:32 +03:00
|
|
|
GetXULBorderAndPadding(bp);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
|
|
|
result = prefSize.width - bp.LeftRight();
|
2013-01-15 16:22:03 +04:00
|
|
|
result = std::max(result, 0);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
|
|
|
return result;
|
2002-01-23 05:53:02 +03:00
|
|
|
}
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
void nsBoxFrame::Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,
|
2016-07-21 13:36:39 +03:00
|
|
|
const ReflowInput& aReflowInput,
|
2002-05-29 02:50:43 +04:00
|
|
|
nsReflowStatus& aStatus) {
|
2015-03-30 01:38:40 +03:00
|
|
|
MarkInReflow();
|
2002-02-14 03:08:08 +03:00
|
|
|
// If you make changes to this method, please keep nsLeafBoxFrame::Reflow
|
|
|
|
// in sync, if the changes are applicable there.
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsBoxFrame");
|
2016-07-21 13:36:39 +03:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowInput, aDesiredSize, aStatus);
|
2017-09-13 13:00:25 +03:00
|
|
|
MOZ_ASSERT(aStatus.IsEmpty(), "Caller should pass a fresh reflow status!");
|
1999-03-27 04:35:55 +03:00
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
NS_ASSERTION(
|
|
|
|
aReflowInput.ComputedWidth() >= 0 && aReflowInput.ComputedHeight() >= 0,
|
|
|
|
"Computed Size < 0");
|
1999-04-13 01:48:21 +04:00
|
|
|
|
2000-08-23 15:02:19 +04:00
|
|
|
#ifdef DO_NOISY_REFLOW
|
2000-10-29 02:17:53 +04:00
|
|
|
printf(
|
|
|
|
"\n-------------Starting BoxFrame Reflow ----------------------------\n");
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
printf("%p ** nsBF::Reflow %d ", this, myCounter++);
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
printSize("AW", aReflowInput.AvailableWidth());
|
|
|
|
printSize("AH", aReflowInput.AvailableHeight());
|
|
|
|
printSize("CW", aReflowInput.ComputedWidth());
|
|
|
|
printSize("CH", aReflowInput.ComputedHeight());
|
2000-08-23 15:02:19 +04:00
|
|
|
|
2000-10-29 02:17:53 +04:00
|
|
|
printf(" *\n");
|
2000-08-23 15:02:19 +04:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
// create the layout state
|
2016-07-21 13:36:39 +03:00
|
|
|
nsBoxLayoutState state(aPresContext, aReflowInput.mRenderingContext,
|
|
|
|
&aReflowInput, aReflowInput.mReflowDepth);
|
1999-04-13 01:48:21 +04:00
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
WritingMode wm = aReflowInput.GetWritingMode();
|
2018-09-27 00:44:18 +03:00
|
|
|
LogicalSize computedSize = aReflowInput.ComputedSize();
|
1999-09-14 00:24:20 +04:00
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
LogicalMargin m = aReflowInput.ComputedLogicalBorderPadding();
|
2016-04-21 07:28:32 +03:00
|
|
|
// GetXULBorderAndPadding(m);
|
1999-08-31 02:32:25 +04:00
|
|
|
|
2014-07-24 12:30:07 +04:00
|
|
|
LogicalSize prefSize(wm);
|
1999-09-14 00:24:20 +04:00
|
|
|
|
2007-01-08 05:57:59 +03:00
|
|
|
// if we are told to layout intrinsic then get our preferred size.
|
2019-06-05 02:41:20 +03:00
|
|
|
NS_ASSERTION(computedSize.ISize(wm) != NS_UNCONSTRAINEDSIZE,
|
2014-07-24 12:30:07 +04:00
|
|
|
"computed inline size should always be computed");
|
2019-06-05 02:41:20 +03:00
|
|
|
if (computedSize.BSize(wm) == NS_UNCONSTRAINEDSIZE) {
|
2016-04-21 07:28:31 +03:00
|
|
|
nsSize physicalPrefSize = GetXULPrefSize(state);
|
2016-04-21 07:28:31 +03:00
|
|
|
nsSize minSize = GetXULMinSize(state);
|
2016-04-21 07:28:31 +03:00
|
|
|
nsSize maxSize = GetXULMaxSize(state);
|
2016-04-21 07:28:31 +03:00
|
|
|
// XXXbz isn't GetXULPrefSize supposed to bounds-check for us?
|
2014-07-24 12:30:07 +04:00
|
|
|
physicalPrefSize = BoundsCheck(minSize, physicalPrefSize, maxSize);
|
|
|
|
prefSize = LogicalSize(wm, physicalPrefSize);
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
// get our desiredSize
|
2014-07-24 12:30:07 +04:00
|
|
|
computedSize.ISize(wm) += m.IStart(wm) + m.IEnd(wm);
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
|
2019-06-05 02:41:20 +03:00
|
|
|
if (aReflowInput.ComputedBSize() == NS_UNCONSTRAINEDSIZE) {
|
2014-07-24 12:30:07 +04:00
|
|
|
computedSize.BSize(wm) = prefSize.BSize(wm);
|
2012-09-12 02:20:51 +04:00
|
|
|
// prefSize is border-box but min/max constraints are content-box.
|
2014-07-24 12:30:07 +04:00
|
|
|
nscoord blockDirBorderPadding =
|
2016-07-21 13:36:39 +03:00
|
|
|
aReflowInput.ComputedLogicalBorderPadding().BStartEnd(wm);
|
2014-07-24 12:30:07 +04:00
|
|
|
nscoord contentBSize = computedSize.BSize(wm) - blockDirBorderPadding;
|
2012-09-12 02:20:51 +04:00
|
|
|
// Note: contentHeight might be negative, but that's OK because min-height
|
|
|
|
// is never negative.
|
2016-07-21 13:36:39 +03:00
|
|
|
computedSize.BSize(wm) =
|
|
|
|
aReflowInput.ApplyMinMaxHeight(contentBSize) + blockDirBorderPadding;
|
2000-08-18 00:08:44 +04:00
|
|
|
} else {
|
2014-07-24 12:30:07 +04:00
|
|
|
computedSize.BSize(wm) += m.BStart(wm) + m.BEnd(wm);
|
2000-08-18 00:08:44 +04:00
|
|
|
}
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
|
2014-07-24 12:30:07 +04:00
|
|
|
nsSize physicalSize = computedSize.GetPhysicalSize(wm);
|
|
|
|
nsRect r(mRect.x, mRect.y, physicalSize.width, physicalSize.height);
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
|
2016-04-21 07:28:32 +03:00
|
|
|
SetXULBounds(state, r);
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
// layout our children
|
2016-04-21 07:28:32 +03:00
|
|
|
XULLayout(state);
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
// ok our child could have gotten bigger. So lets get its bounds
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
// get the ascent
|
2014-07-24 12:30:07 +04:00
|
|
|
LogicalSize boxSize = GetLogicalSize(wm);
|
|
|
|
nscoord ascent = boxSize.BSize(wm);
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
// getting the ascent could be a lot of work. Don't get it if
|
|
|
|
// we are the root. The viewport doesn't care about it.
|
2002-01-23 05:53:02 +03:00
|
|
|
if (!(mState & NS_STATE_IS_ROOT)) {
|
2016-04-21 07:28:32 +03:00
|
|
|
ascent = GetXULBoxAscent(state);
|
2002-01-23 05:53:02 +03:00
|
|
|
}
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
|
2014-07-24 12:30:07 +04:00
|
|
|
aDesiredSize.SetSize(wm, boxSize);
|
2014-06-11 13:45:31 +04:00
|
|
|
aDesiredSize.SetBlockStartAscent(ascent);
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
|
2010-10-07 08:25:46 +04:00
|
|
|
aDesiredSize.mOverflowAreas = GetOverflowAreas();
|
2004-07-16 20:56:21 +04:00
|
|
|
|
2000-08-23 15:02:19 +04:00
|
|
|
#ifdef DO_NOISY_REFLOW
|
|
|
|
{
|
2013-12-27 21:59:52 +04:00
|
|
|
printf("%p ** nsBF(done) W:%d H:%d ", this, aDesiredSize.Width(),
|
|
|
|
aDesiredSize.Height());
|
2000-08-23 15:02:19 +04:00
|
|
|
|
|
|
|
if (maxElementSize) {
|
2017-07-06 15:00:35 +03:00
|
|
|
printf("MW:%d\n", *maxElementWidth);
|
2000-08-23 15:02:19 +04:00
|
|
|
} else {
|
2017-07-06 15:00:35 +03:00
|
|
|
printf("MW:?\n");
|
2000-08-23 15:02:19 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2000-04-05 04:19:00 +04:00
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
ReflowAbsoluteFrames(aPresContext, aDesiredSize, aReflowInput, aStatus);
|
2012-03-11 02:49:10 +04:00
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aDesiredSize);
|
1999-04-13 01:48:21 +04:00
|
|
|
}
|
|
|
|
|
2016-04-21 07:28:31 +03:00
|
|
|
nsSize nsBoxFrame::GetXULPrefSize(nsBoxLayoutState& aBoxLayoutState) {
|
2007-04-30 02:24:59 +04:00
|
|
|
NS_ASSERTION(aBoxLayoutState.GetRenderingContext(),
|
|
|
|
"must have rendering context");
|
|
|
|
|
2007-01-08 05:57:59 +03:00
|
|
|
nsSize size(0, 0);
|
|
|
|
DISPLAY_PREF_SIZE(this, size);
|
2000-06-06 05:25:03 +04:00
|
|
|
if (!DoesNeedRecalc(mPrefSize)) {
|
2018-03-24 16:17:33 +03:00
|
|
|
size = mPrefSize;
|
|
|
|
return size;
|
2000-02-25 07:18:34 +03:00
|
|
|
}
|
|
|
|
|
2016-04-21 07:28:32 +03:00
|
|
|
if (IsXULCollapsed()) return size;
|
2004-09-28 22:37:50 +04:00
|
|
|
|
|
|
|
// if the size was not completely redefined in CSS then ask our children
|
2011-09-29 10:19:26 +04:00
|
|
|
bool widthSet, heightSet;
|
2016-04-21 07:28:34 +03:00
|
|
|
if (!nsIFrame::AddXULPrefSize(this, size, widthSet, heightSet)) {
|
2004-09-28 22:37:50 +04:00
|
|
|
if (mLayoutManager) {
|
2016-04-21 07:28:31 +03:00
|
|
|
nsSize layoutSize = mLayoutManager->GetXULPrefSize(this, aBoxLayoutState);
|
2010-03-18 22:58:15 +03:00
|
|
|
if (!widthSet) size.width = layoutSize.width;
|
|
|
|
if (!heightSet) size.height = layoutSize.height;
|
|
|
|
} else {
|
2016-04-21 07:28:31 +03:00
|
|
|
size = nsBox::GetXULPrefSize(aBoxLayoutState);
|
2010-03-18 22:58:15 +03:00
|
|
|
}
|
2004-09-28 22:37:50 +04:00
|
|
|
}
|
|
|
|
|
2016-04-21 07:28:31 +03:00
|
|
|
nsSize minSize = GetXULMinSize(aBoxLayoutState);
|
2016-04-21 07:28:31 +03:00
|
|
|
nsSize maxSize = GetXULMaxSize(aBoxLayoutState);
|
2008-01-05 08:49:44 +03:00
|
|
|
mPrefSize = BoundsCheck(minSize, size, maxSize);
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2008-01-05 08:49:44 +03:00
|
|
|
return mPrefSize;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
1999-10-22 00:17:51 +04:00
|
|
|
|
2016-04-21 07:28:32 +03:00
|
|
|
nscoord nsBoxFrame::GetXULBoxAscent(nsBoxLayoutState& aBoxLayoutState) {
|
2007-01-31 19:02:42 +03:00
|
|
|
if (!DoesNeedRecalc(mAscent)) return mAscent;
|
1999-07-24 03:30:17 +04:00
|
|
|
|
2016-04-21 07:28:32 +03:00
|
|
|
if (IsXULCollapsed()) return 0;
|
2004-09-28 22:37:50 +04:00
|
|
|
|
|
|
|
if (mLayoutManager)
|
2008-01-09 10:28:39 +03:00
|
|
|
mAscent = mLayoutManager->GetAscent(this, aBoxLayoutState);
|
2004-09-28 22:37:50 +04:00
|
|
|
else
|
2016-04-21 07:28:32 +03:00
|
|
|
mAscent = nsBox::GetXULBoxAscent(aBoxLayoutState);
|
2004-09-28 22:37:50 +04:00
|
|
|
|
2007-01-31 19:02:42 +03:00
|
|
|
return mAscent;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
1999-07-24 03:30:17 +04:00
|
|
|
|
2016-04-21 07:28:31 +03:00
|
|
|
nsSize nsBoxFrame::GetXULMinSize(nsBoxLayoutState& aBoxLayoutState) {
|
2007-04-30 02:24:59 +04:00
|
|
|
NS_ASSERTION(aBoxLayoutState.GetRenderingContext(),
|
|
|
|
"must have rendering context");
|
|
|
|
|
2007-01-08 05:57:59 +03:00
|
|
|
nsSize size(0, 0);
|
|
|
|
DISPLAY_MIN_SIZE(this, size);
|
2000-06-06 05:25:03 +04:00
|
|
|
if (!DoesNeedRecalc(mMinSize)) {
|
2018-03-24 16:17:33 +03:00
|
|
|
size = mMinSize;
|
|
|
|
return size;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
1999-07-24 03:30:17 +04:00
|
|
|
|
2016-04-21 07:28:32 +03:00
|
|
|
if (IsXULCollapsed()) return size;
|
2004-09-28 22:37:50 +04:00
|
|
|
|
|
|
|
// if the size was not completely redefined in CSS then ask our children
|
2011-09-29 10:19:26 +04:00
|
|
|
bool widthSet, heightSet;
|
2016-04-21 07:28:34 +03:00
|
|
|
if (!nsIFrame::AddXULMinSize(aBoxLayoutState, this, size, widthSet,
|
|
|
|
heightSet)) {
|
2004-09-28 22:37:50 +04:00
|
|
|
if (mLayoutManager) {
|
2016-04-21 07:28:31 +03:00
|
|
|
nsSize layoutSize = mLayoutManager->GetXULMinSize(this, aBoxLayoutState);
|
2010-03-18 22:58:15 +03:00
|
|
|
if (!widthSet) size.width = layoutSize.width;
|
|
|
|
if (!heightSet) size.height = layoutSize.height;
|
|
|
|
} else {
|
2016-04-21 07:28:31 +03:00
|
|
|
size = nsBox::GetXULMinSize(aBoxLayoutState);
|
2004-09-28 22:37:50 +04:00
|
|
|
}
|
|
|
|
}
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2007-01-08 05:57:59 +03:00
|
|
|
mMinSize = size;
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
|
2007-01-08 05:57:59 +03:00
|
|
|
return size;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
1999-07-24 03:30:17 +04:00
|
|
|
|
2016-04-21 07:28:31 +03:00
|
|
|
nsSize nsBoxFrame::GetXULMaxSize(nsBoxLayoutState& aBoxLayoutState) {
|
2007-04-30 02:24:59 +04:00
|
|
|
NS_ASSERTION(aBoxLayoutState.GetRenderingContext(),
|
|
|
|
"must have rendering context");
|
|
|
|
|
2019-06-05 02:41:20 +03:00
|
|
|
nsSize size(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
|
2007-01-08 05:57:59 +03:00
|
|
|
DISPLAY_MAX_SIZE(this, size);
|
2000-06-06 05:25:03 +04:00
|
|
|
if (!DoesNeedRecalc(mMaxSize)) {
|
2018-03-24 16:17:33 +03:00
|
|
|
size = mMaxSize;
|
|
|
|
return size;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
1999-07-24 03:30:17 +04:00
|
|
|
|
2016-04-21 07:28:32 +03:00
|
|
|
if (IsXULCollapsed()) return size;
|
2004-09-28 22:37:50 +04:00
|
|
|
|
|
|
|
// if the size was not completely redefined in CSS then ask our children
|
2011-09-29 10:19:26 +04:00
|
|
|
bool widthSet, heightSet;
|
2016-04-21 07:28:34 +03:00
|
|
|
if (!nsIFrame::AddXULMaxSize(this, size, widthSet, heightSet)) {
|
2004-09-28 22:37:50 +04:00
|
|
|
if (mLayoutManager) {
|
2016-04-21 07:28:31 +03:00
|
|
|
nsSize layoutSize = mLayoutManager->GetXULMaxSize(this, aBoxLayoutState);
|
2010-03-18 22:58:15 +03:00
|
|
|
if (!widthSet) size.width = layoutSize.width;
|
|
|
|
if (!heightSet) size.height = layoutSize.height;
|
|
|
|
} else {
|
2016-04-21 07:28:31 +03:00
|
|
|
size = nsBox::GetXULMaxSize(aBoxLayoutState);
|
2004-09-28 22:37:50 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-08 05:57:59 +03:00
|
|
|
mMaxSize = size;
|
2000-03-02 06:01:30 +03:00
|
|
|
|
2007-01-08 05:57:59 +03:00
|
|
|
return size;
|
1999-03-27 04:35:55 +03:00
|
|
|
}
|
|
|
|
|
2016-04-21 07:28:31 +03:00
|
|
|
nscoord nsBoxFrame::GetXULFlex() {
|
2007-01-31 19:02:42 +03:00
|
|
|
if (!DoesNeedRecalc(mFlex)) return mFlex;
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
|
2016-04-21 07:28:31 +03:00
|
|
|
mFlex = nsBox::GetXULFlex();
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
|
2007-01-31 19:02:42 +03:00
|
|
|
return mFlex;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
|
2000-07-08 02:24:06 +04:00
|
|
|
/**
|
2017-07-06 15:00:35 +03:00
|
|
|
* If subclassing please subclass this method not layout.
|
2000-07-08 02:24:06 +04:00
|
|
|
* layout will call this method.
|
|
|
|
*/
|
|
|
|
NS_IMETHODIMP
|
2016-04-21 07:28:35 +03:00
|
|
|
nsBoxFrame::DoXULLayout(nsBoxLayoutState& aState) {
|
2019-08-08 22:48:19 +03:00
|
|
|
ReflowChildFlags oldFlags = aState.LayoutFlags();
|
|
|
|
aState.SetLayoutFlags(ReflowChildFlags::Default);
|
2004-09-28 22:37:50 +04:00
|
|
|
|
|
|
|
nsresult rv = NS_OK;
|
2009-10-22 04:11:25 +04:00
|
|
|
if (mLayoutManager) {
|
|
|
|
CoordNeedsRecalc(mAscent);
|
2016-04-21 07:28:32 +03:00
|
|
|
rv = mLayoutManager->XULLayout(this, aState);
|
2009-10-22 04:11:25 +04:00
|
|
|
}
|
2004-09-28 22:37:50 +04:00
|
|
|
|
|
|
|
aState.SetLayoutFlags(oldFlags);
|
|
|
|
|
2012-03-11 02:49:10 +04:00
|
|
|
if (HasAbsolutelyPositionedChildren()) {
|
2016-07-21 13:36:39 +03:00
|
|
|
// Set up a |reflowInput| to pass into ReflowAbsoluteFrames
|
2014-07-24 12:28:46 +04:00
|
|
|
WritingMode wm = GetWritingMode();
|
2016-07-21 13:36:39 +03:00
|
|
|
ReflowInput reflowInput(
|
2012-03-11 02:49:10 +04:00
|
|
|
aState.PresContext(), this, aState.GetRenderingContext(),
|
2014-07-24 12:28:46 +04:00
|
|
|
LogicalSize(wm, GetLogicalSize().ISize(wm), NS_UNCONSTRAINEDSIZE));
|
2012-03-11 02:49:10 +04:00
|
|
|
|
|
|
|
// Set up a |desiredSize| to pass into ReflowAbsoluteFrames
|
2016-07-21 13:36:39 +03:00
|
|
|
ReflowOutput desiredSize(reflowInput);
|
2013-12-27 21:59:52 +04:00
|
|
|
desiredSize.Width() = mRect.width;
|
|
|
|
desiredSize.Height() = mRect.height;
|
2012-03-11 02:49:10 +04:00
|
|
|
|
|
|
|
// get the ascent (cribbed from ::Reflow)
|
|
|
|
nscoord ascent = mRect.height;
|
|
|
|
|
|
|
|
// getting the ascent could be a lot of work. Don't get it if
|
|
|
|
// we are the root. The viewport doesn't care about it.
|
|
|
|
if (!(mState & NS_STATE_IS_ROOT)) {
|
2016-04-21 07:28:32 +03:00
|
|
|
ascent = GetXULBoxAscent(aState);
|
2012-03-11 02:49:10 +04:00
|
|
|
}
|
2014-06-11 13:45:31 +04:00
|
|
|
desiredSize.SetBlockStartAscent(ascent);
|
2012-03-11 02:49:10 +04:00
|
|
|
desiredSize.mOverflowAreas = GetOverflowAreas();
|
|
|
|
|
2014-01-04 01:08:50 +04:00
|
|
|
AddStateBits(NS_FRAME_IN_REFLOW);
|
2012-03-11 02:49:10 +04:00
|
|
|
// Set up a |reflowStatus| to pass into ReflowAbsoluteFrames
|
|
|
|
// (just a dummy value; hopefully that's OK)
|
2017-02-14 12:55:48 +03:00
|
|
|
nsReflowStatus reflowStatus;
|
2012-03-11 02:49:10 +04:00
|
|
|
ReflowAbsoluteFrames(aState.PresContext(), desiredSize, reflowInput,
|
2016-07-21 13:36:39 +03:00
|
|
|
reflowStatus);
|
2014-01-04 01:08:50 +04:00
|
|
|
RemoveStateBits(NS_FRAME_IN_REFLOW);
|
2012-03-11 02:49:10 +04:00
|
|
|
}
|
|
|
|
|
2004-09-28 22:37:50 +04:00
|
|
|
return rv;
|
2000-07-08 02:24:06 +04:00
|
|
|
}
|
|
|
|
|
2017-11-07 03:20:33 +03:00
|
|
|
void nsBoxFrame::DestroyFrom(nsIFrame* aDestructRoot,
|
|
|
|
PostDestroyData& aPostDestroyData) {
|
2002-02-21 16:39:39 +03:00
|
|
|
// unregister access key
|
2011-10-17 18:59:28 +04:00
|
|
|
RegUnregAccessKey(false);
|
2002-02-21 16:39:39 +03:00
|
|
|
|
2003-03-26 09:52:20 +03:00
|
|
|
// clean up the container box's layout manager and child boxes
|
2016-04-21 07:28:33 +03:00
|
|
|
SetXULLayoutManager(nullptr);
|
2000-04-18 04:17:00 +04:00
|
|
|
|
2017-11-07 03:20:33 +03:00
|
|
|
nsContainerFrame::DestroyFrom(aDestructRoot, aPostDestroyData);
|
2017-07-06 15:00:35 +03:00
|
|
|
}
|
2000-02-17 07:10:02 +03:00
|
|
|
|
2019-02-26 01:09:24 +03:00
|
|
|
/* virtual */
|
|
|
|
void nsBoxFrame::MarkIntrinsicISizesDirty() {
|
2002-10-10 10:39:30 +04:00
|
|
|
SizeNeedsRecalc(mPrefSize);
|
|
|
|
SizeNeedsRecalc(mMinSize);
|
|
|
|
SizeNeedsRecalc(mMaxSize);
|
|
|
|
CoordNeedsRecalc(mFlex);
|
|
|
|
CoordNeedsRecalc(mAscent);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
|
|
|
if (mLayoutManager) {
|
2007-03-31 01:11:41 +04:00
|
|
|
nsBoxLayoutState state(PresContext());
|
2014-07-24 21:03:26 +04:00
|
|
|
mLayoutManager->IntrinsicISizesDirty(this, state);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
}
|
|
|
|
|
2019-04-21 04:47:36 +03:00
|
|
|
nsContainerFrame::MarkIntrinsicISizesDirty();
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
|
2011-08-25 00:54:30 +04:00
|
|
|
void nsBoxFrame::RemoveFrame(ChildListID aListID, nsIFrame* aOldFrame) {
|
2018-04-28 22:50:58 +03:00
|
|
|
MOZ_ASSERT(aListID == kPrincipalList, "We don't support out-of-flow kids");
|
|
|
|
|
2007-03-31 01:11:41 +04:00
|
|
|
nsPresContext* presContext = PresContext();
|
2005-02-07 04:58:25 +03:00
|
|
|
nsBoxLayoutState state(presContext);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
|
|
|
// remove the child frame
|
2004-09-28 22:37:50 +04:00
|
|
|
mFrames.RemoveFrame(aOldFrame);
|
|
|
|
|
|
|
|
// notify the layout manager
|
|
|
|
if (mLayoutManager) mLayoutManager->ChildrenRemoved(this, state, aOldFrame);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2004-09-28 22:37:50 +04:00
|
|
|
// destroy the child frame
|
2006-04-10 04:16:29 +04:00
|
|
|
aOldFrame->Destroy();
|
2000-03-31 11:02:06 +04:00
|
|
|
|
|
|
|
// mark us dirty and generate a reflow command
|
2019-04-25 08:04:15 +03:00
|
|
|
PresShell()->FrameNeedsReflow(this, IntrinsicDirty::TreeChange,
|
2017-11-09 05:00:48 +03:00
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
2000-03-02 06:01:30 +03:00
|
|
|
}
|
|
|
|
|
2011-08-25 00:54:30 +04:00
|
|
|
void nsBoxFrame::InsertFrames(ChildListID aListID, nsIFrame* aPrevFrame,
|
2019-07-18 02:34:45 +03:00
|
|
|
const nsLineList::iterator* aPrevFrameLine,
|
2009-07-30 21:23:32 +04:00
|
|
|
nsFrameList& aFrameList) {
|
2006-06-29 06:32:36 +04:00
|
|
|
NS_ASSERTION(!aPrevFrame || aPrevFrame->GetParent() == this,
|
|
|
|
"inserting after sibling frame with different parent");
|
2007-10-20 09:43:38 +04:00
|
|
|
NS_ASSERTION(!aPrevFrame || mFrames.ContainsFrame(aPrevFrame),
|
|
|
|
"inserting after sibling frame not in our child list");
|
2009-07-30 21:23:32 +04:00
|
|
|
MOZ_ASSERT(aListID == kPrincipalList, "We don't support out-of-flow kids");
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2009-07-30 21:23:32 +04:00
|
|
|
nsBoxLayoutState state(PresContext());
|
1999-11-19 00:05:43 +03:00
|
|
|
|
2004-09-28 22:37:50 +04:00
|
|
|
// insert the child frames
|
2009-07-30 21:23:32 +04:00
|
|
|
const nsFrameList::Slice& newFrames =
|
|
|
|
mFrames.InsertFrames(this, aPrevFrame, aFrameList);
|
1999-05-10 01:46:24 +04:00
|
|
|
|
2011-08-25 00:54:30 +04:00
|
|
|
// notify the layout manager
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
if (mLayoutManager)
|
2011-08-25 00:54:30 +04:00
|
|
|
mLayoutManager->ChildrenInserted(this, state, aPrevFrame, newFrames);
|
2018-04-28 22:50:58 +03:00
|
|
|
|
2007-03-31 01:11:41 +04:00
|
|
|
// Make sure to check box order _after_ notifying the layout
|
2010-06-29 00:47:58 +04:00
|
|
|
// manager; otherwise the slice we give the layout manager will
|
2007-03-31 01:11:41 +04:00
|
|
|
// just be bogus. If the layout manager cares about the order, we
|
|
|
|
// just lose.
|
|
|
|
CheckBoxOrder();
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2019-04-25 08:04:15 +03:00
|
|
|
PresShell()->FrameNeedsReflow(this, IntrinsicDirty::TreeChange,
|
2017-11-09 05:00:48 +03:00
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
1999-05-18 08:06:52 +04:00
|
|
|
|
2009-07-30 21:23:32 +04:00
|
|
|
void nsBoxFrame::AppendFrames(ChildListID aListID, nsFrameList& aFrameList) {
|
|
|
|
MOZ_ASSERT(aListID == kPrincipalList, "We don't support out-of-flow kids");
|
2004-09-28 22:37:50 +04:00
|
|
|
|
2009-07-30 21:23:32 +04:00
|
|
|
nsBoxLayoutState state(PresContext());
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2010-06-29 00:47:58 +04:00
|
|
|
// append the new frames
|
|
|
|
const nsFrameList::Slice& newFrames = mFrames.AppendFrames(this, aFrameList);
|
|
|
|
|
2004-09-28 22:37:50 +04:00
|
|
|
// notify the layout manager
|
2016-01-28 02:11:00 +03:00
|
|
|
if (mLayoutManager) mLayoutManager->ChildrenAppended(this, state, newFrames);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2010-06-29 00:47:58 +04:00
|
|
|
// Make sure to check box order _after_ notifying the layout
|
|
|
|
// manager; otherwise the slice we give the layout manager will
|
|
|
|
// just be bogus. If the layout manager cares about the order, we
|
|
|
|
// just lose.
|
2012-12-01 03:25:32 +04:00
|
|
|
CheckBoxOrder();
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2007-05-06 23:16:51 +04:00
|
|
|
// XXXbz why is this NS_FRAME_FIRST_REFLOW check here?
|
2006-01-09 07:01:09 +03:00
|
|
|
if (!(GetStateBits() & NS_FRAME_FIRST_REFLOW)) {
|
2019-04-25 08:04:15 +03:00
|
|
|
PresShell()->FrameNeedsReflow(this, IntrinsicDirty::TreeChange,
|
2017-11-09 05:00:48 +03:00
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
2006-01-09 07:01:09 +03:00
|
|
|
}
|
1999-05-10 01:46:24 +04:00
|
|
|
}
|
|
|
|
|
2019-02-26 01:09:24 +03:00
|
|
|
/* virtual */
|
|
|
|
nsContainerFrame* nsBoxFrame::GetContentInsertionFrame() {
|
2007-10-26 03:30:49 +04:00
|
|
|
if (GetStateBits() & NS_STATE_BOX_WRAPS_KIDS_IN_BLOCK)
|
2016-01-29 17:42:14 +03:00
|
|
|
return PrincipalChildList().FirstChild()->GetContentInsertionFrame();
|
2007-10-26 03:30:49 +04:00
|
|
|
return nsContainerFrame::GetContentInsertionFrame();
|
|
|
|
}
|
1999-03-27 04:35:55 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
nsresult nsBoxFrame::AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute,
|
|
|
|
int32_t aModType) {
|
2005-09-07 20:49:21 +04:00
|
|
|
nsresult rv =
|
|
|
|
nsContainerFrame::AttributeChanged(aNameSpaceID, aAttribute, aModType);
|
2003-07-12 01:16:12 +04:00
|
|
|
|
|
|
|
// Ignore 'width', 'height', 'screenX', 'screenY' and 'sizemode' on a
|
|
|
|
// <window>.
|
2019-10-18 00:25:53 +03:00
|
|
|
if (mContent->IsAnyOfXULElements(nsGkAtoms::window, nsGkAtoms::dialog) &&
|
2006-12-26 20:47:52 +03:00
|
|
|
(nsGkAtoms::width == aAttribute || nsGkAtoms::height == aAttribute ||
|
|
|
|
nsGkAtoms::screenX == aAttribute || nsGkAtoms::screenY == aAttribute ||
|
|
|
|
nsGkAtoms::sizemode == aAttribute)) {
|
2003-07-12 01:16:12 +04:00
|
|
|
return rv;
|
|
|
|
}
|
2002-02-21 16:39:39 +03:00
|
|
|
|
2006-12-26 20:47:52 +03:00
|
|
|
if (aAttribute == nsGkAtoms::width || aAttribute == nsGkAtoms::height ||
|
|
|
|
aAttribute == nsGkAtoms::align || aAttribute == nsGkAtoms::valign ||
|
|
|
|
aAttribute == nsGkAtoms::left || aAttribute == nsGkAtoms::top ||
|
2009-09-14 01:13:54 +04:00
|
|
|
aAttribute == nsGkAtoms::right || aAttribute == nsGkAtoms::bottom ||
|
2011-02-28 21:06:29 +03:00
|
|
|
aAttribute == nsGkAtoms::start || aAttribute == nsGkAtoms::end ||
|
2006-12-26 20:47:52 +03:00
|
|
|
aAttribute == nsGkAtoms::minwidth || aAttribute == nsGkAtoms::maxwidth ||
|
|
|
|
aAttribute == nsGkAtoms::minheight ||
|
|
|
|
aAttribute == nsGkAtoms::maxheight || aAttribute == nsGkAtoms::flex ||
|
|
|
|
aAttribute == nsGkAtoms::orient || aAttribute == nsGkAtoms::pack ||
|
2007-06-19 03:22:46 +04:00
|
|
|
aAttribute == nsGkAtoms::dir || aAttribute == nsGkAtoms::mousethrough ||
|
2006-12-26 20:47:52 +03:00
|
|
|
aAttribute == nsGkAtoms::equalsize) {
|
|
|
|
if (aAttribute == nsGkAtoms::align || aAttribute == nsGkAtoms::valign ||
|
|
|
|
aAttribute == nsGkAtoms::orient || aAttribute == nsGkAtoms::pack ||
|
|
|
|
aAttribute == nsGkAtoms::dir) {
|
2002-10-10 10:39:30 +04:00
|
|
|
mValign = nsBoxFrame::vAlign_Top;
|
|
|
|
mHalign = nsBoxFrame::hAlign_Left;
|
2002-02-21 16:39:39 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool orient = true;
|
2017-07-06 15:00:35 +03:00
|
|
|
GetInitialOrientation(orient);
|
2002-02-21 16:39:39 +03:00
|
|
|
if (orient)
|
2017-08-24 14:09:42 +03:00
|
|
|
AddStateBits(NS_STATE_IS_HORIZONTAL);
|
2002-02-21 16:39:39 +03:00
|
|
|
else
|
2017-08-24 12:55:28 +03:00
|
|
|
RemoveStateBits(NS_STATE_IS_HORIZONTAL);
|
1999-05-10 01:46:24 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool normal = true;
|
2002-02-21 16:39:39 +03:00
|
|
|
GetInitialDirection(normal);
|
|
|
|
if (normal)
|
2017-08-24 14:09:42 +03:00
|
|
|
AddStateBits(NS_STATE_IS_DIRECTION_NORMAL);
|
2002-02-21 16:39:39 +03:00
|
|
|
else
|
2017-08-24 12:55:28 +03:00
|
|
|
RemoveStateBits(NS_STATE_IS_DIRECTION_NORMAL);
|
2001-12-04 02:41:13 +03:00
|
|
|
|
2002-10-10 10:39:30 +04:00
|
|
|
GetInitialVAlignment(mValign);
|
|
|
|
GetInitialHAlignment(mHalign);
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool equalSize = false;
|
2017-07-06 15:00:35 +03:00
|
|
|
GetInitialEqualSize(equalSize);
|
2002-02-21 16:39:39 +03:00
|
|
|
if (equalSize)
|
2017-08-24 14:09:42 +03:00
|
|
|
AddStateBits(NS_STATE_EQUAL_SIZE);
|
2002-02-21 16:39:39 +03:00
|
|
|
else
|
2017-08-24 12:55:28 +03:00
|
|
|
RemoveStateBits(NS_STATE_EQUAL_SIZE);
|
1) implememted box reflow coelescing.
2) implemented gfx scrollbars for list boxes
3) fixed progess meter to be an animated gif
4) fixed bugs 23521, 24721, 19114, 20546, 24385, 24457, 23156, 20226, 22543
-r hyatt, troy, rod
2000-02-10 01:02:40 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool autostretch = !!(mState & NS_STATE_AUTO_STRETCH);
|
2002-02-21 16:39:39 +03:00
|
|
|
GetInitialAutoStretch(autostretch);
|
|
|
|
if (autostretch)
|
2017-08-24 14:09:42 +03:00
|
|
|
AddStateBits(NS_STATE_AUTO_STRETCH);
|
2002-02-21 16:39:39 +03:00
|
|
|
else
|
2017-08-24 12:55:28 +03:00
|
|
|
RemoveStateBits(NS_STATE_AUTO_STRETCH);
|
2006-12-26 20:47:52 +03:00
|
|
|
} else if (aAttribute == nsGkAtoms::left || aAttribute == nsGkAtoms::top ||
|
2009-09-14 01:13:54 +04:00
|
|
|
aAttribute == nsGkAtoms::right ||
|
2011-02-28 21:06:29 +03:00
|
|
|
aAttribute == nsGkAtoms::bottom ||
|
|
|
|
aAttribute == nsGkAtoms::start || aAttribute == nsGkAtoms::end) {
|
2017-08-24 12:55:28 +03:00
|
|
|
RemoveStateBits(NS_STATE_STACK_NOT_POSITIONED);
|
2007-06-19 03:22:46 +04:00
|
|
|
} else if (aAttribute == nsGkAtoms::mousethrough) {
|
|
|
|
UpdateMouseThrough();
|
|
|
|
}
|
2004-09-17 22:36:30 +04:00
|
|
|
|
2019-04-25 08:04:15 +03:00
|
|
|
PresShell()->FrameNeedsReflow(this, IntrinsicDirty::StyleChange,
|
2017-11-09 05:00:48 +03:00
|
|
|
NS_FRAME_IS_DIRTY);
|
2006-12-26 20:47:52 +03:00
|
|
|
} else if (aAttribute == nsGkAtoms::ordinal) {
|
2016-04-21 07:28:32 +03:00
|
|
|
nsIFrame* parent = GetParentXULBox(this);
|
2006-02-21 03:40:54 +03:00
|
|
|
// If our parent is not a box, there's not much we can do... but in that
|
|
|
|
// case our ordinal doesn't matter anyway, so that's ok.
|
2017-07-06 15:00:35 +03:00
|
|
|
// Also don't bother with popup frames since they are kept on the
|
2016-04-21 07:28:34 +03:00
|
|
|
// kPopupList and XULRelayoutChildAtOrdinal() only handles
|
2007-08-16 19:39:22 +04:00
|
|
|
// principal children.
|
|
|
|
if (parent && !(GetStateBits() & NS_FRAME_OUT_OF_FLOW) &&
|
2016-12-06 10:36:28 +03:00
|
|
|
StyleDisplay()->mDisplay != mozilla::StyleDisplay::MozPopup) {
|
2016-04-21 07:28:34 +03:00
|
|
|
parent->XULRelayoutChildAtOrdinal(this);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
// XXXldb Should this instead be a tree change on the child or parent?
|
2019-04-25 08:04:15 +03:00
|
|
|
PresShell()->FrameNeedsReflow(parent, IntrinsicDirty::StyleChange,
|
2017-11-09 05:00:48 +03:00
|
|
|
NS_FRAME_IS_DIRTY);
|
2006-02-21 03:40:54 +03:00
|
|
|
}
|
2002-02-21 16:39:39 +03:00
|
|
|
}
|
|
|
|
// If the accesskey changed, register for the new value
|
|
|
|
// The old value has been unregistered in nsXULElement::SetAttr
|
2006-12-26 20:47:52 +03:00
|
|
|
else if (aAttribute == nsGkAtoms::accesskey) {
|
2011-10-17 18:59:28 +04:00
|
|
|
RegUnregAccessKey(true);
|
2013-09-13 15:02:30 +04:00
|
|
|
} else if (aAttribute == nsGkAtoms::rows &&
|
2015-03-03 14:09:00 +03:00
|
|
|
mContent->IsXULElement(nsGkAtoms::tree)) {
|
2013-09-13 15:02:30 +04:00
|
|
|
// Reflow ourselves and all our children if "rows" changes, since
|
|
|
|
// nsTreeBodyFrame's layout reads this from its parent (this frame).
|
2019-04-25 08:04:15 +03:00
|
|
|
PresShell()->FrameNeedsReflow(this, IntrinsicDirty::StyleChange,
|
2017-11-09 05:00:48 +03:00
|
|
|
NS_FRAME_IS_DIRTY);
|
2013-09-13 15:02:30 +04:00
|
|
|
}
|
2001-12-04 02:41:13 +03:00
|
|
|
|
1999-03-27 04:35:55 +03:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
void nsBoxFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayListSet& aLists) {
|
2014-06-04 16:44:26 +04:00
|
|
|
bool forceLayer = false;
|
2019-03-22 21:28:42 +03:00
|
|
|
// We check the renderroot attribute here in nsBoxFrame for lack of a better
|
|
|
|
// place. This roughly mirrors the pre-existing "layer" attribute. In the
|
|
|
|
// long term we may want to add a specific element in which we can wrap
|
|
|
|
// alternate renderroot content, but we're electing to not go down that
|
|
|
|
// rabbit hole today.
|
|
|
|
wr::RenderRoot renderRoot =
|
|
|
|
gfxUtils::GetRenderRootForFrame(this).valueOr(wr::RenderRoot::Default);
|
2010-08-28 03:15:08 +04:00
|
|
|
|
2015-03-03 14:08:59 +03:00
|
|
|
if (GetContent()->IsXULElement()) {
|
2014-06-04 16:44:26 +04:00
|
|
|
// forcelayer is only supported on XUL elements with box layout
|
2017-12-07 21:13:50 +03:00
|
|
|
if (GetContent()->AsElement()->HasAttr(kNameSpaceID_None,
|
|
|
|
nsGkAtoms::layer)) {
|
2014-06-04 16:44:26 +04:00
|
|
|
forceLayer = true;
|
|
|
|
}
|
|
|
|
// Check for frames that are marked as a part of the region used
|
|
|
|
// in calculating glass margins on Windows.
|
|
|
|
const nsStyleDisplay* styles = StyleDisplay();
|
2018-07-25 16:03:45 +03:00
|
|
|
if (styles && styles->mAppearance == StyleAppearance::MozWinExcludeGlass) {
|
2014-10-29 02:33:52 +03:00
|
|
|
aBuilder->AddWindowExcludeGlassRegion(
|
2014-07-15 08:23:37 +04:00
|
|
|
this, nsRect(aBuilder->ToReferenceFrame(this), GetSize()));
|
2014-06-04 16:44:26 +04:00
|
|
|
}
|
2011-05-13 20:40:46 +04:00
|
|
|
}
|
|
|
|
|
2017-10-17 05:19:44 +03:00
|
|
|
nsDisplayListCollection tempLists(aBuilder);
|
2019-03-22 21:28:42 +03:00
|
|
|
const nsDisplayListSet& destination =
|
|
|
|
(forceLayer || renderRoot != wr::RenderRoot::Default) ? tempLists
|
|
|
|
: aLists;
|
2010-08-28 03:15:08 +04:00
|
|
|
|
2013-02-14 15:08:08 +04:00
|
|
|
DisplayBorderBackgroundOutline(aBuilder, destination);
|
2006-01-26 05:29:17 +03:00
|
|
|
|
2017-02-01 01:07:35 +03:00
|
|
|
Maybe<nsDisplayListBuilder::AutoContainerASRTracker> contASRTracker;
|
2019-03-22 21:28:42 +03:00
|
|
|
if (forceLayer || renderRoot != wr::RenderRoot::Default) {
|
2017-02-01 01:07:35 +03:00
|
|
|
contASRTracker.emplace(aBuilder);
|
|
|
|
}
|
|
|
|
|
2017-08-07 05:23:35 +03:00
|
|
|
BuildDisplayListForChildren(aBuilder, destination);
|
2000-09-01 04:59:09 +04:00
|
|
|
|
|
|
|
// see if we have to draw a selection frame around this container
|
2013-02-14 15:08:08 +04:00
|
|
|
DisplaySelectionOverlay(aBuilder, destination.Content());
|
2010-08-28 03:15:08 +04:00
|
|
|
|
2019-03-22 21:28:42 +03:00
|
|
|
if (forceLayer || renderRoot != wr::RenderRoot::Default) {
|
2010-08-28 03:15:08 +04:00
|
|
|
// This is a bit of a hack. Collect up all descendant display items
|
|
|
|
// and merge them into a single Content() list. This can cause us
|
|
|
|
// to violate CSS stacking order, but forceLayer is a magic
|
|
|
|
// XUL-only extension anyway.
|
2017-11-16 06:09:28 +03:00
|
|
|
nsDisplayList masterList;
|
2010-08-28 03:15:08 +04:00
|
|
|
masterList.AppendToTop(tempLists.BorderBackground());
|
|
|
|
masterList.AppendToTop(tempLists.BlockBorderBackgrounds());
|
|
|
|
masterList.AppendToTop(tempLists.Floats());
|
|
|
|
masterList.AppendToTop(tempLists.Content());
|
|
|
|
masterList.AppendToTop(tempLists.PositionedDescendants());
|
|
|
|
masterList.AppendToTop(tempLists.Outlines());
|
2017-02-01 01:07:35 +03:00
|
|
|
const ActiveScrolledRoot* ownLayerASR = contASRTracker->GetContainerASR();
|
|
|
|
DisplayListClipState::AutoSaveRestore ownLayerClipState(aBuilder);
|
|
|
|
|
2019-03-22 21:28:42 +03:00
|
|
|
if (forceLayer) {
|
|
|
|
MOZ_ASSERT(renderRoot == wr::RenderRoot::Default);
|
|
|
|
// Wrap the list to make it its own layer
|
2019-04-01 19:53:11 +03:00
|
|
|
aLists.Content()->AppendNewToTop<nsDisplayOwnLayer>(
|
2019-03-22 21:28:42 +03:00
|
|
|
aBuilder, this, &masterList, ownLayerASR,
|
2019-04-26 02:03:04 +03:00
|
|
|
nsDisplayOwnLayerFlags::None, mozilla::layers::ScrollbarData{}, true,
|
2019-10-01 00:01:20 +03:00
|
|
|
true, nsDisplayOwnLayer::OwnLayerForBoxFrame);
|
2019-03-22 21:28:42 +03:00
|
|
|
} else {
|
|
|
|
MOZ_ASSERT(!XRE_IsContentProcess());
|
2019-04-01 19:53:11 +03:00
|
|
|
aLists.Content()->AppendNewToTop<nsDisplayRenderRoot>(
|
|
|
|
aBuilder, this, &masterList, ownLayerASR, renderRoot);
|
2019-03-22 21:28:42 +03:00
|
|
|
}
|
2010-08-28 03:15:08 +04:00
|
|
|
}
|
2000-09-01 04:59:09 +04:00
|
|
|
}
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
void nsBoxFrame::BuildDisplayListForChildren(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayListSet& aLists) {
|
|
|
|
nsIFrame* kid = mFrames.FirstChild();
|
|
|
|
// Put each child's background onto the BlockBorderBackgrounds list
|
|
|
|
// to emulate the existing two-layer XUL painting scheme.
|
|
|
|
nsDisplayListSet set(aLists, aLists.BlockBorderBackgrounds());
|
|
|
|
// The children should be in the right order
|
|
|
|
while (kid) {
|
2017-08-07 05:23:35 +03:00
|
|
|
BuildDisplayListForChild(aBuilder, kid, set);
|
2006-01-26 05:29:17 +03:00
|
|
|
kid = kid->GetNextSibling();
|
2000-09-01 04:59:09 +04:00
|
|
|
}
|
1999-09-10 04:57:01 +04:00
|
|
|
}
|
|
|
|
|
2014-01-06 03:31:14 +04:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2001-11-14 04:33:42 +03:00
|
|
|
nsresult nsBoxFrame::GetFrameName(nsAString& aResult) const {
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("Box"), aResult);
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
2001-09-15 04:45:54 +04:00
|
|
|
#endif
|
1999-12-02 04:07:27 +03:00
|
|
|
|
2002-02-21 16:39:39 +03:00
|
|
|
// If you make changes to this function, check its counterparts
|
2008-12-29 18:07:38 +03:00
|
|
|
// in nsTextBoxFrame and nsXULLabelFrame
|
2011-09-29 10:19:26 +04:00
|
|
|
void nsBoxFrame::RegUnregAccessKey(bool aDoReg) {
|
2013-03-20 05:47:48 +04:00
|
|
|
MOZ_ASSERT(mContent);
|
2002-02-21 16:39:39 +03:00
|
|
|
|
|
|
|
// only support accesskeys for the following elements
|
2015-03-03 14:09:00 +03:00
|
|
|
if (!mContent->IsAnyOfXULElements(nsGkAtoms::button, nsGkAtoms::toolbarbutton,
|
2019-10-09 12:27:28 +03:00
|
|
|
nsGkAtoms::checkbox, nsGkAtoms::tab,
|
|
|
|
nsGkAtoms::radio)) {
|
2013-03-20 05:47:48 +04:00
|
|
|
return;
|
2002-02-21 16:39:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoString accessKey;
|
2017-12-07 21:13:50 +03:00
|
|
|
mContent->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::accesskey,
|
|
|
|
accessKey);
|
2002-02-21 16:39:39 +03:00
|
|
|
|
|
|
|
if (accessKey.IsEmpty()) return;
|
|
|
|
|
2017-07-06 15:00:35 +03:00
|
|
|
// With a valid PresContext we can get the ESM
|
2002-02-21 16:39:39 +03:00
|
|
|
// and register the access key
|
2014-04-01 08:09:23 +04:00
|
|
|
EventStateManager* esm = PresContext()->EventStateManager();
|
2002-02-21 16:39:39 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t key = accessKey.First();
|
2004-02-27 20:17:37 +03:00
|
|
|
if (aDoReg)
|
2017-12-07 21:13:50 +03:00
|
|
|
esm->RegisterAccessKey(mContent->AsElement(), key);
|
2004-02-27 20:17:37 +03:00
|
|
|
else
|
2017-12-07 21:13:50 +03:00
|
|
|
esm->UnregisterAccessKey(mContent->AsElement(), key);
|
2002-02-21 16:39:39 +03:00
|
|
|
}
|
|
|
|
|
2017-08-09 23:43:47 +03:00
|
|
|
void nsBoxFrame::AppendDirectlyOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult) {
|
|
|
|
if (GetStateBits() & NS_STATE_BOX_WRAPS_KIDS_IN_BLOCK) {
|
|
|
|
aResult.AppendElement(OwnedAnonBox(PrincipalChildList().FirstChild()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-01 03:25:33 +04:00
|
|
|
// Helper less-than-or-equal function, used in CheckBoxOrder() as a
|
|
|
|
// template-parameter for the sorting functions.
|
|
|
|
static bool IsBoxOrdinalLEQ(nsIFrame* aFrame1, nsIFrame* aFrame2) {
|
2013-06-01 09:14:03 +04:00
|
|
|
// If we've got a placeholder frame, use its out-of-flow frame's ordinal val.
|
|
|
|
nsIFrame* aRealFrame1 = nsPlaceholderFrame::GetRealFrameFor(aFrame1);
|
|
|
|
nsIFrame* aRealFrame2 = nsPlaceholderFrame::GetRealFrameFor(aFrame2);
|
2016-04-21 07:28:31 +03:00
|
|
|
return aRealFrame1->GetXULOrdinal() <= aRealFrame2->GetXULOrdinal();
|
2012-12-01 03:25:33 +04:00
|
|
|
}
|
|
|
|
|
2012-12-01 03:25:32 +04:00
|
|
|
void nsBoxFrame::CheckBoxOrder() {
|
2018-07-18 13:23:32 +03:00
|
|
|
if (!nsIFrame::IsFrameListSorted<IsBoxOrdinalLEQ>(mFrames)) {
|
2013-10-01 01:26:04 +04:00
|
|
|
nsIFrame::SortFrameList<IsBoxOrdinalLEQ>(mFrames);
|
2012-12-01 03:25:33 +04:00
|
|
|
}
|
|
|
|
}
|
2008-12-07 21:11:30 +03:00
|
|
|
|
2012-08-06 07:00:57 +04:00
|
|
|
nsresult nsBoxFrame::LayoutChildAt(nsBoxLayoutState& aState, nsIFrame* aBox,
|
|
|
|
const nsRect& aRect) {
|
2004-09-28 22:37:50 +04:00
|
|
|
// get the current rect
|
|
|
|
nsRect oldRect(aBox->GetRect());
|
2016-04-21 07:28:32 +03:00
|
|
|
aBox->SetXULBounds(aState, aRect);
|
2004-09-28 22:37:50 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool layout = NS_SUBTREE_DIRTY(aBox);
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2004-09-28 22:37:50 +04:00
|
|
|
if (layout ||
|
|
|
|
(oldRect.width != aRect.width || oldRect.height != aRect.height)) {
|
2016-04-21 07:28:32 +03:00
|
|
|
return aBox->XULLayout(aState);
|
2004-09-28 22:37:50 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2016-04-21 07:28:34 +03:00
|
|
|
nsresult nsBoxFrame::XULRelayoutChildAtOrdinal(nsIFrame* aChild) {
|
2019-08-21 21:35:31 +03:00
|
|
|
int32_t ord = aChild->GetXULOrdinal();
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2009-10-02 20:27:37 +04:00
|
|
|
nsIFrame* child = mFrames.FirstChild();
|
2012-07-30 18:20:58 +04:00
|
|
|
nsIFrame* newPrevSib = nullptr;
|
2004-09-30 04:18:49 +04:00
|
|
|
|
|
|
|
while (child) {
|
2016-04-21 07:28:31 +03:00
|
|
|
if (ord < child->GetXULOrdinal()) {
|
2009-10-02 20:27:37 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (child != aChild) {
|
2004-09-30 04:18:49 +04:00
|
|
|
newPrevSib = child;
|
2009-10-02 20:27:37 +04:00
|
|
|
}
|
2004-09-30 04:18:49 +04:00
|
|
|
|
2016-04-21 07:28:32 +03:00
|
|
|
child = GetNextXULBox(child);
|
2004-09-28 22:37:50 +04:00
|
|
|
}
|
2004-09-30 04:18:49 +04:00
|
|
|
|
2009-10-02 20:27:37 +04:00
|
|
|
if (aChild->GetPrevSibling() == newPrevSib) {
|
2004-09-30 04:18:49 +04:00
|
|
|
// This box is not moving.
|
|
|
|
return NS_OK;
|
2004-09-28 22:37:50 +04:00
|
|
|
}
|
2004-09-30 04:18:49 +04:00
|
|
|
|
2009-09-18 15:09:35 +04:00
|
|
|
// Take |aChild| out of its old position in the child list.
|
2009-10-02 20:27:37 +04:00
|
|
|
mFrames.RemoveFrame(aChild);
|
2004-09-28 22:37:50 +04:00
|
|
|
|
2009-09-18 15:09:35 +04:00
|
|
|
// Insert it after |newPrevSib| or at the start if it's null.
|
2012-07-30 18:20:58 +04:00
|
|
|
mFrames.InsertFrame(nullptr, newPrevSib, aChild);
|
2004-09-28 22:37:50 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
/**
|
|
|
|
* This wrapper class lets us redirect mouse hits from descendant frames
|
|
|
|
* of a menu to the menu itself, if they didn't specify 'allowevents'.
|
2017-07-06 15:00:35 +03:00
|
|
|
*
|
2006-01-26 05:29:17 +03:00
|
|
|
* The wrapper simply turns a hit on a descendant element
|
|
|
|
* into a hit on the menu itself, unless there is an element between the target
|
|
|
|
* and the menu with the "allowevents" attribute.
|
2017-07-06 15:00:35 +03:00
|
|
|
*
|
2006-01-26 05:29:17 +03:00
|
|
|
* This is used by nsMenuFrame and nsTreeColFrame.
|
2017-07-06 15:00:35 +03:00
|
|
|
*
|
2012-07-30 18:20:58 +04:00
|
|
|
* Note that turning a hit on a descendant element into nullptr, so events
|
2006-01-26 05:29:17 +03:00
|
|
|
* could fall through to the menu background, might be an appealing
|
|
|
|
* simplification but it would mean slightly strange behaviour in some cases,
|
|
|
|
* because grabber wrappers can be created for many individual lists and items,
|
|
|
|
* so the exact fallthrough behaviour would be complex. E.g. an element with
|
|
|
|
* "allowevents" on top of the Content() list could receive the event even if it
|
|
|
|
* was covered by a PositionedDescenants() element without "allowevents". It is
|
|
|
|
* best to never convert a non-null hit into null.
|
|
|
|
*/
|
|
|
|
// REVIEW: This is roughly of what nsMenuFrame::GetFrameForPoint used to do.
|
|
|
|
// I've made 'allowevents' affect child elements because that seems the only
|
|
|
|
// reasonable thing to do.
|
2017-05-02 04:50:16 +03:00
|
|
|
class nsDisplayXULEventRedirector final : public nsDisplayWrapList {
|
2006-01-26 05:29:17 +03:00
|
|
|
public:
|
2010-08-13 14:01:13 +04:00
|
|
|
nsDisplayXULEventRedirector(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
|
|
|
|
nsDisplayItem* aItem, nsIFrame* aTargetFrame)
|
|
|
|
: nsDisplayWrapList(aBuilder, aFrame, aItem),
|
|
|
|
mTargetFrame(aTargetFrame) {}
|
|
|
|
nsDisplayXULEventRedirector(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
|
|
|
|
nsDisplayList* aList, nsIFrame* aTargetFrame)
|
|
|
|
: nsDisplayWrapList(aBuilder, aFrame, aList),
|
|
|
|
mTargetFrame(aTargetFrame) {}
|
2010-04-08 04:31:26 +04:00
|
|
|
virtual void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
|
2014-02-24 18:41:56 +04:00
|
|
|
HitTestState* aState,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsTArray<nsIFrame*>* aOutFrames) override;
|
|
|
|
virtual bool ShouldFlattenAway(nsDisplayListBuilder* aBuilder) override {
|
2014-06-09 08:47:59 +04:00
|
|
|
return false;
|
|
|
|
}
|
2010-07-16 01:07:49 +04:00
|
|
|
NS_DISPLAY_DECL_NAME("XULEventRedirector", TYPE_XUL_EVENT_REDIRECTOR)
|
2006-01-26 05:29:17 +03:00
|
|
|
private:
|
|
|
|
nsIFrame* mTargetFrame;
|
|
|
|
};
|
|
|
|
|
2010-04-08 04:31:26 +04:00
|
|
|
void nsDisplayXULEventRedirector::HitTest(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aRect,
|
|
|
|
HitTestState* aState,
|
|
|
|
nsTArray<nsIFrame*>* aOutFrames) {
|
|
|
|
nsTArray<nsIFrame*> outFrames;
|
|
|
|
mList.HitTest(aBuilder, aRect, aState, &outFrames);
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool topMostAdded = false;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t localLength = outFrames.Length();
|
2010-04-08 04:31:26 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < localLength; i++) {
|
2010-04-08 04:31:26 +04:00
|
|
|
for (nsIContent* content = outFrames.ElementAt(i)->GetContent();
|
|
|
|
content && content != mTargetFrame->GetContent();
|
|
|
|
content = content->GetParent()) {
|
2017-12-07 21:13:50 +03:00
|
|
|
if (!content->IsElement() ||
|
|
|
|
!content->AsElement()->AttrValueIs(kNameSpaceID_None,
|
|
|
|
nsGkAtoms::allowevents,
|
|
|
|
nsGkAtoms::_true, eCaseMatters)) {
|
|
|
|
continue;
|
2010-04-08 04:31:26 +04:00
|
|
|
}
|
2017-12-07 21:13:50 +03:00
|
|
|
|
|
|
|
// Events are allowed on 'frame', so let it go.
|
|
|
|
aOutFrames->AppendElement(outFrames.ElementAt(i));
|
|
|
|
topMostAdded = true;
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
2010-04-08 04:31:26 +04:00
|
|
|
|
2010-05-01 20:39:00 +04:00
|
|
|
// If there was no hit on the topmost frame or its ancestors,
|
|
|
|
// add the target frame itself as the first candidate (see bug 562554).
|
|
|
|
if (!topMostAdded) {
|
2011-10-17 18:59:28 +04:00
|
|
|
topMostAdded = true;
|
2010-05-01 20:39:00 +04:00
|
|
|
aOutFrames->AppendElement(mTargetFrame);
|
|
|
|
}
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-02 04:50:16 +03:00
|
|
|
class nsXULEventRedirectorWrapper final : public nsDisplayWrapper {
|
2006-01-26 05:29:17 +03:00
|
|
|
public:
|
2014-09-01 07:36:37 +04:00
|
|
|
explicit nsXULEventRedirectorWrapper(nsIFrame* aTargetFrame)
|
2006-01-26 05:29:17 +03:00
|
|
|
: mTargetFrame(aTargetFrame) {}
|
|
|
|
virtual nsDisplayItem* WrapList(nsDisplayListBuilder* aBuilder,
|
2014-02-24 18:41:56 +04:00
|
|
|
nsIFrame* aFrame,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsDisplayList* aList) override {
|
2018-02-13 03:43:28 +03:00
|
|
|
return MakeDisplayItem<nsDisplayXULEventRedirector>(aBuilder, aFrame, aList,
|
|
|
|
mTargetFrame);
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
|
|
|
virtual nsDisplayItem* WrapItem(nsDisplayListBuilder* aBuilder,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsDisplayItem* aItem) override {
|
2018-02-13 03:43:28 +03:00
|
|
|
return MakeDisplayItem<nsDisplayXULEventRedirector>(
|
|
|
|
aBuilder, aItem->Frame(), aItem, mTargetFrame);
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
private:
|
|
|
|
nsIFrame* mTargetFrame;
|
|
|
|
};
|
|
|
|
|
|
|
|
void nsBoxFrame::WrapListsInRedirector(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayListSet& aIn,
|
|
|
|
const nsDisplayListSet& aOut) {
|
|
|
|
nsXULEventRedirectorWrapper wrapper(this);
|
2013-02-14 15:12:27 +04:00
|
|
|
wrapper.WrapLists(aBuilder, this, aIn, aOut);
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
2012-07-28 02:01:12 +04:00
|
|
|
|
2013-10-02 07:46:03 +04:00
|
|
|
bool nsBoxFrame::GetEventPoint(WidgetGUIEvent* aEvent, nsPoint& aPoint) {
|
2015-02-02 01:27:41 +03:00
|
|
|
LayoutDeviceIntPoint refPoint;
|
2012-07-28 02:01:12 +04:00
|
|
|
bool res = GetEventPoint(aEvent, refPoint);
|
2015-02-02 01:27:31 +03:00
|
|
|
aPoint = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, refPoint, this);
|
2012-07-28 02:01:12 +04:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2015-02-02 01:27:41 +03:00
|
|
|
bool nsBoxFrame::GetEventPoint(WidgetGUIEvent* aEvent,
|
|
|
|
LayoutDeviceIntPoint& aPoint) {
|
2012-07-28 02:01:12 +04:00
|
|
|
NS_ENSURE_TRUE(aEvent, false);
|
|
|
|
|
2013-10-18 10:10:23 +04:00
|
|
|
WidgetTouchEvent* touchEvent = aEvent->AsTouchEvent();
|
|
|
|
if (touchEvent) {
|
2012-07-28 02:01:12 +04:00
|
|
|
// return false if there is more than one touch on the page, or if
|
|
|
|
// we can't find a touch point
|
2016-03-30 12:44:28 +03:00
|
|
|
if (touchEvent->mTouches.Length() != 1) {
|
2012-07-28 02:01:12 +04:00
|
|
|
return false;
|
|
|
|
}
|
2013-04-05 12:49:00 +04:00
|
|
|
|
2016-03-30 12:44:28 +03:00
|
|
|
dom::Touch* touch = touchEvent->mTouches.SafeElementAt(0);
|
2012-07-28 02:01:12 +04:00
|
|
|
if (!touch) {
|
|
|
|
return false;
|
|
|
|
}
|
2015-02-02 01:27:41 +03:00
|
|
|
aPoint = touch->mRefPoint;
|
2012-07-28 02:01:12 +04:00
|
|
|
} else {
|
2016-04-18 17:09:02 +03:00
|
|
|
aPoint = aEvent->mRefPoint;
|
2012-07-28 02:01:12 +04:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|