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/. */
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2020-04-18 15:06:09 +03:00
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
#include "mozilla/StaticPtr.h"
|
|
|
|
#include "nsIFrame.h"
|
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
#include "nsBoxLayoutState.h"
|
|
|
|
#include "nsBoxFrame.h"
|
2018-01-21 02:48:36 +03:00
|
|
|
#include "nsDOMAttributeMap.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
2000-03-31 11:02:06 +04:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIContent.h"
|
2011-12-28 00:18:48 +04:00
|
|
|
#include "nsContainerFrame.h"
|
2014-02-28 03:04:46 +04:00
|
|
|
#include "nsNameSpaceManager.h"
|
2007-01-30 03:06:41 +03:00
|
|
|
#include "nsGkAtoms.h"
|
2001-12-18 01:51:39 +03:00
|
|
|
#include "nsITheme.h"
|
2011-07-11 18:05:10 +04:00
|
|
|
#include "nsBoxLayout.h"
|
2010-08-31 04:49:13 +04:00
|
|
|
#include "FrameLayerBuilder.h"
|
2018-01-21 02:48:36 +03:00
|
|
|
#include "mozilla/dom/Attr.h"
|
|
|
|
#include "mozilla/dom/Element.h"
|
2013-01-15 16:22:03 +04:00
|
|
|
#include <algorithm>
|
2010-08-31 04:49:13 +04:00
|
|
|
|
|
|
|
using namespace mozilla;
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2020-04-18 15:06:09 +03:00
|
|
|
nsresult nsIFrame::BeginXULLayout(nsBoxLayoutState& aState) {
|
2004-09-28 22:37:50 +04:00
|
|
|
// mark ourselves as dirty so no child under us
|
|
|
|
// can post an incremental layout.
|
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 Is this still needed?
|
2017-08-24 14:09:42 +03:00
|
|
|
AddStateBits(NS_FRAME_HAS_DIRTY_CHILDREN);
|
2004-09-28 22:37:50 +04:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
if (GetStateBits() & NS_FRAME_IS_DIRTY) {
|
2016-07-21 13:36:35 +03:00
|
|
|
// If the parent is dirty, all the children are dirty (ReflowInput
|
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
|
|
|
// does this too).
|
|
|
|
nsIFrame* box;
|
2016-04-21 07:28:32 +03:00
|
|
|
for (box = GetChildXULBox(this); box; box = GetNextXULBox(box))
|
2019-07-02 00:56:43 +03:00
|
|
|
box->MarkSubtreeDirty();
|
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-07-21 13:36:35 +03:00
|
|
|
// Another copy-over from ReflowInput.
|
2010-03-02 04:57:43 +03:00
|
|
|
// Since we are in reflow, we don't need to store these properties anymore.
|
2020-02-06 19:06:49 +03:00
|
|
|
RemoveProperty(UsedBorderProperty());
|
|
|
|
RemoveProperty(UsedPaddingProperty());
|
|
|
|
RemoveProperty(UsedMarginProperty());
|
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
|
|
|
|
2000-07-08 02:24:06 +04:00
|
|
|
return NS_OK;
|
2000-05-15 08:12:31 +04:00
|
|
|
}
|
|
|
|
|
2000-07-08 02:24:06 +04:00
|
|
|
NS_IMETHODIMP
|
2020-04-18 15:06:09 +03:00
|
|
|
nsIFrame::DoXULLayout(nsBoxLayoutState& aState) { return NS_OK; }
|
2001-12-18 01:51:39 +03:00
|
|
|
|
2020-04-18 15:06:09 +03:00
|
|
|
nsresult nsIFrame::EndXULLayout(nsBoxLayoutState& aState) {
|
|
|
|
return SyncXULLayout(aState);
|
2002-12-11 05:33:33 +03:00
|
|
|
}
|
|
|
|
|
2020-04-18 15:06:09 +03:00
|
|
|
nsresult nsIFrame::XULRelayoutChildAtOrdinal(nsIFrame* aChild) { return NS_OK; }
|
2001-09-26 02:17:00 +04:00
|
|
|
|
2016-04-21 07:28:33 +03:00
|
|
|
nsresult nsIFrame::GetXULClientRect(nsRect& aClientRect) {
|
2007-01-31 19:02:42 +03:00
|
|
|
aClientRect = mRect;
|
|
|
|
aClientRect.MoveTo(0, 0);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
|
|
|
nsMargin borderPadding;
|
2016-04-21 07:28:32 +03:00
|
|
|
GetXULBorderAndPadding(borderPadding);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
|
|
|
aClientRect.Deflate(borderPadding);
|
|
|
|
|
|
|
|
if (aClientRect.width < 0) aClientRect.width = 0;
|
|
|
|
|
|
|
|
if (aClientRect.height < 0) aClientRect.height = 0;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2020-04-18 15:06:09 +03:00
|
|
|
void nsIFrame::SetXULBounds(nsBoxLayoutState& aState, const nsRect& aRect,
|
|
|
|
bool aRemoveOverflowAreas) {
|
2004-09-28 22:37:50 +04:00
|
|
|
nsRect rect(mRect);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2019-08-08 22:48:19 +03:00
|
|
|
ReflowChildFlags flags = GetXULLayoutFlags() | aState.LayoutFlags();
|
2000-04-25 11:10:48 +04:00
|
|
|
|
2019-08-08 22:48:19 +03:00
|
|
|
if ((flags & ReflowChildFlags::NoMoveFrame) ==
|
|
|
|
ReflowChildFlags::NoMoveFrame) {
|
2013-08-14 16:27:20 +04:00
|
|
|
SetSize(aRect.Size());
|
2019-08-08 22:48:19 +03:00
|
|
|
} else {
|
2004-09-28 22:37:50 +04:00
|
|
|
SetRect(aRect);
|
2019-08-08 22:48:19 +03:00
|
|
|
}
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2004-07-16 20:56:21 +04:00
|
|
|
// Nuke the overflow area. The caller is responsible for restoring
|
|
|
|
// it if necessary.
|
2010-10-07 08:25:47 +04:00
|
|
|
if (aRemoveOverflowAreas) {
|
2004-09-28 22:37:50 +04:00
|
|
|
// remove the previously stored overflow area
|
2010-10-07 08:25:47 +04:00
|
|
|
ClearOverflowRects();
|
2004-07-16 20:56:21 +04:00
|
|
|
}
|
|
|
|
|
2019-08-08 22:48:19 +03:00
|
|
|
if (!(flags & ReflowChildFlags::NoMoveView)) {
|
2004-12-27 18:05:18 +03:00
|
|
|
nsContainerFrame::PositionFrameView(this);
|
2001-09-21 04:53:29 +04:00
|
|
|
if ((rect.x != aRect.x) || (rect.y != aRect.y))
|
2004-12-27 18:05:18 +03:00
|
|
|
nsContainerFrame::PositionChildViews(this);
|
2000-04-25 11:10:48 +04:00
|
|
|
}
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
|
2016-04-21 07:28:32 +03:00
|
|
|
nsresult nsIFrame::GetXULBorderAndPadding(nsMargin& aBorderAndPadding) {
|
2004-09-28 22:37:50 +04:00
|
|
|
aBorderAndPadding.SizeTo(0, 0, 0, 0);
|
2016-04-21 07:28:33 +03:00
|
|
|
nsresult rv = GetXULBorder(aBorderAndPadding);
|
2001-01-21 01:46:54 +03:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2001-01-25 05:58:12 +03:00
|
|
|
nsMargin padding;
|
2016-04-21 07:28:33 +03:00
|
|
|
rv = GetXULPadding(padding);
|
2001-02-07 12:57:26 +03:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
aBorderAndPadding += padding;
|
|
|
|
|
2000-04-25 11:10:48 +04:00
|
|
|
return rv;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
|
2020-04-18 15:06:09 +03:00
|
|
|
nsresult nsIFrame::GetXULBorder(nsMargin& aBorder) {
|
|
|
|
aBorder.SizeTo(0, 0, 0, 0);
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStyleDisplay* disp = StyleDisplay();
|
2020-03-04 02:39:07 +03:00
|
|
|
if (disp->HasAppearance()) {
|
2019-09-13 19:51:01 +03:00
|
|
|
// Go to the theme for the border.
|
2020-03-04 02:39:07 +03:00
|
|
|
nsPresContext* pc = PresContext();
|
2020-03-04 04:58:30 +03:00
|
|
|
nsITheme* theme = pc->Theme();
|
|
|
|
if (theme->ThemeSupportsWidget(pc, this, disp->mAppearance)) {
|
2020-03-04 02:39:07 +03:00
|
|
|
LayoutDeviceIntMargin margin =
|
|
|
|
theme->GetWidgetBorder(pc->DeviceContext(), this, disp->mAppearance);
|
2020-04-18 15:06:09 +03:00
|
|
|
aBorder =
|
2020-03-04 02:39:07 +03:00
|
|
|
LayoutDevicePixel::ToAppUnits(margin, pc->AppUnitsPerDevPixel());
|
2019-09-13 19:51:01 +03:00
|
|
|
return NS_OK;
|
2001-12-18 01:51:39 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-18 15:06:09 +03:00
|
|
|
aBorder = StyleBorder()->GetComputedBorder();
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2003-05-15 07:42:21 +04:00
|
|
|
return NS_OK;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
|
2020-04-18 15:06:09 +03:00
|
|
|
nsresult nsIFrame::GetXULPadding(nsMargin& aBorderAndPadding) {
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStyleDisplay* disp = StyleDisplay();
|
2020-03-04 02:39:07 +03:00
|
|
|
if (disp->HasAppearance()) {
|
2019-09-13 19:51:01 +03:00
|
|
|
// Go to the theme for the padding.
|
2020-03-04 02:39:07 +03:00
|
|
|
nsPresContext* pc = PresContext();
|
2020-03-04 04:58:30 +03:00
|
|
|
nsITheme* theme = pc->Theme();
|
|
|
|
if (theme->ThemeSupportsWidget(pc, this, disp->mAppearance)) {
|
2019-09-13 19:51:01 +03:00
|
|
|
LayoutDeviceIntMargin padding;
|
2020-03-04 02:39:07 +03:00
|
|
|
bool useThemePadding = theme->GetWidgetPadding(
|
|
|
|
pc->DeviceContext(), this, disp->mAppearance, &padding);
|
2019-09-13 19:51:01 +03:00
|
|
|
if (useThemePadding) {
|
2020-04-18 15:06:09 +03:00
|
|
|
aBorderAndPadding =
|
2020-03-04 02:39:07 +03:00
|
|
|
LayoutDevicePixel::ToAppUnits(padding, pc->AppUnitsPerDevPixel());
|
2019-09-13 19:51:01 +03:00
|
|
|
return NS_OK;
|
2004-09-06 07:59:31 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-18 15:06:09 +03:00
|
|
|
aBorderAndPadding.SizeTo(0, 0, 0, 0);
|
|
|
|
StylePadding()->GetPadding(aBorderAndPadding);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2003-05-15 07:42:21 +04:00
|
|
|
return NS_OK;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
|
2020-04-18 15:06:09 +03:00
|
|
|
nsresult nsIFrame::GetXULMargin(nsMargin& aMargin) {
|
2000-03-31 11:02:06 +04:00
|
|
|
aMargin.SizeTo(0, 0, 0, 0);
|
2013-02-17 01:51:02 +04:00
|
|
|
StyleMargin()->GetMargin(aMargin);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2020-04-18 15:06:09 +03:00
|
|
|
void nsIFrame::XULSizeNeedsRecalc(nsSize& aSize) {
|
2000-03-31 11:02:06 +04:00
|
|
|
aSize.width = -1;
|
|
|
|
aSize.height = -1;
|
|
|
|
}
|
|
|
|
|
2020-04-18 15:06:09 +03:00
|
|
|
void nsIFrame::XULCoordNeedsRecalc(nscoord& aCoord) { aCoord = -1; }
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2020-04-18 15:06:09 +03:00
|
|
|
bool nsIFrame::XULNeedsRecalc(const nsSize& aSize) {
|
2000-03-31 11:02:06 +04:00
|
|
|
return (aSize.width == -1 || aSize.height == -1);
|
|
|
|
}
|
|
|
|
|
2020-04-18 15:06:09 +03:00
|
|
|
bool nsIFrame::XULNeedsRecalc(nscoord aCoord) { return (aCoord == -1); }
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2020-04-18 15:06:09 +03:00
|
|
|
nsSize nsIFrame::GetXULPrefSize(nsBoxLayoutState& aBoxLayoutState) {
|
|
|
|
NS_ASSERTION(aBoxLayoutState.GetRenderingContext(),
|
|
|
|
"must have rendering context");
|
2007-04-30 02:24:59 +04:00
|
|
|
|
2007-01-08 05:57:59 +03:00
|
|
|
nsSize pref(0, 0);
|
|
|
|
DISPLAY_PREF_SIZE(this, pref);
|
2000-05-17 00:46:08 +04:00
|
|
|
|
2016-04-21 07:28:32 +03:00
|
|
|
if (IsXULCollapsed()) return pref;
|
2004-06-15 05:10:09 +04:00
|
|
|
|
2020-04-18 15:06:09 +03:00
|
|
|
AddXULBorderAndPadding(pref);
|
2011-09-29 10:19:26 +04:00
|
|
|
bool widthSet, heightSet;
|
2016-04-21 07:28:34 +03:00
|
|
|
nsIFrame::AddXULPrefSize(this, pref, widthSet, heightSet);
|
2004-06-15 05:10:09 +04:00
|
|
|
|
2020-04-18 15:06:09 +03:00
|
|
|
nsSize minSize = GetXULMinSize(aBoxLayoutState);
|
|
|
|
nsSize maxSize = GetXULMaxSize(aBoxLayoutState);
|
|
|
|
return XULBoundsCheck(minSize, pref, maxSize);
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
|
2020-04-18 15:06:09 +03:00
|
|
|
nsSize nsIFrame::GetXULMinSize(nsBoxLayoutState& aBoxLayoutState) {
|
|
|
|
NS_ASSERTION(aBoxLayoutState.GetRenderingContext(),
|
|
|
|
"must have rendering context");
|
2007-04-30 02:24:59 +04:00
|
|
|
|
2007-01-08 05:57:59 +03:00
|
|
|
nsSize min(0, 0);
|
|
|
|
DISPLAY_MIN_SIZE(this, min);
|
2000-05-17 00:46:08 +04:00
|
|
|
|
2016-04-21 07:28:32 +03:00
|
|
|
if (IsXULCollapsed()) return min;
|
2000-05-17 00:46:08 +04:00
|
|
|
|
2020-04-18 15:06:09 +03:00
|
|
|
AddXULBorderAndPadding(min);
|
2011-09-29 10:19:26 +04:00
|
|
|
bool widthSet, heightSet;
|
2020-03-03 23:30:52 +03:00
|
|
|
nsIFrame::AddXULMinSize(this, min, widthSet, heightSet);
|
2007-01-08 05:57:59 +03:00
|
|
|
return min;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
|
2020-04-18 15:06:09 +03:00
|
|
|
nsSize nsIFrame::GetXULMinSizeForScrollArea(nsBoxLayoutState& aBoxLayoutState) {
|
2004-11-03 05:52:16 +03:00
|
|
|
return nsSize(0, 0);
|
|
|
|
}
|
|
|
|
|
2020-04-18 15:06:09 +03:00
|
|
|
nsSize nsIFrame::GetXULMaxSize(nsBoxLayoutState& aBoxLayoutState) {
|
|
|
|
NS_ASSERTION(aBoxLayoutState.GetRenderingContext(),
|
|
|
|
"must have rendering context");
|
2007-04-30 02:24:59 +04:00
|
|
|
|
2019-06-05 02:41:20 +03:00
|
|
|
nsSize maxSize(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
|
2008-02-27 04:51:57 +03:00
|
|
|
DISPLAY_MAX_SIZE(this, maxSize);
|
2000-05-17 00:46:08 +04:00
|
|
|
|
2016-04-21 07:28:32 +03:00
|
|
|
if (IsXULCollapsed()) return maxSize;
|
2000-05-17 00:46:08 +04:00
|
|
|
|
2020-04-18 15:06:09 +03:00
|
|
|
AddXULBorderAndPadding(maxSize);
|
2011-09-29 10:19:26 +04:00
|
|
|
bool widthSet, heightSet;
|
2016-04-21 07:28:34 +03:00
|
|
|
nsIFrame::AddXULMaxSize(this, maxSize, widthSet, heightSet);
|
2008-02-27 04:51:57 +03:00
|
|
|
return maxSize;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
|
2020-04-18 15:06:09 +03:00
|
|
|
nscoord nsIFrame::GetXULFlex() {
|
2007-01-31 19:02:42 +03:00
|
|
|
nscoord flex = 0;
|
2000-05-17 00:46:08 +04:00
|
|
|
|
2016-04-21 07:28:34 +03:00
|
|
|
nsIFrame::AddXULFlex(this, flex);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2007-01-31 19:02:42 +03:00
|
|
|
return flex;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
|
2020-04-18 15:06:09 +03:00
|
|
|
nscoord nsIFrame::GetXULBoxAscent(nsBoxLayoutState& aBoxLayoutState) {
|
2016-04-21 07:28:32 +03:00
|
|
|
if (IsXULCollapsed()) return 0;
|
2000-05-17 00:46:08 +04:00
|
|
|
|
2020-04-18 15:06:09 +03:00
|
|
|
return GetXULPrefSize(aBoxLayoutState).height;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
|
2020-04-18 15:06:09 +03:00
|
|
|
bool nsIFrame::IsXULCollapsed() {
|
2019-12-13 08:34:38 +03:00
|
|
|
return StyleVisibility()->mVisible == StyleVisibility::Collapse;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
|
2016-04-21 07:28:32 +03:00
|
|
|
nsresult nsIFrame::XULLayout(nsBoxLayoutState& aState) {
|
2007-04-30 02:24:59 +04:00
|
|
|
NS_ASSERTION(aState.GetRenderingContext(), "must have rendering context");
|
|
|
|
|
2020-04-18 15:06:09 +03:00
|
|
|
nsIFrame* box = static_cast<nsIFrame*>(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
|
|
|
DISPLAY_LAYOUT(box);
|
|
|
|
|
2016-04-21 07:28:34 +03:00
|
|
|
box->BeginXULLayout(aState);
|
2000-05-15 08:12:31 +04:00
|
|
|
|
2016-04-21 07:28:35 +03:00
|
|
|
box->DoXULLayout(aState);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2016-04-21 07:28:35 +03:00
|
|
|
box->EndXULLayout(aState);
|
2000-05-15 08:12:31 +04:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2020-04-18 15:06:09 +03:00
|
|
|
bool nsIFrame::DoesClipChildren() {
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStyleDisplay* display = StyleDisplay();
|
2018-12-11 03:50:32 +03:00
|
|
|
NS_ASSERTION(
|
|
|
|
(display->mOverflowY == StyleOverflow::MozHiddenUnscrollable) ==
|
|
|
|
(display->mOverflowX == StyleOverflow::MozHiddenUnscrollable),
|
|
|
|
"If one overflow is -moz-hidden-unscrollable, the other should be too");
|
|
|
|
return display->mOverflowX == StyleOverflow::MozHiddenUnscrollable;
|
2005-04-12 02:03:23 +04:00
|
|
|
}
|
|
|
|
|
2020-04-18 15:06:09 +03:00
|
|
|
nsresult nsIFrame::SyncXULLayout(nsBoxLayoutState& aBoxLayoutState) {
|
2000-03-31 11:02:06 +04:00
|
|
|
/*
|
2016-04-21 07:28:32 +03:00
|
|
|
if (IsXULCollapsed()) {
|
2020-04-18 15:06:09 +03:00
|
|
|
CollapseChild(aBoxLayoutState, this, true);
|
2000-03-31 11:02:06 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
*/
|
2017-07-06 15:00:35 +03:00
|
|
|
|
2020-04-18 15:06:09 +03:00
|
|
|
if (GetStateBits() & NS_FRAME_IS_DIRTY) {
|
|
|
|
XULRedraw(aBoxLayoutState);
|
|
|
|
}
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2004-09-28 22:37:50 +04:00
|
|
|
RemoveStateBits(NS_FRAME_HAS_DIRTY_CHILDREN | NS_FRAME_IS_DIRTY |
|
|
|
|
NS_FRAME_FIRST_REFLOW | NS_FRAME_IN_REFLOW);
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2020-04-18 15:06:09 +03:00
|
|
|
nsPresContext* presContext = aBoxLayoutState.PresContext();
|
2000-04-25 11:10:48 +04:00
|
|
|
|
2020-04-18 15:06:09 +03:00
|
|
|
ReflowChildFlags flags = GetXULLayoutFlags() | aBoxLayoutState.LayoutFlags();
|
2000-04-25 11:10:48 +04:00
|
|
|
|
2010-10-07 08:25:46 +04:00
|
|
|
nsRect visualOverflow;
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2020-04-18 15:06:09 +03:00
|
|
|
if (XULComputesOwnOverflowArea()) {
|
2010-10-07 08:25:46 +04:00
|
|
|
visualOverflow = GetVisualOverflowRect();
|
2008-02-20 10:08:55 +03:00
|
|
|
} else {
|
2010-10-07 08:25:46 +04:00
|
|
|
nsRect rect(nsPoint(0, 0), GetSize());
|
|
|
|
nsOverflowAreas overflowAreas(rect, rect);
|
2016-04-21 07:28:32 +03:00
|
|
|
if (!DoesClipChildren() && !IsXULCollapsed()) {
|
2004-07-16 20:56:21 +04:00
|
|
|
// See if our child frames caused us to overflow after being laid
|
|
|
|
// out. If so, store the overflow area. This normally can't happen
|
|
|
|
// in XUL, but it can happen with the CSS 'outline' property and
|
|
|
|
// possibly with other exotic stuff (e.g. relatively positioned
|
|
|
|
// frames in HTML inside XUL).
|
2011-06-16 01:03:49 +04:00
|
|
|
nsLayoutUtils::UnionChildOverflow(this, overflowAreas);
|
2004-07-15 22:57:47 +04:00
|
|
|
}
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2010-10-07 08:25:46 +04:00
|
|
|
FinishAndStoreOverflow(overflowAreas, GetSize());
|
|
|
|
visualOverflow = overflowAreas.VisualOverflow();
|
2004-07-16 20:56:21 +04:00
|
|
|
}
|
|
|
|
|
2013-01-03 17:23:11 +04:00
|
|
|
nsView* view = GetView();
|
2000-03-31 11:02:06 +04:00
|
|
|
if (view) {
|
|
|
|
// Make sure the frame's view is properly sized and positioned and has
|
|
|
|
// things like opacity correct
|
2011-12-28 00:18:48 +04:00
|
|
|
nsContainerFrame::SyncFrameViewAfterReflow(presContext, this, view,
|
|
|
|
visualOverflow, flags);
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2016-04-21 07:28:34 +03:00
|
|
|
nsresult nsIFrame::XULRedraw(nsBoxLayoutState& aState) {
|
2004-06-22 06:55:04 +04:00
|
|
|
if (aState.PaintingDisabled()) return NS_OK;
|
2000-10-07 04:49:08 +04:00
|
|
|
|
2010-08-31 04:49:13 +04:00
|
|
|
// nsStackLayout, at least, expects us to repaint descendants even
|
|
|
|
// if a damage rect is provided
|
2012-08-29 09:39:31 +04:00
|
|
|
InvalidateFrameSubtree();
|
2000-03-31 11:02:06 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2016-04-21 07:28:34 +03:00
|
|
|
bool nsIFrame::AddXULPrefSize(nsIFrame* aBox, nsSize& aSize, bool& aWidthSet,
|
|
|
|
bool& aHeightSet) {
|
2011-10-17 18:59:28 +04:00
|
|
|
aWidthSet = false;
|
|
|
|
aHeightSet = false;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
// add in the css min, max, pref
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStylePosition* position = aBox->StylePosition();
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
// see if the width or height was specifically set
|
2007-05-09 12:48:38 +04:00
|
|
|
// XXX Handle eStyleUnit_Enumerated?
|
2007-05-04 03:11:00 +04:00
|
|
|
// (Handling the eStyleUnit_Enumerated types requires
|
2016-04-21 07:28:31 +03:00
|
|
|
// GetXULPrefSize/GetXULMinSize methods that don't consider
|
2008-07-18 03:37:12 +04:00
|
|
|
// (min-/max-/)(width/height) properties.)
|
2019-02-10 15:55:16 +03:00
|
|
|
const auto& width = position->mWidth;
|
|
|
|
if (width.ConvertsToLength()) {
|
|
|
|
aSize.width = std::max(0, width.ToLength());
|
2011-10-17 18:59:28 +04:00
|
|
|
aWidthSet = true;
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2019-02-10 15:55:16 +03:00
|
|
|
const auto& height = position->mHeight;
|
|
|
|
if (height.ConvertsToLength()) {
|
|
|
|
aSize.height = std::max(0, height.ToLength());
|
2011-10-17 18:59:28 +04:00
|
|
|
aHeightSet = true;
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2010-08-25 14:17:55 +04:00
|
|
|
nsIContent* content = aBox->GetContent();
|
|
|
|
// ignore 'height' and 'width' attributes if the actual element is not XUL
|
|
|
|
// For example, we might be magic XUL frames whose primary content is an HTML
|
2003-05-20 03:24:51 +04:00
|
|
|
// <select>
|
2015-03-03 14:08:59 +03:00
|
|
|
if (content && content->IsXULElement()) {
|
2010-08-25 14:17:55 +04:00
|
|
|
nsAutoString value;
|
|
|
|
nsresult error;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2010-08-25 14:17:55 +04:00
|
|
|
content->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::width, value);
|
2017-11-20 08:30:27 +03:00
|
|
|
if (!value.IsEmpty()) {
|
2000-03-31 11:02:06 +04:00
|
|
|
value.Trim("%");
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-11-20 08:30:27 +03:00
|
|
|
aSize.width = nsPresContext::CSSPixelsToAppUnits(value.ToInteger(&error));
|
2011-10-17 18:59:28 +04:00
|
|
|
aWidthSet = true;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
2010-08-25 14:17:55 +04:00
|
|
|
|
2017-12-07 21:13:50 +03:00
|
|
|
content->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::height, value);
|
2005-10-28 15:25:24 +04:00
|
|
|
if (!value.IsEmpty()) {
|
2000-03-31 11:02:06 +04:00
|
|
|
value.Trim("%");
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2007-02-07 10:46:44 +03:00
|
|
|
aSize.height =
|
|
|
|
nsPresContext::CSSPixelsToAppUnits(value.ToInteger(&error));
|
2011-10-17 18:59:28 +04:00
|
|
|
aHeightSet = true;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2010-03-18 22:58:15 +03:00
|
|
|
return (aWidthSet && aHeightSet);
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
|
2018-08-20 21:50:33 +03:00
|
|
|
// This returns the scrollbar width we want to use when either native
|
|
|
|
// theme is disabled, or the native theme claims that it doesn't support
|
|
|
|
// scrollbar.
|
|
|
|
static nscoord GetScrollbarWidthNoTheme(nsIFrame* aBox) {
|
|
|
|
ComputedStyle* scrollbarStyle = nsLayoutUtils::StyleForScrollbar(aBox);
|
|
|
|
switch (scrollbarStyle->StyleUIReset()->mScrollbarWidth) {
|
|
|
|
default:
|
|
|
|
case StyleScrollbarWidth::Auto:
|
2018-08-24 10:40:07 +03:00
|
|
|
return 12 * AppUnitsPerCSSPixel();
|
2018-08-20 21:50:33 +03:00
|
|
|
case StyleScrollbarWidth::Thin:
|
2018-08-24 10:40:07 +03:00
|
|
|
return 6 * AppUnitsPerCSSPixel();
|
2018-08-20 21:50:33 +03:00
|
|
|
case StyleScrollbarWidth::None:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2020-03-03 23:30:52 +03:00
|
|
|
bool nsIFrame::AddXULMinSize(nsIFrame* aBox, nsSize& aSize, bool& aWidthSet,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool& aHeightSet) {
|
2011-10-17 18:59:28 +04:00
|
|
|
aWidthSet = false;
|
|
|
|
aHeightSet = false;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool canOverride = true;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2020-03-03 23:30:52 +03:00
|
|
|
nsPresContext* pc = aBox->PresContext();
|
|
|
|
|
2001-12-18 01:51:39 +03:00
|
|
|
// See if a native theme wants to supply a minimum size.
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStyleDisplay* display = aBox->StyleDisplay();
|
2018-07-25 16:03:45 +03:00
|
|
|
if (display->HasAppearance()) {
|
2020-03-04 04:58:30 +03:00
|
|
|
nsITheme* theme = pc->Theme();
|
|
|
|
if (theme->ThemeSupportsWidget(pc, aBox, display->mAppearance)) {
|
2015-03-30 18:36:14 +03:00
|
|
|
LayoutDeviceIntSize size;
|
2020-03-03 23:30:52 +03:00
|
|
|
theme->GetMinimumWidgetSize(pc, aBox, display->mAppearance, &size,
|
2017-05-21 12:15:00 +03:00
|
|
|
&canOverride);
|
2014-06-27 13:19:00 +04:00
|
|
|
if (size.width) {
|
2020-03-03 23:30:52 +03:00
|
|
|
aSize.width = pc->DevPixelsToAppUnits(size.width);
|
2011-10-17 18:59:28 +04:00
|
|
|
aWidthSet = true;
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2014-06-27 13:19:00 +04:00
|
|
|
if (size.height) {
|
2020-03-03 23:30:52 +03:00
|
|
|
aSize.height = pc->DevPixelsToAppUnits(size.height);
|
2011-10-17 18:59:28 +04:00
|
|
|
aHeightSet = true;
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
|
|
|
} else {
|
2018-08-20 21:50:33 +03:00
|
|
|
switch (display->mAppearance) {
|
|
|
|
case StyleAppearance::ScrollbarVertical:
|
|
|
|
aSize.width = GetScrollbarWidthNoTheme(aBox);
|
2014-06-27 13:19:00 +04:00
|
|
|
aWidthSet = true;
|
|
|
|
break;
|
|
|
|
case StyleAppearance::ScrollbarHorizontal:
|
|
|
|
aSize.height = GetScrollbarWidthNoTheme(aBox);
|
|
|
|
aHeightSet = true;
|
2018-08-20 21:50:33 +03:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2001-12-18 01:51:39 +03:00
|
|
|
}
|
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2001-12-18 01:51:39 +03:00
|
|
|
|
2000-03-31 11:02:06 +04:00
|
|
|
// add in the css min, max, pref
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStylePosition* position = aBox->StylePosition();
|
2019-02-10 15:55:16 +03:00
|
|
|
const auto& minWidth = position->mMinWidth;
|
|
|
|
if (minWidth.ConvertsToLength()) {
|
|
|
|
nscoord min = minWidth.ToLength();
|
2010-08-25 14:17:56 +04:00
|
|
|
if (!aWidthSet || (min > aSize.width && canOverride)) {
|
2000-03-31 11:02:06 +04:00
|
|
|
aSize.width = min;
|
2011-10-17 18:59:28 +04:00
|
|
|
aWidthSet = true;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
2019-02-10 15:55:16 +03:00
|
|
|
} else if (minWidth.ConvertsToPercentage()) {
|
|
|
|
NS_ASSERTION(minWidth.ToPercentage() == 0.0f,
|
2008-09-20 17:42:03 +04:00
|
|
|
"Non-zero percentage values not currently supported");
|
2010-08-25 14:17:55 +04:00
|
|
|
aSize.width = 0;
|
2011-10-17 18:59:28 +04:00
|
|
|
aWidthSet = true; // FIXME: should we really do this for
|
2010-08-25 14:17:56 +04:00
|
|
|
// nonzero values?
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2019-02-10 15:55:16 +03:00
|
|
|
// XXX Handle ExtremumLength?
|
|
|
|
// (Handling them requires GetXULPrefSize/GetXULMinSize methods that don't
|
|
|
|
// consider (min-/max-/)(width/height) properties.
|
2010-08-25 14:17:56 +04:00
|
|
|
// calc() with percentage is treated like '0' (unset)
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2019-02-10 15:55:16 +03:00
|
|
|
const auto& minHeight = position->mMinHeight;
|
|
|
|
if (minHeight.ConvertsToLength()) {
|
|
|
|
nscoord min = minHeight.ToLength();
|
2010-08-25 14:17:55 +04:00
|
|
|
if (!aHeightSet || (min > aSize.height && canOverride)) {
|
2000-03-31 11:02:06 +04:00
|
|
|
aSize.height = min;
|
2011-10-17 18:59:28 +04:00
|
|
|
aHeightSet = true;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
2019-02-10 15:55:16 +03:00
|
|
|
} else if (minHeight.ConvertsToPercentage()) {
|
|
|
|
NS_ASSERTION(position->mMinHeight.ToPercentage() == 0.0f,
|
2008-09-20 17:42:03 +04:00
|
|
|
"Non-zero percentage values not currently supported");
|
2004-11-03 15:20:13 +03:00
|
|
|
aSize.height = 0;
|
2011-10-17 18:59:28 +04:00
|
|
|
aHeightSet = true; // FIXME: should we really do this for
|
2010-08-25 14:17:55 +04:00
|
|
|
// nonzero values?
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2010-08-25 14:17:55 +04:00
|
|
|
// calc() with percentage is treated like '0' (unset)
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2004-09-28 22:37:50 +04:00
|
|
|
nsIContent* content = aBox->GetContent();
|
2015-03-03 14:08:59 +03:00
|
|
|
if (content && content->IsXULElement()) {
|
2000-03-31 11:02:06 +04:00
|
|
|
nsAutoString value;
|
2012-07-27 17:59:29 +04:00
|
|
|
nsresult error;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-12-07 21:13:50 +03:00
|
|
|
content->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::minwidth,
|
2018-11-30 13:46:48 +03:00
|
|
|
value);
|
2005-10-28 15:25:24 +04:00
|
|
|
if (!value.IsEmpty()) {
|
2000-03-31 11:02:06 +04:00
|
|
|
value.Trim("%");
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2007-02-07 10:46:44 +03:00
|
|
|
nscoord val = nsPresContext::CSSPixelsToAppUnits(value.ToInteger(&error));
|
2001-11-07 05:32:58 +03:00
|
|
|
if (val > aSize.width) aSize.width = val;
|
2014-06-27 13:19:00 +04:00
|
|
|
aWidthSet = true;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-12-07 21:13:50 +03:00
|
|
|
content->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::minheight,
|
|
|
|
value);
|
2005-10-28 15:25:24 +04:00
|
|
|
if (!value.IsEmpty()) {
|
2000-12-07 13:18:40 +03:00
|
|
|
value.Trim("%");
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2007-02-07 10:46:44 +03:00
|
|
|
nscoord val = nsPresContext::CSSPixelsToAppUnits(value.ToInteger(&error));
|
2001-11-07 05:32:58 +03:00
|
|
|
if (val > aSize.height) aSize.height = val;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
aHeightSet = true;
|
2000-12-07 13:18:40 +03:00
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2000-12-07 13:18:40 +03:00
|
|
|
|
2010-03-18 22:58:15 +03:00
|
|
|
return (aWidthSet && aHeightSet);
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
|
2016-04-21 07:28:34 +03:00
|
|
|
bool nsIFrame::AddXULMaxSize(nsIFrame* aBox, nsSize& aSize, bool& aWidthSet,
|
|
|
|
bool& aHeightSet) {
|
2011-10-17 18:59:28 +04:00
|
|
|
aWidthSet = false;
|
|
|
|
aHeightSet = false;
|
2000-03-31 11:02:06 +04:00
|
|
|
|
|
|
|
// add in the css min, max, pref
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStylePosition* position = aBox->StylePosition();
|
2000-03-31 11:02:06 +04:00
|
|
|
|
|
|
|
// and max
|
2008-07-18 03:37:12 +04:00
|
|
|
// see if the width or height was specifically set
|
2007-05-09 12:48:38 +04:00
|
|
|
// XXX Handle eStyleUnit_Enumerated?
|
2007-05-04 03:11:00 +04:00
|
|
|
// (Handling the eStyleUnit_Enumerated types requires
|
2016-04-21 07:28:31 +03:00
|
|
|
// GetXULPrefSize/GetXULMinSize methods that don't consider
|
2008-07-18 03:37:12 +04:00
|
|
|
// (min-/max-/)(width/height) properties.)
|
2019-02-10 15:55:16 +03:00
|
|
|
const auto& maxWidth = position->mMaxWidth;
|
2010-08-25 14:17:56 +04:00
|
|
|
if (maxWidth.ConvertsToLength()) {
|
2019-02-10 15:55:16 +03:00
|
|
|
aSize.width = maxWidth.ToLength();
|
2011-10-17 18:59:28 +04:00
|
|
|
aWidthSet = true;
|
2008-07-18 03:37:12 +04:00
|
|
|
}
|
2010-08-25 14:17:56 +04:00
|
|
|
// percentages and calc() with percentages are treated like 'none'
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2019-02-10 15:55:16 +03:00
|
|
|
const auto& maxHeight = position->mMaxHeight;
|
2010-08-25 14:17:55 +04:00
|
|
|
if (maxHeight.ConvertsToLength()) {
|
2019-02-10 15:55:16 +03:00
|
|
|
aSize.height = maxHeight.ToLength();
|
2011-10-17 18:59:28 +04:00
|
|
|
aHeightSet = true;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
2010-08-25 14:17:55 +04:00
|
|
|
// percentages and calc() with percentages are treated like 'none'
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2004-09-28 22:37:50 +04:00
|
|
|
nsIContent* content = aBox->GetContent();
|
2015-03-03 14:08:59 +03:00
|
|
|
if (content && content->IsXULElement()) {
|
2001-09-20 11:46:13 +04:00
|
|
|
nsAutoString value;
|
2012-07-27 17:59:29 +04:00
|
|
|
nsresult error;
|
2001-09-20 11:46:13 +04:00
|
|
|
|
2017-12-07 21:13:50 +03:00
|
|
|
content->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::maxwidth,
|
|
|
|
value);
|
2005-10-28 15:25:24 +04:00
|
|
|
if (!value.IsEmpty()) {
|
2001-09-20 11:46:13 +04:00
|
|
|
value.Trim("%");
|
|
|
|
|
2007-02-07 10:46:44 +03:00
|
|
|
nscoord val = nsPresContext::CSSPixelsToAppUnits(value.ToInteger(&error));
|
2001-09-20 11:46:13 +04:00
|
|
|
aSize.width = val;
|
2011-10-17 18:59:28 +04:00
|
|
|
aWidthSet = true;
|
2001-09-20 11:46:13 +04:00
|
|
|
}
|
|
|
|
|
2017-12-07 21:13:50 +03:00
|
|
|
content->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::maxheight,
|
|
|
|
value);
|
2005-10-28 15:25:24 +04:00
|
|
|
if (!value.IsEmpty()) {
|
2001-09-20 11:46:13 +04:00
|
|
|
value.Trim("%");
|
|
|
|
|
2007-02-07 10:46:44 +03:00
|
|
|
nscoord val = nsPresContext::CSSPixelsToAppUnits(value.ToInteger(&error));
|
2001-09-20 11:46:13 +04:00
|
|
|
aSize.height = val;
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
aHeightSet = true;
|
2001-09-20 11:46:13 +04:00
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2001-09-20 11:46:13 +04:00
|
|
|
|
2010-03-18 22:58:15 +03:00
|
|
|
return (aWidthSet || aHeightSet);
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
|
2016-04-21 07:28:34 +03:00
|
|
|
bool nsIFrame::AddXULFlex(nsIFrame* aBox, nscoord& aFlex) {
|
2011-09-29 10:19:26 +04:00
|
|
|
bool flexSet = false;
|
2000-03-31 11:02:06 +04:00
|
|
|
|
|
|
|
// get the flexibility
|
2013-02-17 01:51:02 +04:00
|
|
|
aFlex = aBox->StyleXUL()->mBoxFlex;
|
2011-04-23 05:36:24 +04:00
|
|
|
|
|
|
|
// attribute value overrides CSS
|
2004-09-28 22:37:50 +04:00
|
|
|
nsIContent* content = aBox->GetContent();
|
2015-03-03 14:08:59 +03:00
|
|
|
if (content && content->IsXULElement()) {
|
2012-07-27 17:59:29 +04:00
|
|
|
nsresult error;
|
2000-03-31 11:02:06 +04:00
|
|
|
nsAutoString value;
|
|
|
|
|
2017-12-07 21:13:50 +03:00
|
|
|
content->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::flex, value);
|
2005-10-28 15:25:24 +04:00
|
|
|
if (!value.IsEmpty()) {
|
2000-03-31 11:02:06 +04:00
|
|
|
value.Trim("%");
|
|
|
|
aFlex = value.ToInteger(&error);
|
2011-10-17 18:59:28 +04:00
|
|
|
flexSet = true;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2006-07-24 14:46:36 +04:00
|
|
|
if (aFlex < 0) aFlex = 0;
|
|
|
|
if (aFlex >= nscoord_MAX) aFlex = nscoord_MAX - 1;
|
|
|
|
|
2011-04-23 05:36:24 +04:00
|
|
|
return flexSet || aFlex > 0;
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
|
2020-04-18 15:06:09 +03:00
|
|
|
void nsIFrame::AddXULBorderAndPadding(nsSize& aSize) {
|
|
|
|
AddXULBorderAndPadding(this, aSize);
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
|
2020-04-18 15:06:09 +03:00
|
|
|
void nsIFrame::AddXULBorderAndPadding(nsIFrame* aBox, nsSize& aSize) {
|
2000-03-31 11:02:06 +04:00
|
|
|
nsMargin borderPadding(0, 0, 0, 0);
|
2016-04-21 07:28:32 +03:00
|
|
|
aBox->GetXULBorderAndPadding(borderPadding);
|
2020-04-18 15:06:09 +03:00
|
|
|
AddXULMargin(aSize, borderPadding);
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
|
2020-04-18 15:06:09 +03:00
|
|
|
void nsIFrame::AddXULMargin(nsIFrame* aChild, nsSize& aSize) {
|
2000-03-31 11:02:06 +04:00
|
|
|
nsMargin margin(0, 0, 0, 0);
|
2016-04-21 07:28:33 +03:00
|
|
|
aChild->GetXULMargin(margin);
|
2020-04-18 15:06:09 +03:00
|
|
|
AddXULMargin(aSize, margin);
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
|
2020-04-18 15:06:09 +03:00
|
|
|
void nsIFrame::AddXULMargin(nsSize& aSize, const nsMargin& aMargin) {
|
2019-06-05 02:41:20 +03:00
|
|
|
if (aSize.width != NS_UNCONSTRAINEDSIZE)
|
2000-03-31 11:02:06 +04:00
|
|
|
aSize.width += aMargin.left + aMargin.right;
|
|
|
|
|
2019-06-05 02:41:20 +03:00
|
|
|
if (aSize.height != NS_UNCONSTRAINEDSIZE)
|
2000-03-31 11:02:06 +04:00
|
|
|
aSize.height += aMargin.top + aMargin.bottom;
|
|
|
|
}
|
|
|
|
|
2020-04-18 15:06:09 +03:00
|
|
|
nscoord nsIFrame::XULBoundsCheck(nscoord aMin, nscoord aPref, nscoord aMax) {
|
2001-10-10 01:02:29 +04:00
|
|
|
if (aPref > aMax) aPref = aMax;
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2001-10-10 01:02:29 +04:00
|
|
|
if (aPref < aMin) aPref = aMin;
|
2008-01-05 08:49:44 +03:00
|
|
|
|
|
|
|
return aPref;
|
2001-10-10 01:02:29 +04:00
|
|
|
}
|
2000-03-31 11:02:06 +04:00
|
|
|
|
2020-04-18 15:06:09 +03:00
|
|
|
nsSize nsIFrame::XULBoundsCheckMinMax(const nsSize& aMinSize,
|
|
|
|
const nsSize& aMaxSize) {
|
2013-01-15 16:22:03 +04:00
|
|
|
return nsSize(std::max(aMaxSize.width, aMinSize.width),
|
|
|
|
std::max(aMaxSize.height, aMinSize.height));
|
2004-11-03 15:20:13 +03:00
|
|
|
}
|
|
|
|
|
2020-04-18 15:06:09 +03:00
|
|
|
nsSize nsIFrame::XULBoundsCheck(const nsSize& aMinSize, const nsSize& aPrefSize,
|
|
|
|
const nsSize& aMaxSize) {
|
2008-01-05 08:49:44 +03:00
|
|
|
return nsSize(
|
2020-04-18 15:06:09 +03:00
|
|
|
XULBoundsCheck(aMinSize.width, aPrefSize.width, aMaxSize.width),
|
|
|
|
XULBoundsCheck(aMinSize.height, aPrefSize.height, aMaxSize.height));
|
2000-03-31 11:02:06 +04:00
|
|
|
}
|
|
|
|
|
2019-02-26 01:09:24 +03:00
|
|
|
/*static*/
|
2020-04-18 15:06:09 +03:00
|
|
|
nsIFrame* nsIFrame::GetChildXULBox(const nsIFrame* aFrame) {
|
2014-05-25 02:20:41 +04:00
|
|
|
// box layout ends at box-wrapped frames, so don't allow these frames
|
|
|
|
// to report child boxes.
|
2016-04-21 07:28:30 +03:00
|
|
|
return aFrame->IsXULBoxFrame() ? aFrame->PrincipalChildList().FirstChild()
|
|
|
|
: nullptr;
|
2014-05-25 02:20:41 +04:00
|
|
|
}
|
|
|
|
|
2019-02-26 01:09:24 +03:00
|
|
|
/*static*/
|
2020-04-18 15:06:09 +03:00
|
|
|
nsIFrame* nsIFrame::GetNextXULBox(const nsIFrame* aFrame) {
|
2016-04-21 07:28:30 +03:00
|
|
|
return aFrame->GetParent() && aFrame->GetParent()->IsXULBoxFrame()
|
|
|
|
? aFrame->GetNextSibling()
|
|
|
|
: nullptr;
|
2014-05-25 02:20:41 +04:00
|
|
|
}
|
|
|
|
|
2019-02-26 01:09:24 +03:00
|
|
|
/*static*/
|
2020-04-18 15:06:09 +03:00
|
|
|
nsIFrame* nsIFrame::GetParentXULBox(const nsIFrame* aFrame) {
|
2016-04-21 07:28:30 +03:00
|
|
|
return aFrame->GetParent() && aFrame->GetParent()->IsXULBoxFrame()
|
|
|
|
? aFrame->GetParent()
|
|
|
|
: nullptr;
|
2014-05-25 02:20:41 +04:00
|
|
|
}
|