2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2006-03-29 22:29:03 +04:00
|
|
|
|
|
|
|
/* struct containing the input to nsIFrame::Reflow */
|
|
|
|
|
2013-09-25 05:43:43 +04:00
|
|
|
#include "nsHTMLReflowState.h"
|
|
|
|
|
2015-06-16 02:36:11 +03:00
|
|
|
#include "LayoutLogging.h"
|
1999-01-05 22:44:41 +03:00
|
|
|
#include "nsStyleConsts.h"
|
2003-10-06 17:13:37 +04:00
|
|
|
#include "nsCSSAnonBoxes.h"
|
1999-03-05 07:24:20 +03:00
|
|
|
#include "nsFrame.h"
|
1999-01-05 22:44:41 +03:00
|
|
|
#include "nsIContent.h"
|
2007-01-30 03:06:41 +03:00
|
|
|
#include "nsGkAtoms.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
1999-01-13 09:37:31 +03:00
|
|
|
#include "nsIPresShell.h"
|
2011-04-08 05:05:49 +04:00
|
|
|
#include "nsFontMetrics.h"
|
2000-04-16 08:07:02 +04:00
|
|
|
#include "nsBlockFrame.h"
|
|
|
|
#include "nsLineBox.h"
|
|
|
|
#include "nsImageFrame.h"
|
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
|
|
|
#include "nsTableFrame.h"
|
2007-06-19 03:19:39 +04:00
|
|
|
#include "nsTableCellFrame.h"
|
2015-06-22 12:33:34 +03:00
|
|
|
#include "nsIPercentBSizeObserver.h"
|
2005-02-08 05:15:26 +03:00
|
|
|
#include "nsLayoutUtils.h"
|
2011-05-25 10:31:59 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
2012-04-17 02:32:12 +04:00
|
|
|
#include "nsFontInflationData.h"
|
2013-09-06 17:35:16 +04:00
|
|
|
#include "StickyScrollContainer.h"
|
2013-10-02 01:00:38 +04:00
|
|
|
#include "nsIFrameInlines.h"
|
2014-06-12 05:12:00 +04:00
|
|
|
#include "CounterStyleManager.h"
|
2013-01-15 16:22:03 +04:00
|
|
|
#include <algorithm>
|
2014-03-15 04:00:12 +04:00
|
|
|
#include "mozilla/dom/HTMLInputElement.h"
|
1999-01-05 22:44:41 +03:00
|
|
|
|
2012-06-25 23:59:42 +04:00
|
|
|
#ifdef DEBUG
|
1999-03-08 22:26:30 +03:00
|
|
|
#undef NOISY_VERTICAL_ALIGN
|
|
|
|
#else
|
|
|
|
#undef NOISY_VERTICAL_ALIGN
|
|
|
|
#endif
|
|
|
|
|
2010-03-29 05:46:55 +04:00
|
|
|
using namespace mozilla;
|
2013-09-06 17:35:16 +04:00
|
|
|
using namespace mozilla::css;
|
2014-03-15 04:00:12 +04:00
|
|
|
using namespace mozilla::dom;
|
2012-01-25 05:21:29 +04:00
|
|
|
using namespace mozilla::layout;
|
2010-03-29 05:46:55 +04:00
|
|
|
|
2002-04-11 04:00:40 +04:00
|
|
|
enum eNormalLineHeightControl {
|
|
|
|
eUninitialized = -1,
|
2015-07-17 19:04:24 +03:00
|
|
|
eNoExternalLeading = 0, // does not include external leading
|
2002-04-11 04:00:40 +04:00
|
|
|
eIncludeExternalLeading, // use whatever value font vendor provides
|
|
|
|
eCompensateLeading // compensate leading if leading provided by font vendor is not enough
|
|
|
|
};
|
2003-09-27 08:18:26 +04:00
|
|
|
|
2002-04-11 04:00:40 +04:00
|
|
|
static eNormalLineHeightControl sNormalLineHeightControl = eUninitialized;
|
|
|
|
|
1999-03-05 07:24:20 +03:00
|
|
|
// Initialize a <b>root</b> reflow state with a rendering context to
|
|
|
|
// use for measuring things.
|
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
|
|
|
nsHTMLReflowState::nsHTMLReflowState(nsPresContext* aPresContext,
|
1999-03-05 07:24:20 +03:00
|
|
|
nsIFrame* aFrame,
|
2013-09-10 00:29:05 +04:00
|
|
|
nsRenderingContext* aRenderingContext,
|
2014-07-24 12:28:46 +04:00
|
|
|
const LogicalSize& aAvailableSpace,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aFlags)
|
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
|
|
|
: nsCSSOffsetState(aFrame, aRenderingContext)
|
2007-08-21 00:07:50 +04:00
|
|
|
, mBlockDelta(0)
|
2014-09-03 19:43:03 +04:00
|
|
|
, mOrthogonalLimit(NS_UNCONSTRAINEDSIZE)
|
2008-02-15 07:14:53 +03:00
|
|
|
, mReflowDepth(0)
|
1999-03-05 07:24:20 +03:00
|
|
|
{
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
NS_PRECONDITION(aRenderingContext, "no rendering context");
|
2014-02-06 13:02:12 +04:00
|
|
|
MOZ_ASSERT(aPresContext, "no pres context");
|
|
|
|
MOZ_ASSERT(aFrame, "no frame");
|
|
|
|
MOZ_ASSERT(aPresContext == aFrame->PresContext(), "wrong pres context");
|
2012-07-30 18:20:58 +04:00
|
|
|
parentReflowState = nullptr;
|
2014-07-24 12:28:46 +04:00
|
|
|
AvailableISize() = aAvailableSpace.ISize(mWritingMode);
|
|
|
|
AvailableBSize() = aAvailableSpace.BSize(mWritingMode);
|
2012-07-30 18:20:58 +04:00
|
|
|
mFloatManager = nullptr;
|
|
|
|
mLineLayout = nullptr;
|
2012-02-13 01:21:51 +04:00
|
|
|
memset(&mFlags, 0, sizeof(mFlags));
|
2012-07-30 18:20:58 +04:00
|
|
|
mDiscoveredClearance = nullptr;
|
2015-06-22 12:33:34 +03:00
|
|
|
mPercentBSizeObserver = nullptr;
|
2012-06-13 23:49:41 +04:00
|
|
|
|
|
|
|
if (aFlags & DUMMY_PARENT_REFLOW_STATE) {
|
|
|
|
mFlags.mDummyParentReflowState = true;
|
|
|
|
}
|
|
|
|
|
2013-09-10 00:29:05 +04:00
|
|
|
if (!(aFlags & CALLER_WILL_INIT)) {
|
|
|
|
Init(aPresContext);
|
|
|
|
}
|
1999-03-05 07:24:20 +03:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool CheckNextInFlowParenthood(nsIFrame* aFrame, nsIFrame* aParent)
|
2004-10-08 16:17:10 +04:00
|
|
|
{
|
|
|
|
nsIFrame* frameNext = aFrame->GetNextInFlow();
|
|
|
|
nsIFrame* parentNext = aParent->GetNextInFlow();
|
|
|
|
return frameNext && parentNext && frameNext->GetParent() == parentNext;
|
|
|
|
}
|
|
|
|
|
2012-07-10 19:46:07 +04:00
|
|
|
/**
|
|
|
|
* Adjusts the margin for a list (ol, ul), if necessary, depending on
|
|
|
|
* font inflation settings. Unfortunately, because bullets from a list are
|
|
|
|
* placed in the margin area, we only have ~40px in which to place the
|
|
|
|
* bullets. When they are inflated, however, this causes problems, since
|
|
|
|
* the text takes up more space than is available in the margin.
|
|
|
|
*
|
|
|
|
* This method will return a small amount (in app units) by which the
|
|
|
|
* margin can be adjusted, so that the space is available for list
|
|
|
|
* bullets to be rendered with font inflation enabled.
|
|
|
|
*/
|
|
|
|
static nscoord
|
|
|
|
FontSizeInflationListMarginAdjustment(const nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
float inflation = nsLayoutUtils::FontSizeInflationFor(aFrame);
|
|
|
|
if (aFrame->IsFrameOfType(nsIFrame::eBlockFrame)) {
|
|
|
|
const nsBlockFrame* blockFrame = static_cast<const nsBlockFrame*>(aFrame);
|
|
|
|
|
|
|
|
// We only want to adjust the margins if we're dealing with an ordered
|
|
|
|
// list.
|
|
|
|
if (inflation > 1.0f &&
|
|
|
|
blockFrame->HasBullet() &&
|
|
|
|
inflation > 1.0f) {
|
|
|
|
|
2014-06-12 05:12:00 +04:00
|
|
|
auto listStyleType = aFrame->StyleList()->GetCounterStyle()->GetStyle();
|
|
|
|
if (listStyleType != NS_STYLE_LIST_STYLE_NONE &&
|
|
|
|
listStyleType != NS_STYLE_LIST_STYLE_DISC &&
|
|
|
|
listStyleType != NS_STYLE_LIST_STYLE_CIRCLE &&
|
2014-06-13 19:34:00 +04:00
|
|
|
listStyleType != NS_STYLE_LIST_STYLE_SQUARE &&
|
|
|
|
listStyleType != NS_STYLE_LIST_STYLE_DISCLOSURE_CLOSED &&
|
|
|
|
listStyleType != NS_STYLE_LIST_STYLE_DISCLOSURE_OPEN) {
|
2014-06-12 05:12:00 +04:00
|
|
|
// The HTML spec states that the default padding for ordered lists
|
|
|
|
// begins at 40px, indicating that we have 40px of space to place a
|
|
|
|
// bullet. When performing font inflation calculations, we add space
|
|
|
|
// equivalent to this, but simply inflated at the same amount as the
|
|
|
|
// text, in app units.
|
|
|
|
return nsPresContext::CSSPixelsToAppUnits(40) * (inflation - 1);
|
|
|
|
}
|
|
|
|
|
2012-07-10 19:46:07 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2013-09-10 00:29:05 +04:00
|
|
|
|
2015-06-04 13:43:02 +03:00
|
|
|
// NOTE: If we ever want to use nsCSSOffsetState for a flex item or a
|
|
|
|
// grid item, we need to make it take the containing-block block-size as
|
|
|
|
// well as the inline-size, since flex items and grid items resolve
|
|
|
|
// block-direction percent margins and padding against the
|
|
|
|
// containing-block block-size, rather than its inline-size.
|
2014-01-21 02:02:18 +04:00
|
|
|
nsCSSOffsetState::nsCSSOffsetState(nsIFrame *aFrame,
|
|
|
|
nsRenderingContext *aRenderingContext,
|
2015-06-11 09:42:56 +03:00
|
|
|
WritingMode aContainingBlockWritingMode,
|
2015-06-04 13:43:02 +03:00
|
|
|
nscoord aContainingBlockISize)
|
2014-01-21 02:02:18 +04:00
|
|
|
: frame(aFrame)
|
|
|
|
, rendContext(aRenderingContext)
|
|
|
|
, mWritingMode(aFrame->GetWritingMode())
|
|
|
|
{
|
2014-05-13 01:16:05 +04:00
|
|
|
MOZ_ASSERT(!aFrame->IsFlexOrGridItem(),
|
2015-06-04 13:43:02 +03:00
|
|
|
"We're about to resolve percent margin & padding "
|
|
|
|
"values against CB inline size, which is incorrect for "
|
|
|
|
"flex/grid items");
|
2015-06-11 09:42:56 +03:00
|
|
|
LogicalSize cbSize(aContainingBlockWritingMode, aContainingBlockISize,
|
2015-06-04 13:43:02 +03:00
|
|
|
aContainingBlockISize);
|
2015-06-11 09:42:56 +03:00
|
|
|
InitOffsets(aContainingBlockWritingMode, cbSize, frame->GetType());
|
2014-01-21 02:02:18 +04:00
|
|
|
}
|
|
|
|
|
2013-09-08 21:34:32 +04:00
|
|
|
// Initialize a reflow state for a child frame's reflow. Some state
|
1999-03-05 07:24:20 +03:00
|
|
|
// is copied from the parent reflow state; the remaining state is
|
|
|
|
// computed.
|
2015-06-04 13:43:02 +03:00
|
|
|
nsHTMLReflowState::nsHTMLReflowState(
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState& aParentReflowState,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
const LogicalSize& aAvailableSpace,
|
|
|
|
const LogicalSize* aContainingBlockSize,
|
|
|
|
uint32_t aFlags)
|
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
|
|
|
: nsCSSOffsetState(aFrame, aParentReflowState.rendContext)
|
2008-02-15 07:14:53 +03:00
|
|
|
, mBlockDelta(0)
|
2014-09-03 19:43:03 +04:00
|
|
|
, mOrthogonalLimit(NS_UNCONSTRAINEDSIZE)
|
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
|
|
|
, mReflowDepth(aParentReflowState.mReflowDepth + 1)
|
|
|
|
, mFlags(aParentReflowState.mFlags)
|
1999-03-05 07:24:20 +03:00
|
|
|
{
|
2014-02-06 13:02:12 +04:00
|
|
|
MOZ_ASSERT(aPresContext, "no pres context");
|
|
|
|
MOZ_ASSERT(aFrame, "no frame");
|
|
|
|
MOZ_ASSERT(aPresContext == aFrame->PresContext(), "wrong pres context");
|
2015-06-22 12:33:34 +03:00
|
|
|
NS_PRECONDITION(!mFlags.mSpecialBSizeReflow ||
|
2007-05-06 23:16:51 +04:00
|
|
|
!NS_SUBTREE_DIRTY(aFrame),
|
2015-06-22 12:33:34 +03:00
|
|
|
"frame should be clean when getting special bsize reflow");
|
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
|
|
|
|
1999-03-05 07:24:20 +03:00
|
|
|
parentReflowState = &aParentReflowState;
|
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 the parent is dirty, then the child is as well.
|
|
|
|
// XXX Are the other cases where the parent reflows a child a second
|
|
|
|
// time, as a resize?
|
2015-06-22 12:33:34 +03:00
|
|
|
if (!mFlags.mSpecialBSizeReflow)
|
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
|
|
|
frame->AddStateBits(parentReflowState->frame->GetStateBits() &
|
|
|
|
NS_FRAME_IS_DIRTY);
|
2002-05-10 22:22:41 +04:00
|
|
|
|
2014-07-24 12:28:46 +04:00
|
|
|
AvailableISize() = aAvailableSpace.ISize(mWritingMode);
|
|
|
|
AvailableBSize() = aAvailableSpace.BSize(mWritingMode);
|
1999-03-05 07:24:20 +03:00
|
|
|
|
2014-11-25 00:44:06 +03:00
|
|
|
if (mWritingMode.IsOrthogonalTo(aParentReflowState.GetWritingMode())) {
|
|
|
|
// If we're setting up for an orthogonal flow, and the parent reflow state
|
|
|
|
// had a constrained ComputedBSize, we can use that as our AvailableISize
|
|
|
|
// in preference to leaving it unconstrained.
|
|
|
|
if (AvailableISize() == NS_UNCONSTRAINEDSIZE &&
|
|
|
|
aParentReflowState.ComputedBSize() != NS_UNCONSTRAINEDSIZE) {
|
|
|
|
AvailableISize() = aParentReflowState.ComputedBSize();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-05 03:39:54 +03:00
|
|
|
mFloatManager = aParentReflowState.mFloatManager;
|
2007-05-18 10:04:04 +04:00
|
|
|
if (frame->IsFrameOfType(nsIFrame::eLineParticipant))
|
|
|
|
mLineLayout = aParentReflowState.mLineLayout;
|
|
|
|
else
|
2012-07-30 18:20:58 +04:00
|
|
|
mLineLayout = nullptr;
|
2011-10-22 00:41:12 +04:00
|
|
|
|
|
|
|
// Note: mFlags was initialized as a copy of aParentReflowState.mFlags up in
|
|
|
|
// this constructor's init list, so the only flags that we need to explicitly
|
|
|
|
// initialize here are those that may need a value other than our parent's.
|
2004-10-08 16:17:10 +04:00
|
|
|
mFlags.mNextInFlowUntouched = aParentReflowState.mFlags.mNextInFlowUntouched &&
|
|
|
|
CheckNextInFlowParenthood(aFrame, aParentReflowState.frame);
|
2011-10-17 18:59:28 +04:00
|
|
|
mFlags.mAssumingHScrollbar = mFlags.mAssumingVScrollbar = false;
|
2012-02-13 01:21:51 +04:00
|
|
|
mFlags.mIsColumnBalancing = false;
|
2012-09-30 10:38:46 +04:00
|
|
|
mFlags.mIsFlexContainerMeasuringHeight = false;
|
2012-06-13 23:49:41 +04:00
|
|
|
mFlags.mDummyParentReflowState = false;
|
2011-10-22 00:41:12 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
mDiscoveredClearance = nullptr;
|
2015-06-22 12:33:34 +03:00
|
|
|
mPercentBSizeObserver = (aParentReflowState.mPercentBSizeObserver &&
|
|
|
|
aParentReflowState.mPercentBSizeObserver->NeedsToObserve(*this))
|
|
|
|
? aParentReflowState.mPercentBSizeObserver : nullptr;
|
1999-03-05 07:24:20 +03:00
|
|
|
|
2014-07-04 15:48:15 +04:00
|
|
|
if ((aFlags & DUMMY_PARENT_REFLOW_STATE) ||
|
|
|
|
(parentReflowState->mFlags.mDummyParentReflowState &&
|
|
|
|
frame->GetType() == nsGkAtoms::tableFrame)) {
|
2013-09-10 00:29:05 +04:00
|
|
|
mFlags.mDummyParentReflowState = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(aFlags & CALLER_WILL_INIT)) {
|
2015-06-04 13:43:02 +03:00
|
|
|
Init(aPresContext, aContainingBlockSize);
|
2002-02-19 18:48:28 +03:00
|
|
|
}
|
1999-03-05 07:24:20 +03:00
|
|
|
}
|
|
|
|
|
2007-05-04 03:11:00 +04:00
|
|
|
inline nscoord
|
2015-06-04 13:43:02 +03:00
|
|
|
nsCSSOffsetState::ComputeISizeValue(nscoord aContainingBlockISize,
|
2007-05-04 03:11:00 +04:00
|
|
|
nscoord aContentEdgeToBoxSizing,
|
|
|
|
nscoord aBoxSizingToMarginEdge,
|
|
|
|
const nsStyleCoord& aCoord)
|
|
|
|
{
|
2015-06-04 13:43:02 +03:00
|
|
|
return nsLayoutUtils::ComputeISizeValue(rendContext, frame,
|
|
|
|
aContainingBlockISize,
|
2007-05-04 03:11:00 +04:00
|
|
|
aContentEdgeToBoxSizing,
|
|
|
|
aBoxSizingToMarginEdge,
|
|
|
|
aCoord);
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord
|
2015-06-04 13:43:02 +03:00
|
|
|
nsCSSOffsetState::ComputeISizeValue(nscoord aContainingBlockISize,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t aBoxSizing,
|
2007-05-04 03:11:00 +04:00
|
|
|
const nsStyleCoord& aCoord)
|
|
|
|
{
|
2015-06-04 13:43:02 +03:00
|
|
|
WritingMode wm = GetWritingMode();
|
|
|
|
nscoord inside = 0, outside = ComputedLogicalBorderPadding().IStartEnd(wm) +
|
|
|
|
ComputedLogicalMargin().IStartEnd(wm);
|
2015-05-29 22:16:53 +03:00
|
|
|
switch (aBoxSizing) {
|
|
|
|
case NS_STYLE_BOX_SIZING_BORDER:
|
2015-06-04 13:43:02 +03:00
|
|
|
inside = ComputedLogicalBorderPadding().IStartEnd(wm);
|
2015-05-29 22:16:53 +03:00
|
|
|
break;
|
|
|
|
case NS_STYLE_BOX_SIZING_PADDING:
|
2015-06-04 13:43:02 +03:00
|
|
|
inside = ComputedLogicalPadding().IStartEnd(wm);
|
2015-05-29 22:16:53 +03:00
|
|
|
break;
|
2007-05-04 03:11:00 +04:00
|
|
|
}
|
|
|
|
outside -= inside;
|
|
|
|
|
2015-06-04 13:43:02 +03:00
|
|
|
return ComputeISizeValue(aContainingBlockISize, inside,
|
2007-05-04 03:11:00 +04:00
|
|
|
outside, aCoord);
|
|
|
|
}
|
|
|
|
|
2012-08-08 19:58:26 +04:00
|
|
|
nscoord
|
2015-06-04 13:43:02 +03:00
|
|
|
nsCSSOffsetState::ComputeBSizeValue(nscoord aContainingBlockBSize,
|
|
|
|
uint8_t aBoxSizing,
|
|
|
|
const nsStyleCoord& aCoord)
|
2012-08-08 19:58:26 +04:00
|
|
|
{
|
2015-06-04 13:43:02 +03:00
|
|
|
WritingMode wm = GetWritingMode();
|
2012-08-08 19:58:26 +04:00
|
|
|
nscoord inside = 0;
|
2015-05-29 22:16:53 +03:00
|
|
|
switch (aBoxSizing) {
|
|
|
|
case NS_STYLE_BOX_SIZING_BORDER:
|
2015-06-04 13:43:02 +03:00
|
|
|
inside = ComputedLogicalBorderPadding().BStartEnd(wm);
|
2015-05-29 22:16:53 +03:00
|
|
|
break;
|
|
|
|
case NS_STYLE_BOX_SIZING_PADDING:
|
2015-06-04 13:43:02 +03:00
|
|
|
inside = ComputedLogicalPadding().BStartEnd(wm);
|
2015-05-29 22:16:53 +03:00
|
|
|
break;
|
2012-08-08 19:58:26 +04:00
|
|
|
}
|
2015-06-04 13:43:02 +03:00
|
|
|
return nsLayoutUtils::ComputeBSizeValue(aContainingBlockBSize,
|
|
|
|
inside, aCoord);
|
2012-08-08 19:58:26 +04:00
|
|
|
}
|
|
|
|
|
2007-01-26 03:05:12 +03:00
|
|
|
void
|
|
|
|
nsHTMLReflowState::SetComputedWidth(nscoord aComputedWidth)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(frame, "Must have a frame!");
|
2007-01-26 08:02:31 +03:00
|
|
|
// It'd be nice to assert that |frame| is not in reflow, but this fails for
|
|
|
|
// two reasons:
|
|
|
|
//
|
|
|
|
// 1) Viewport frames reset the computed width on a copy of their reflow
|
|
|
|
// state when reflowing fixed-pos kids. In that case we actually don't
|
|
|
|
// want to mess with the resize flags, because comparing the frame's rect
|
|
|
|
// to the munged computed width is pointless.
|
|
|
|
// 2) nsFrame::BoxReflow creates a reflow state for its parent. This reflow
|
|
|
|
// state is not used to reflow the parent, but just as a parent for the
|
|
|
|
// frame's own reflow state. So given a nsBoxFrame inside some non-XUL
|
|
|
|
// (like a text control, for example), we'll end up creating a reflow
|
|
|
|
// state for the parent while the parent is reflowing.
|
|
|
|
|
2007-05-05 10:13:48 +04:00
|
|
|
NS_PRECONDITION(aComputedWidth >= 0, "Invalid computed width");
|
2013-12-27 21:59:21 +04:00
|
|
|
if (ComputedWidth() != aComputedWidth) {
|
|
|
|
ComputedWidth() = aComputedWidth;
|
2011-06-11 03:02:14 +04:00
|
|
|
nsIAtom* frameType = frame->GetType();
|
|
|
|
if (frameType != nsGkAtoms::viewportFrame) { // Or check GetParent()?
|
|
|
|
InitResizeFlags(frame->PresContext(), frameType);
|
2007-05-05 10:13:48 +04:00
|
|
|
}
|
2007-01-26 03:05:12 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-02 22:08:05 +04:00
|
|
|
void
|
|
|
|
nsHTMLReflowState::SetComputedHeight(nscoord aComputedHeight)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(frame, "Must have a frame!");
|
2009-01-29 23:39:22 +03:00
|
|
|
// It'd be nice to assert that |frame| is not in reflow, but this fails
|
|
|
|
// because:
|
2007-08-02 22:08:05 +04:00
|
|
|
//
|
2009-01-29 23:39:22 +03:00
|
|
|
// nsFrame::BoxReflow creates a reflow state for its parent. This reflow
|
2007-08-02 22:08:05 +04:00
|
|
|
// state is not used to reflow the parent, but just as a parent for the
|
|
|
|
// frame's own reflow state. So given a nsBoxFrame inside some non-XUL
|
|
|
|
// (like a text control, for example), we'll end up creating a reflow
|
|
|
|
// state for the parent while the parent is reflowing.
|
|
|
|
|
|
|
|
NS_PRECONDITION(aComputedHeight >= 0, "Invalid computed height");
|
2013-12-27 21:59:21 +04:00
|
|
|
if (ComputedHeight() != aComputedHeight) {
|
|
|
|
ComputedHeight() = aComputedHeight;
|
2011-06-11 03:02:14 +04:00
|
|
|
InitResizeFlags(frame->PresContext(), frame->GetType());
|
2007-08-02 22:08:05 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-03-05 07:24:20 +03:00
|
|
|
void
|
2015-06-04 13:43:02 +03:00
|
|
|
nsHTMLReflowState::Init(nsPresContext* aPresContext,
|
|
|
|
const LogicalSize* aContainingBlockSize,
|
|
|
|
const nsMargin* aBorder,
|
|
|
|
const nsMargin* aPadding)
|
1999-03-05 07:24:20 +03:00
|
|
|
{
|
2014-09-03 19:43:03 +04:00
|
|
|
if (AvailableISize() == NS_UNCONSTRAINEDSIZE) {
|
|
|
|
// Look up the parent chain for an orthogonal inline limit,
|
|
|
|
// and reset AvailableISize() if found.
|
|
|
|
for (const nsHTMLReflowState *parent = parentReflowState;
|
|
|
|
parent != nullptr; parent = parent->parentReflowState) {
|
|
|
|
if (parent->GetWritingMode().IsOrthogonalTo(mWritingMode) &&
|
|
|
|
parent->mOrthogonalLimit != NS_UNCONSTRAINEDSIZE) {
|
|
|
|
AvailableISize() = parent->mOrthogonalLimit;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-16 02:36:11 +03:00
|
|
|
LAYOUT_WARN_IF_FALSE(AvailableISize() != NS_UNCONSTRAINEDSIZE,
|
2015-06-16 02:36:12 +03:00
|
|
|
"have unconstrained inline-size; this should only "
|
|
|
|
"result from very large sizes, not attempts at "
|
|
|
|
"intrinsic inline-size calculation");
|
1999-03-05 07:24:20 +03:00
|
|
|
|
2013-02-17 01:51:02 +04:00
|
|
|
mStylePosition = frame->StylePosition();
|
|
|
|
mStyleDisplay = frame->StyleDisplay();
|
|
|
|
mStyleVisibility = frame->StyleVisibility();
|
|
|
|
mStyleBorder = frame->StyleBorder();
|
|
|
|
mStyleMargin = frame->StyleMargin();
|
|
|
|
mStylePadding = frame->StylePadding();
|
|
|
|
mStyleText = frame->StyleText();
|
2001-11-28 08:06:17 +03:00
|
|
|
|
2011-06-11 03:02:14 +04:00
|
|
|
nsIAtom* type = frame->GetType();
|
|
|
|
|
|
|
|
InitFrameType(type);
|
2002-05-14 16:59:55 +04:00
|
|
|
InitCBReflowState();
|
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
|
|
|
|
2015-06-04 13:43:02 +03:00
|
|
|
LogicalSize cbSize(mWritingMode, -1, -1);
|
|
|
|
if (aContainingBlockSize) {
|
|
|
|
cbSize = *aContainingBlockSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
InitConstraints(aPresContext, cbSize, aBorder, aPadding, type);
|
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
|
|
|
|
2011-06-11 03:02:14 +04:00
|
|
|
InitResizeFlags(aPresContext, type);
|
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
|
|
|
|
2011-11-24 06:48:23 +04:00
|
|
|
nsIFrame *parent = frame->GetParent();
|
|
|
|
if (parent &&
|
2015-03-10 17:28:23 +03:00
|
|
|
(parent->GetStateBits() & NS_FRAME_IN_CONSTRAINED_BSIZE) &&
|
2011-11-24 06:48:23 +04:00
|
|
|
!(parent->GetType() == nsGkAtoms::scrollFrame &&
|
2013-02-17 01:51:02 +04:00
|
|
|
parent->StyleDisplay()->mOverflowY != NS_STYLE_OVERFLOW_HIDDEN)) {
|
2015-03-10 17:28:23 +03:00
|
|
|
frame->AddStateBits(NS_FRAME_IN_CONSTRAINED_BSIZE);
|
2012-06-11 03:44:50 +04:00
|
|
|
} else if (type == nsGkAtoms::svgForeignObjectFrame) {
|
2015-03-10 17:28:23 +03:00
|
|
|
// An SVG foreignObject frame is inherently constrained block-size.
|
|
|
|
frame->AddStateBits(NS_FRAME_IN_CONSTRAINED_BSIZE);
|
|
|
|
} else {
|
2015-05-11 13:37:46 +03:00
|
|
|
const nsStyleCoord& bSizeCoord = mStylePosition->BSize(mWritingMode);
|
|
|
|
const nsStyleCoord& maxBSizeCoord = mStylePosition->MaxBSize(mWritingMode);
|
2015-03-10 17:28:23 +03:00
|
|
|
if ((bSizeCoord.GetUnit() != eStyleUnit_Auto ||
|
|
|
|
maxBSizeCoord.GetUnit() != eStyleUnit_None) &&
|
|
|
|
// Don't set NS_FRAME_IN_CONSTRAINED_BSIZE on body or html elements.
|
|
|
|
(frame->GetContent() &&
|
|
|
|
!(frame->GetContent()->IsAnyOfHTMLElements(nsGkAtoms::body,
|
|
|
|
nsGkAtoms::html)))) {
|
|
|
|
|
|
|
|
// If our block-size was specified as a percentage, then this could
|
|
|
|
// actually resolve to 'auto', based on:
|
|
|
|
// http://www.w3.org/TR/CSS21/visudet.html#the-height-property
|
|
|
|
nsIFrame* containingBlk = frame;
|
|
|
|
while (containingBlk) {
|
|
|
|
const nsStylePosition* stylePos = containingBlk->StylePosition();
|
2015-05-11 13:37:46 +03:00
|
|
|
const nsStyleCoord& bSizeCoord = stylePos->BSize(mWritingMode);
|
|
|
|
const nsStyleCoord& maxBSizeCoord = stylePos->MaxBSize(mWritingMode);
|
2015-03-10 17:28:23 +03:00
|
|
|
if ((bSizeCoord.IsCoordPercentCalcUnit() &&
|
|
|
|
!bSizeCoord.HasPercent()) ||
|
|
|
|
(maxBSizeCoord.IsCoordPercentCalcUnit() &&
|
|
|
|
!maxBSizeCoord.HasPercent())) {
|
|
|
|
frame->AddStateBits(NS_FRAME_IN_CONSTRAINED_BSIZE);
|
|
|
|
break;
|
|
|
|
} else if ((bSizeCoord.IsCoordPercentCalcUnit() &&
|
|
|
|
bSizeCoord.HasPercent()) ||
|
|
|
|
(maxBSizeCoord.IsCoordPercentCalcUnit() &&
|
|
|
|
maxBSizeCoord.HasPercent())) {
|
|
|
|
if (!(containingBlk = containingBlk->GetContainingBlock())) {
|
|
|
|
// If we've reached the top of the tree, then we don't have
|
|
|
|
// a constrained block-size.
|
|
|
|
frame->RemoveStateBits(NS_FRAME_IN_CONSTRAINED_BSIZE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
continue;
|
|
|
|
} else {
|
|
|
|
frame->RemoveStateBits(NS_FRAME_IN_CONSTRAINED_BSIZE);
|
2012-05-04 21:07:37 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2015-03-10 17:28:23 +03:00
|
|
|
} else {
|
|
|
|
frame->RemoveStateBits(NS_FRAME_IN_CONSTRAINED_BSIZE);
|
2012-05-04 21:07:37 +04:00
|
|
|
}
|
2011-11-24 06:48:23 +04:00
|
|
|
}
|
|
|
|
|
2015-06-19 11:09:19 +03:00
|
|
|
if (parentReflowState &&
|
2015-06-03 13:17:24 +03:00
|
|
|
parentReflowState->GetWritingMode().IsOrthogonalTo(mWritingMode)) {
|
2015-06-19 11:09:19 +03:00
|
|
|
// Orthogonal frames are always reflowed with an unconstrained
|
|
|
|
// dimension to avoid incomplete reflow across an orthogonal
|
|
|
|
// boundary. Normally this is the block-size, but for column sets
|
|
|
|
// with auto-height it's the inline-size, so that they can add
|
|
|
|
// columns in the container's block direction
|
|
|
|
if (type == nsGkAtoms::columnSetFrame &&
|
|
|
|
eStyleUnit_Auto == mStylePosition->ISize(mWritingMode).GetUnit()) {
|
|
|
|
ComputedISize() = NS_UNCONSTRAINEDSIZE;
|
|
|
|
} else {
|
|
|
|
AvailableBSize() = NS_UNCONSTRAINEDSIZE;
|
|
|
|
}
|
2015-06-03 13:17:24 +03:00
|
|
|
}
|
|
|
|
|
2015-06-16 02:36:11 +03:00
|
|
|
LAYOUT_WARN_IF_FALSE((mFrameType == NS_CSS_FRAME_TYPE_INLINE &&
|
2015-06-16 02:36:12 +03:00
|
|
|
!frame->IsFrameOfType(nsIFrame::eReplaced)) ||
|
|
|
|
type == nsGkAtoms::textFrame ||
|
|
|
|
ComputedISize() != NS_UNCONSTRAINEDSIZE,
|
|
|
|
"have unconstrained inline-size; this should only "
|
|
|
|
"result from very large sizes, not attempts at "
|
|
|
|
"intrinsic inline-size calculation");
|
1999-03-05 07:24:20 +03:00
|
|
|
}
|
|
|
|
|
2002-05-14 16:59:55 +04:00
|
|
|
void nsHTMLReflowState::InitCBReflowState()
|
1999-01-05 22:44:41 +03:00
|
|
|
{
|
2004-04-24 21:56:23 +04:00
|
|
|
if (!parentReflowState) {
|
2012-07-30 18:20:58 +04:00
|
|
|
mCBReflowState = nullptr;
|
2004-04-24 21:56:23 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-05-12 08:04:30 +04:00
|
|
|
if (parentReflowState->frame == frame->GetContainingBlock()) {
|
|
|
|
// Inner table frames need to use the containing block of the outer
|
|
|
|
// table frame.
|
|
|
|
if (frame->GetType() == nsGkAtoms::tableFrame) {
|
|
|
|
mCBReflowState = parentReflowState->mCBReflowState;
|
2004-04-24 21:56:23 +04:00
|
|
|
} else {
|
|
|
|
mCBReflowState = parentReflowState;
|
1999-01-05 22:44:41 +03:00
|
|
|
}
|
2011-05-12 08:04:30 +04:00
|
|
|
} else {
|
|
|
|
mCBReflowState = parentReflowState->mCBReflowState;
|
1999-01-05 22:44:41 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-16 01:52:44 +04:00
|
|
|
/* Check whether CalcQuirkContainingBlockHeight would stop on the
|
2015-07-17 19:04:24 +03:00
|
|
|
* given reflow state, using its block as a height. (essentially
|
|
|
|
* returns false for any case in which CalcQuirkContainingBlockHeight
|
2007-05-16 01:52:44 +04:00
|
|
|
* has a "continue" in its main loop.)
|
|
|
|
*
|
2015-07-17 19:04:24 +03:00
|
|
|
* XXX Maybe refactor CalcQuirkContainingBlockHeight so it uses
|
2007-05-16 01:52:44 +04:00
|
|
|
* this function as well
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool
|
2011-06-11 03:02:14 +04:00
|
|
|
IsQuirkContainingBlockHeight(const nsHTMLReflowState* rs, nsIAtom* aFrameType)
|
2007-05-16 01:52:44 +04:00
|
|
|
{
|
2011-06-11 03:02:14 +04:00
|
|
|
if (nsGkAtoms::blockFrame == aFrameType ||
|
2008-12-29 18:07:38 +03:00
|
|
|
#ifdef MOZ_XUL
|
2011-06-11 03:02:14 +04:00
|
|
|
nsGkAtoms::XULLabelFrame == aFrameType ||
|
2008-12-29 18:07:38 +03:00
|
|
|
#endif
|
2011-06-11 03:02:14 +04:00
|
|
|
nsGkAtoms::scrollFrame == aFrameType) {
|
2007-05-16 01:52:44 +04:00
|
|
|
// Note: This next condition could change due to a style change,
|
|
|
|
// but that would cause a style reflow anyway, which means we're ok.
|
2007-08-02 22:08:05 +04:00
|
|
|
if (NS_AUTOHEIGHT == rs->ComputedHeight()) {
|
2012-08-02 15:38:50 +04:00
|
|
|
if (!rs->frame->IsAbsolutelyPositioned()) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2007-05-16 01:52:44 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2007-05-16 01:52:44 +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
|
|
|
void
|
2011-06-11 03:02:14 +04:00
|
|
|
nsHTMLReflowState::InitResizeFlags(nsPresContext* aPresContext, nsIAtom* aFrameType)
|
1999-01-05 22:44:41 +03:00
|
|
|
{
|
2015-06-18 09:33:50 +03:00
|
|
|
const WritingMode wm = mWritingMode; // just a shorthand
|
2015-11-05 07:55:16 +03:00
|
|
|
bool isIResize =
|
|
|
|
frame->ISize(wm) !=
|
|
|
|
ComputedISize() + ComputedLogicalBorderPadding().IStartEnd(wm);
|
2012-06-12 00:57:35 +04:00
|
|
|
|
|
|
|
if ((frame->GetStateBits() & NS_FRAME_FONT_INFLATION_FLOW_ROOT) &&
|
2012-06-11 04:36:18 +04:00
|
|
|
nsLayoutUtils::FontSizeInflationEnabled(aPresContext)) {
|
2012-06-12 00:57:35 +04:00
|
|
|
// Create our font inflation data if we don't have it already, and
|
|
|
|
// give it our current width information.
|
2015-03-10 17:28:23 +03:00
|
|
|
bool dirty = nsFontInflationData::UpdateFontInflationDataISizeFor(*this) &&
|
2013-06-04 19:43:08 +04:00
|
|
|
// Avoid running this at the box-to-block interface
|
|
|
|
// (where we shouldn't be inflating anyway, and where
|
|
|
|
// reflow state construction is probably to construct a
|
|
|
|
// dummy parent reflow state anyway).
|
|
|
|
!mFlags.mDummyParentReflowState;
|
2012-06-13 23:49:41 +04:00
|
|
|
|
2015-06-18 09:33:50 +03:00
|
|
|
if (dirty || (!frame->GetParent() && isIResize)) {
|
2012-06-12 00:57:35 +04:00
|
|
|
// When font size inflation is enabled, a change in either:
|
|
|
|
// * the effective width of a font inflation flow root
|
|
|
|
// * the width of the frame
|
|
|
|
// needs to cause a dirty reflow since they change the font size
|
|
|
|
// inflation calculations, which in turn change the size of text,
|
|
|
|
// line-heights, etc. This is relatively similar to a classic
|
|
|
|
// case of style change reflow, except that because inflation
|
|
|
|
// doesn't affect the intrinsic sizing codepath, there's no need
|
|
|
|
// to invalidate intrinsic sizes.
|
|
|
|
//
|
|
|
|
// Note that this makes horizontal resizing a good bit more
|
|
|
|
// expensive. However, font size inflation is targeted at a set of
|
|
|
|
// devices (zoom-and-pan devices) where the main use case for
|
|
|
|
// horizontal resizing needing to be efficient (window resizing) is
|
|
|
|
// not present. It does still increase the cost of dynamic changes
|
|
|
|
// caused by script where a style or content change in one place
|
|
|
|
// causes a resize in another (e.g., rebalancing a table).
|
|
|
|
|
|
|
|
// FIXME: This isn't so great for the cases where
|
|
|
|
// nsHTMLReflowState::SetComputedWidth is called, if the first time
|
2014-11-28 12:44:02 +03:00
|
|
|
// we go through InitResizeFlags we set IsHResize() to true, and then
|
2012-06-12 00:57:35 +04:00
|
|
|
// the second time we'd set it to false even without the
|
|
|
|
// NS_FRAME_IS_DIRTY bit already set.
|
|
|
|
if (frame->GetType() == nsGkAtoms::svgForeignObjectFrame) {
|
|
|
|
// Foreign object frames use dirty bits in a special way.
|
|
|
|
frame->AddStateBits(NS_FRAME_HAS_DIRTY_CHILDREN);
|
|
|
|
nsIFrame *kid = frame->GetFirstPrincipalChild();
|
|
|
|
if (kid) {
|
|
|
|
kid->AddStateBits(NS_FRAME_IS_DIRTY);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
frame->AddStateBits(NS_FRAME_IS_DIRTY);
|
|
|
|
}
|
2012-06-12 00:57:35 +04:00
|
|
|
|
|
|
|
// Mark intrinsic widths on all descendants dirty. We need to do
|
|
|
|
// this (1) since we're changing the size of text and need to
|
|
|
|
// clear text runs on text frames and (2) since we actually are
|
|
|
|
// changing some intrinsic widths, but only those that live inside
|
|
|
|
// of containers.
|
|
|
|
|
|
|
|
// It makes sense to do this for descendants but not ancestors
|
|
|
|
// (which is unusual) because we're only changing the unusual
|
|
|
|
// inflation-dependent intrinsic widths (i.e., ones computed with
|
|
|
|
// nsPresContext::mInflationDisabledForShrinkWrap set to false),
|
|
|
|
// which should never affect anything outside of their inflation
|
|
|
|
// flow root (or, for that matter, even their inflation
|
|
|
|
// container).
|
|
|
|
|
|
|
|
// This is also different from what PresShell::FrameNeedsReflow
|
|
|
|
// does because it doesn't go through placeholders. It doesn't
|
|
|
|
// need to because we're actually doing something that cares about
|
|
|
|
// frame tree geometry (the width on an ancestor) rather than
|
|
|
|
// style.
|
|
|
|
|
|
|
|
nsAutoTArray<nsIFrame*, 32> stack;
|
|
|
|
stack.AppendElement(frame);
|
|
|
|
|
|
|
|
do {
|
|
|
|
nsIFrame *f = stack.ElementAt(stack.Length() - 1);
|
|
|
|
stack.RemoveElementAt(stack.Length() - 1);
|
|
|
|
|
|
|
|
nsIFrame::ChildListIterator lists(f);
|
|
|
|
for (; !lists.IsDone(); lists.Next()) {
|
|
|
|
nsFrameList::Enumerator childFrames(lists.CurrentList());
|
|
|
|
for (; !childFrames.AtEnd(); childFrames.Next()) {
|
|
|
|
nsIFrame* kid = childFrames.get();
|
2014-07-24 21:03:26 +04:00
|
|
|
kid->MarkIntrinsicISizesDirty();
|
2012-06-12 00:57:35 +04:00
|
|
|
stack.AppendElement(kid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while (stack.Length() != 0);
|
2012-06-12 00:57:35 +04:00
|
|
|
}
|
2012-06-11 04:36:18 +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
|
|
|
|
2015-06-18 09:33:50 +03:00
|
|
|
SetIResize(!(frame->GetStateBits() & NS_FRAME_IS_DIRTY) &&
|
|
|
|
isIResize);
|
2012-06-12 00:57:35 +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
|
|
|
// XXX Should we really need to null check mCBReflowState? (We do for
|
|
|
|
// at least nsBoxFrame).
|
2011-06-11 03:02:14 +04:00
|
|
|
if (IS_TABLE_CELL(aFrameType) &&
|
2015-06-22 12:33:34 +03:00
|
|
|
(mFlags.mSpecialBSizeReflow ||
|
2013-09-25 15:42:34 +04:00
|
|
|
(frame->FirstInFlow()->GetStateBits() &
|
2007-06-19 03:19:39 +04:00
|
|
|
NS_TABLE_CELL_HAD_SPECIAL_REFLOW)) &&
|
2015-06-18 09:33:50 +03:00
|
|
|
(frame->GetStateBits() & NS_FRAME_CONTAINS_RELATIVE_BSIZE)) {
|
2007-06-19 03:19:39 +04:00
|
|
|
// Need to set the bit on the cell so that
|
2015-06-18 09:33:50 +03:00
|
|
|
// mCBReflowState->IsBResize() is set correctly below when
|
2007-06-19 03:19:39 +04:00
|
|
|
// reflowing descendant.
|
2015-06-18 09:33:50 +03:00
|
|
|
SetBResize(true);
|
2015-10-21 06:27:50 +03:00
|
|
|
} else if (mCBReflowState && frame->IsBlockWrapper()) {
|
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
|
|
|
// XXX Is this problematic for relatively positioned inlines acting
|
|
|
|
// as containing block for absolutely positioned elements?
|
2010-03-04 02:53:18 +03:00
|
|
|
// Possibly; in that case we should at least be checking
|
|
|
|
// NS_SUBTREE_DIRTY, I'd think.
|
2015-06-18 09:33:50 +03:00
|
|
|
SetBResize(mCBReflowState->IsBResize());
|
|
|
|
} else if (ComputedBSize() == NS_AUTOHEIGHT) {
|
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 (eCompatibility_NavQuirks == aPresContext->CompatibilityMode() &&
|
|
|
|
mCBReflowState) {
|
2015-06-18 09:33:50 +03:00
|
|
|
SetBResize(mCBReflowState->IsBResize());
|
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
|
|
|
} else {
|
2015-06-18 09:33:50 +03:00
|
|
|
SetBResize(IsIResize());
|
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
|
|
|
}
|
2015-06-18 09:33:50 +03:00
|
|
|
SetBResize(IsBResize() || NS_SUBTREE_DIRTY(frame));
|
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
|
|
|
} else {
|
2015-06-18 09:33:50 +03:00
|
|
|
// not 'auto' block-size
|
|
|
|
SetBResize(frame->BSize(wm) !=
|
|
|
|
ComputedBSize() + ComputedLogicalBorderPadding().BStartEnd(wm));
|
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
|
|
|
}
|
|
|
|
|
2015-06-18 09:33:50 +03:00
|
|
|
bool dependsOnCBBSize =
|
|
|
|
(mStylePosition->BSizeDependsOnContainer(wm) &&
|
2010-08-25 14:17:55 +04:00
|
|
|
// FIXME: condition this on not-abspos?
|
2015-06-18 09:33:50 +03:00
|
|
|
mStylePosition->BSize(wm).GetUnit() != eStyleUnit_Auto) ||
|
|
|
|
mStylePosition->MinBSizeDependsOnContainer(wm) ||
|
|
|
|
mStylePosition->MaxBSizeDependsOnContainer(wm) ||
|
|
|
|
mStylePosition->OffsetHasPercent(wm.PhysicalSide(eLogicalSideBStart)) ||
|
|
|
|
mStylePosition->mOffset.GetBEndUnit(wm) != eStyleUnit_Auto ||
|
2011-06-13 05:52:32 +04:00
|
|
|
frame->IsBoxFrame();
|
2007-06-19 03:19:39 +04:00
|
|
|
|
2009-06-20 05:39:40 +04:00
|
|
|
if (mStyleText->mLineHeight.GetUnit() == eStyleUnit_Enumerated) {
|
|
|
|
NS_ASSERTION(mStyleText->mLineHeight.GetIntValue() ==
|
|
|
|
NS_STYLE_LINE_HEIGHT_BLOCK_HEIGHT,
|
|
|
|
"bad line-height value");
|
|
|
|
|
2015-06-18 09:33:50 +03:00
|
|
|
// line-height depends on block bsize
|
|
|
|
frame->AddStateBits(NS_FRAME_CONTAINS_RELATIVE_BSIZE);
|
2009-06-20 05:39:40 +04:00
|
|
|
// but only on containing blocks if this frame is not a suitable block
|
2015-06-18 09:33:50 +03:00
|
|
|
dependsOnCBBSize |= !nsLayoutUtils::IsNonWrapperBlock(frame);
|
2009-06-20 05:39:40 +04:00
|
|
|
}
|
|
|
|
|
2015-06-22 12:33:34 +03:00
|
|
|
// If we're the descendant of a table cell that performs special bsize
|
2007-06-19 03:19:39 +04:00
|
|
|
// reflows and we could be the child that requires them, always set
|
2015-06-18 09:33:50 +03:00
|
|
|
// the block-axis resize in case this is the first pass before the
|
2015-06-22 12:33:34 +03:00
|
|
|
// special bsize reflow. However, don't do this if it actually is
|
|
|
|
// the special bsize reflow, since in that case it will already be
|
2008-11-26 00:27:53 +03:00
|
|
|
// set correctly above if we need it set.
|
2015-06-18 09:33:50 +03:00
|
|
|
if (!IsBResize() && mCBReflowState &&
|
2015-07-17 19:04:24 +03:00
|
|
|
(IS_TABLE_CELL(mCBReflowState->frame->GetType()) ||
|
2008-02-22 00:02:07 +03:00
|
|
|
mCBReflowState->mFlags.mHeightDependsOnAncestorCell) &&
|
2015-07-17 19:04:24 +03:00
|
|
|
!mCBReflowState->mFlags.mSpecialBSizeReflow &&
|
2015-06-18 09:33:50 +03:00
|
|
|
dependsOnCBBSize) {
|
|
|
|
SetBResize(true);
|
2011-10-17 18:59:28 +04:00
|
|
|
mFlags.mHeightDependsOnAncestorCell = true;
|
2008-02-22 00:02:07 +03:00
|
|
|
}
|
2007-06-19 03:19:39 +04:00
|
|
|
|
2015-06-18 09:33:50 +03:00
|
|
|
// Set NS_FRAME_CONTAINS_RELATIVE_BSIZE if it's needed.
|
2007-06-19 03:19:39 +04:00
|
|
|
|
2015-06-18 09:33:50 +03:00
|
|
|
// It would be nice to check that |ComputedBSize != NS_AUTOHEIGHT|
|
|
|
|
// &&ed with the percentage bsize check. However, this doesn't get
|
2015-06-22 12:33:34 +03:00
|
|
|
// along with table special bsize reflows, since a special bsize
|
2015-06-18 09:33:50 +03:00
|
|
|
// reflow (a quirk that makes such percentage height work on children
|
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
|
|
|
// of table cells) can cause not just a single percentage height to
|
2015-06-18 09:33:50 +03:00
|
|
|
// become fixed, but an entire descendant chain of percentage height
|
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
|
|
|
// to become fixed.
|
2015-06-18 09:33:50 +03:00
|
|
|
if (dependsOnCBBSize && mCBReflowState) {
|
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
|
|
|
const nsHTMLReflowState *rs = this;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool hitCBReflowState = false;
|
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 {
|
|
|
|
rs = rs->parentReflowState;
|
2007-05-16 01:52:44 +04:00
|
|
|
if (!rs) {
|
|
|
|
break;
|
|
|
|
}
|
2015-07-17 19:04:24 +03:00
|
|
|
|
2015-06-18 09:33:50 +03:00
|
|
|
if (rs->frame->GetStateBits() & NS_FRAME_CONTAINS_RELATIVE_BSIZE)
|
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
|
|
|
break; // no need to go further
|
2015-06-18 09:33:50 +03:00
|
|
|
rs->frame->AddStateBits(NS_FRAME_CONTAINS_RELATIVE_BSIZE);
|
2015-07-17 19:04:24 +03:00
|
|
|
|
2007-05-16 01:52:44 +04:00
|
|
|
// Keep track of whether we've hit the containing block, because
|
|
|
|
// we need to go at least that far.
|
|
|
|
if (rs == mCBReflowState) {
|
2011-10-17 18:59:28 +04:00
|
|
|
hitCBReflowState = true;
|
2007-05-16 01:52:44 +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
|
|
|
|
2015-06-18 09:33:50 +03:00
|
|
|
// XXX What about orthogonal flows? It doesn't make sense to
|
|
|
|
// keep propagating this bit across an orthogonal boundary,
|
|
|
|
// where the meaning of BSize changes. Bug 1175517.
|
2007-05-16 01:52:44 +04:00
|
|
|
} while (!hitCBReflowState ||
|
|
|
|
(eCompatibility_NavQuirks == aPresContext->CompatibilityMode() &&
|
2011-06-11 03:02:14 +04:00
|
|
|
!IsQuirkContainingBlockHeight(rs, rs->frame->GetType())));
|
2007-05-16 01:52:44 +04:00
|
|
|
// Note: We actually don't need to set the
|
2015-06-18 09:33:50 +03:00
|
|
|
// NS_FRAME_CONTAINS_RELATIVE_BSIZE bit for the cases
|
2007-05-16 01:52:44 +04:00
|
|
|
// where we hit the early break statements in
|
|
|
|
// CalcQuirkContainingBlockHeight. But it doesn't hurt
|
|
|
|
// us to set the bit in these cases.
|
2015-07-17 19:04:24 +03:00
|
|
|
|
2007-05-16 01:52:44 +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 (frame->GetStateBits() & NS_FRAME_IS_DIRTY) {
|
|
|
|
// If we're reflowing everything, then we'll find out if we need
|
|
|
|
// to re-set this.
|
2015-06-18 09:33:50 +03:00
|
|
|
frame->RemoveStateBits(NS_FRAME_CONTAINS_RELATIVE_BSIZE);
|
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
|
|
|
}
|
1999-01-05 22:44:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nscoord
|
2015-04-19 21:03:27 +03:00
|
|
|
nsHTMLReflowState::GetContainingBlockContentISize(WritingMode aWritingMode) const
|
1999-01-05 22:44:41 +03:00
|
|
|
{
|
2015-04-19 21:03:27 +03:00
|
|
|
if (!mCBReflowState) {
|
2002-05-14 16:59:55 +04:00
|
|
|
return 0;
|
2015-04-19 21:03:27 +03:00
|
|
|
}
|
|
|
|
return mCBReflowState->GetWritingMode().IsOrthogonalTo(aWritingMode)
|
|
|
|
? mCBReflowState->ComputedBSize()
|
|
|
|
: mCBReflowState->ComputedISize();
|
2004-11-25 05:43:28 +03:00
|
|
|
}
|
|
|
|
|
2003-11-17 03:35:17 +03:00
|
|
|
void
|
2011-06-11 03:02:14 +04:00
|
|
|
nsHTMLReflowState::InitFrameType(nsIAtom* aFrameType)
|
1999-01-05 22:44:41 +03:00
|
|
|
{
|
2003-11-17 03:35:17 +03:00
|
|
|
const nsStyleDisplay *disp = mStyleDisplay;
|
1999-02-23 22:33:06 +03:00
|
|
|
nsCSSFrameType frameType;
|
1999-01-05 22:44:41 +03:00
|
|
|
|
1999-02-23 22:33:06 +03:00
|
|
|
// Section 9.7 of the CSS2 spec indicates that absolute position
|
|
|
|
// takes precedence over float which takes precedence over display.
|
2003-11-17 03:35:17 +03:00
|
|
|
// XXXldb nsRuleNode::ComputeDisplayData should take care of this, right?
|
2009-02-24 21:38:20 +03:00
|
|
|
// Make sure the frame was actually moved out of the flow, and don't
|
|
|
|
// just assume what the style says, because we might not have had a
|
|
|
|
// useful float/absolute containing block
|
2010-05-02 01:40:16 +04:00
|
|
|
|
2011-05-10 04:36:10 +04:00
|
|
|
DISPLAY_INIT_TYPE(frame, this);
|
2010-05-02 01:40:16 +04:00
|
|
|
|
2011-06-11 03:02:14 +04:00
|
|
|
if (aFrameType == nsGkAtoms::tableFrame) {
|
2011-05-10 04:36:10 +04:00
|
|
|
mFrameType = NS_CSS_FRAME_TYPE_BLOCK;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-02-17 01:51:02 +04:00
|
|
|
NS_ASSERTION(frame->StyleDisplay()->IsAbsolutelyPositionedStyle() ==
|
2012-08-02 15:38:50 +04:00
|
|
|
disp->IsAbsolutelyPositionedStyle(),
|
2009-02-24 21:38:20 +03:00
|
|
|
"Unexpected position style");
|
2013-02-17 01:51:02 +04:00
|
|
|
NS_ASSERTION(frame->StyleDisplay()->IsFloatingStyle() ==
|
2012-08-02 15:38:49 +04:00
|
|
|
disp->IsFloatingStyle(), "Unexpected float style");
|
2011-05-10 04:36:10 +04:00
|
|
|
if (frame->GetStateBits() & NS_FRAME_OUT_OF_FLOW) {
|
2012-08-02 15:38:50 +04:00
|
|
|
if (disp->IsAbsolutelyPositioned(frame)) {
|
1999-09-29 03:42:35 +04:00
|
|
|
frameType = NS_CSS_FRAME_TYPE_ABSOLUTE;
|
2007-10-02 09:57:45 +04:00
|
|
|
//XXXfr hack for making frames behave properly when in overflow container lists
|
|
|
|
// see bug 154892; need to revisit later
|
2011-05-10 04:36:10 +04:00
|
|
|
if (frame->GetPrevInFlow())
|
2007-10-02 09:57:45 +04:00
|
|
|
frameType = NS_CSS_FRAME_TYPE_BLOCK;
|
1999-09-29 03:42:35 +04:00
|
|
|
}
|
2012-08-02 15:38:49 +04:00
|
|
|
else if (disp->IsFloating(frame)) {
|
1999-09-29 03:42:35 +04:00
|
|
|
frameType = NS_CSS_FRAME_TYPE_FLOATING;
|
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
|
|
|
} else {
|
|
|
|
NS_ASSERTION(disp->mDisplay == NS_STYLE_DISPLAY_POPUP,
|
|
|
|
"unknown out of flow frame type");
|
|
|
|
frameType = NS_CSS_FRAME_TYPE_UNKNOWN;
|
1999-09-29 03:42:35 +04:00
|
|
|
}
|
1999-01-05 22:44:41 +03:00
|
|
|
}
|
|
|
|
else {
|
2012-08-02 15:38:51 +04:00
|
|
|
switch (GetDisplay()) {
|
1999-01-05 22:44:41 +03:00
|
|
|
case NS_STYLE_DISPLAY_BLOCK:
|
|
|
|
case NS_STYLE_DISPLAY_LIST_ITEM:
|
|
|
|
case NS_STYLE_DISPLAY_TABLE:
|
2000-05-04 18:47:37 +04:00
|
|
|
case NS_STYLE_DISPLAY_TABLE_CAPTION:
|
2012-09-30 10:38:46 +04:00
|
|
|
case NS_STYLE_DISPLAY_FLEX:
|
2014-05-13 01:16:05 +04:00
|
|
|
case NS_STYLE_DISPLAY_GRID:
|
2014-11-26 07:52:49 +03:00
|
|
|
case NS_STYLE_DISPLAY_RUBY_TEXT_CONTAINER:
|
1999-01-05 22:44:41 +03:00
|
|
|
frameType = NS_CSS_FRAME_TYPE_BLOCK;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_STYLE_DISPLAY_INLINE:
|
2007-01-27 21:36:57 +03:00
|
|
|
case NS_STYLE_DISPLAY_INLINE_BLOCK:
|
1999-01-05 22:44:41 +03:00
|
|
|
case NS_STYLE_DISPLAY_INLINE_TABLE:
|
2001-03-04 00:57:56 +03:00
|
|
|
case NS_STYLE_DISPLAY_INLINE_BOX:
|
2014-02-27 11:43:18 +04:00
|
|
|
case NS_STYLE_DISPLAY_INLINE_XUL_GRID:
|
2001-03-04 00:57:56 +03:00
|
|
|
case NS_STYLE_DISPLAY_INLINE_STACK:
|
2012-09-30 10:38:46 +04:00
|
|
|
case NS_STYLE_DISPLAY_INLINE_FLEX:
|
2014-05-13 01:16:05 +04:00
|
|
|
case NS_STYLE_DISPLAY_INLINE_GRID:
|
2014-11-26 07:52:49 +03:00
|
|
|
case NS_STYLE_DISPLAY_RUBY:
|
|
|
|
case NS_STYLE_DISPLAY_RUBY_BASE:
|
|
|
|
case NS_STYLE_DISPLAY_RUBY_TEXT:
|
|
|
|
case NS_STYLE_DISPLAY_RUBY_BASE_CONTAINER:
|
1999-01-05 22:44:41 +03:00
|
|
|
frameType = NS_CSS_FRAME_TYPE_INLINE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_STYLE_DISPLAY_TABLE_CELL:
|
|
|
|
case NS_STYLE_DISPLAY_TABLE_ROW_GROUP:
|
|
|
|
case NS_STYLE_DISPLAY_TABLE_COLUMN:
|
|
|
|
case NS_STYLE_DISPLAY_TABLE_COLUMN_GROUP:
|
|
|
|
case NS_STYLE_DISPLAY_TABLE_HEADER_GROUP:
|
|
|
|
case NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP:
|
|
|
|
case NS_STYLE_DISPLAY_TABLE_ROW:
|
|
|
|
frameType = NS_CSS_FRAME_TYPE_INTERNAL_TABLE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_STYLE_DISPLAY_NONE:
|
|
|
|
default:
|
|
|
|
frameType = NS_CSS_FRAME_TYPE_UNKNOWN;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-02-13 08:59:19 +03:00
|
|
|
// See if the frame is replaced
|
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 (frame->IsFrameOfType(nsIFrame::eReplacedContainsBlock)) {
|
|
|
|
frameType = NS_FRAME_REPLACED_CONTAINS_BLOCK(frameType);
|
|
|
|
} else if (frame->IsFrameOfType(nsIFrame::eReplaced)) {
|
1999-01-05 22:44:41 +03:00
|
|
|
frameType = NS_FRAME_REPLACED(frameType);
|
|
|
|
}
|
1999-02-23 22:33:06 +03:00
|
|
|
|
2003-11-17 03:35:17 +03:00
|
|
|
mFrameType = frameType;
|
1999-01-05 22:44:41 +03:00
|
|
|
}
|
|
|
|
|
Bug 157681 - Part 2: Optimize positioned frame offset changes by moving the frame as opposed to reflowing it in case we know that the size of the frame will not change; r=dbaron
This patch adds a change hint to signal that one of the offsets on a
frame has been changed. When processing the hint, we do one of the
following things based on the position property of the frame.
* For static frames, we ignore the offset changes completely, as they
will not change the layout.
* For relative positioned frames, this patch refactors the
nsHTMLReflowState::ComputeRelativeOffsets function so that it can be
used from other callers, and it uses that to compute the new relative
offsets, and uses the offsets computed previously to compute the new
position of the frame.
* For absolute positioned frames, we set up a fake parent reflow state
object, and then we create a new reflow state object for the frame in
question. This setup is similar to what nsFrame::BoxReflow does.
Once we have the new reflow state object, we use it to compute the
absolute offsets, and then we use the computed offsets to set the new
position of the frame. The offset computation is similar to what
nsAbsoluteContainingBlock::ReflowAbsoluteFrame does. In some cases
where it is possible for the dimensions of the frame to change based
on the offset changes, we fall back to a full reflow.
2012-06-06 08:53:48 +04:00
|
|
|
/* static */ void
|
2015-06-04 13:43:02 +03:00
|
|
|
nsHTMLReflowState::ComputeRelativeOffsets(WritingMode aWM,
|
Bug 157681 - Part 2: Optimize positioned frame offset changes by moving the frame as opposed to reflowing it in case we know that the size of the frame will not change; r=dbaron
This patch adds a change hint to signal that one of the offsets on a
frame has been changed. When processing the hint, we do one of the
following things based on the position property of the frame.
* For static frames, we ignore the offset changes completely, as they
will not change the layout.
* For relative positioned frames, this patch refactors the
nsHTMLReflowState::ComputeRelativeOffsets function so that it can be
used from other callers, and it uses that to compute the new relative
offsets, and uses the offsets computed previously to compute the new
position of the frame.
* For absolute positioned frames, we set up a fake parent reflow state
object, and then we create a new reflow state object for the frame in
question. This setup is similar to what nsFrame::BoxReflow does.
Once we have the new reflow state object, we use it to compute the
absolute offsets, and then we use the computed offsets to set the new
position of the frame. The offset computation is similar to what
nsAbsoluteContainingBlock::ReflowAbsoluteFrame does. In some cases
where it is possible for the dimensions of the frame to change based
on the offset changes, we fall back to a full reflow.
2012-06-06 08:53:48 +04:00
|
|
|
nsIFrame* aFrame,
|
2015-06-04 13:43:02 +03:00
|
|
|
const LogicalSize& aCBSize,
|
Bug 157681 - Part 2: Optimize positioned frame offset changes by moving the frame as opposed to reflowing it in case we know that the size of the frame will not change; r=dbaron
This patch adds a change hint to signal that one of the offsets on a
frame has been changed. When processing the hint, we do one of the
following things based on the position property of the frame.
* For static frames, we ignore the offset changes completely, as they
will not change the layout.
* For relative positioned frames, this patch refactors the
nsHTMLReflowState::ComputeRelativeOffsets function so that it can be
used from other callers, and it uses that to compute the new relative
offsets, and uses the offsets computed previously to compute the new
position of the frame.
* For absolute positioned frames, we set up a fake parent reflow state
object, and then we create a new reflow state object for the frame in
question. This setup is similar to what nsFrame::BoxReflow does.
Once we have the new reflow state object, we use it to compute the
absolute offsets, and then we use the computed offsets to set the new
position of the frame. The offset computation is similar to what
nsAbsoluteContainingBlock::ReflowAbsoluteFrame does. In some cases
where it is possible for the dimensions of the frame to change based
on the offset changes, we fall back to a full reflow.
2012-06-06 08:53:48 +04:00
|
|
|
nsMargin& aComputedOffsets)
|
1999-01-16 23:58:17 +03:00
|
|
|
{
|
2015-06-04 13:43:02 +03:00
|
|
|
LogicalMargin offsets(aWM);
|
|
|
|
mozilla::css::Side inlineStart = aWM.PhysicalSide(eLogicalSideIStart);
|
|
|
|
mozilla::css::Side inlineEnd = aWM.PhysicalSide(eLogicalSideIEnd);
|
|
|
|
mozilla::css::Side blockStart = aWM.PhysicalSide(eLogicalSideBStart);
|
|
|
|
mozilla::css::Side blockEnd = aWM.PhysicalSide(eLogicalSideBEnd);
|
|
|
|
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStylePosition* position = aFrame->StylePosition();
|
Bug 157681 - Part 2: Optimize positioned frame offset changes by moving the frame as opposed to reflowing it in case we know that the size of the frame will not change; r=dbaron
This patch adds a change hint to signal that one of the offsets on a
frame has been changed. When processing the hint, we do one of the
following things based on the position property of the frame.
* For static frames, we ignore the offset changes completely, as they
will not change the layout.
* For relative positioned frames, this patch refactors the
nsHTMLReflowState::ComputeRelativeOffsets function so that it can be
used from other callers, and it uses that to compute the new relative
offsets, and uses the offsets computed previously to compute the new
position of the frame.
* For absolute positioned frames, we set up a fake parent reflow state
object, and then we create a new reflow state object for the frame in
question. This setup is similar to what nsFrame::BoxReflow does.
Once we have the new reflow state object, we use it to compute the
absolute offsets, and then we use the computed offsets to set the new
position of the frame. The offset computation is similar to what
nsAbsoluteContainingBlock::ReflowAbsoluteFrame does. In some cases
where it is possible for the dimensions of the frame to change based
on the offset changes, we fall back to a full reflow.
2012-06-06 08:53:48 +04:00
|
|
|
|
2015-06-04 13:43:02 +03:00
|
|
|
// Compute the 'inlineStart' and 'inlineEnd' values. 'inlineStart'
|
|
|
|
// moves the boxes to the end of the line, and 'inlineEnd' moves the
|
|
|
|
// boxes to the start of the line. The computed values are always:
|
|
|
|
// inlineStart=-inlineEnd
|
|
|
|
bool inlineStartIsAuto =
|
|
|
|
eStyleUnit_Auto == position->mOffset.GetUnit(inlineStart);
|
|
|
|
bool inlineEndIsAuto =
|
|
|
|
eStyleUnit_Auto == position->mOffset.GetUnit(inlineEnd);
|
|
|
|
|
|
|
|
// If neither 'inlineStart' nor 'inlineEnd' is auto, then we're
|
|
|
|
// over-constrained and we ignore one of them
|
|
|
|
if (!inlineStartIsAuto && !inlineEndIsAuto) {
|
|
|
|
inlineEndIsAuto = true;
|
1999-01-16 23:58:17 +03:00
|
|
|
}
|
|
|
|
|
2015-06-04 13:43:02 +03:00
|
|
|
if (inlineStartIsAuto) {
|
|
|
|
if (inlineEndIsAuto) {
|
1999-01-22 07:12:03 +03:00
|
|
|
// If both are 'auto' (their initial values), the computed values are 0
|
2015-06-04 13:43:02 +03:00
|
|
|
offsets.IStart(aWM) = offsets.IEnd(aWM) = 0;
|
1999-01-22 07:12:03 +03:00
|
|
|
} else {
|
2015-06-04 13:43:02 +03:00
|
|
|
// 'inlineEnd' isn't 'auto' so compute its value
|
|
|
|
offsets.IEnd(aWM) = nsLayoutUtils::
|
|
|
|
ComputeCBDependentValue(aCBSize.ISize(aWM),
|
|
|
|
position->mOffset.Get(inlineEnd));
|
2008-07-18 03:37:12 +04:00
|
|
|
|
2015-06-04 13:43:02 +03:00
|
|
|
// Computed value for 'inlineStart' is minus the value of 'inlineEnd'
|
|
|
|
offsets.IStart(aWM) = -offsets.IEnd(aWM);
|
1999-01-22 07:12:03 +03:00
|
|
|
}
|
|
|
|
|
1999-01-16 23:58:17 +03:00
|
|
|
} else {
|
2015-06-04 13:43:02 +03:00
|
|
|
NS_ASSERTION(inlineEndIsAuto, "unexpected specified constraint");
|
|
|
|
|
|
|
|
// 'InlineStart' isn't 'auto' so compute its value
|
|
|
|
offsets.IStart(aWM) = nsLayoutUtils::
|
|
|
|
ComputeCBDependentValue(aCBSize.ISize(aWM),
|
|
|
|
position->mOffset.Get(inlineStart));
|
|
|
|
|
|
|
|
// Computed value for 'inlineEnd' is minus the value of 'inlineStart'
|
|
|
|
offsets.IEnd(aWM) = -offsets.IStart(aWM);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Compute the 'blockStart' and 'blockEnd' values. The 'blockStart'
|
|
|
|
// and 'blockEnd' properties move relatively positioned elements in
|
|
|
|
// the block progression direction. They also must be each other's
|
|
|
|
// negative
|
|
|
|
bool blockStartIsAuto =
|
|
|
|
eStyleUnit_Auto == position->mOffset.GetUnit(blockStart);
|
|
|
|
bool blockEndIsAuto =
|
|
|
|
eStyleUnit_Auto == position->mOffset.GetUnit(blockEnd);
|
|
|
|
|
|
|
|
// Check for percentage based values and a containing block block-size
|
|
|
|
// that depends on the content block-size. Treat them like 'auto'
|
|
|
|
if (NS_AUTOHEIGHT == aCBSize.BSize(aWM)) {
|
|
|
|
if (position->OffsetHasPercent(blockStart)) {
|
|
|
|
blockStartIsAuto = true;
|
1999-01-23 07:49:15 +03:00
|
|
|
}
|
2015-06-04 13:43:02 +03:00
|
|
|
if (position->OffsetHasPercent(blockEnd)) {
|
|
|
|
blockEndIsAuto = true;
|
1999-01-23 07:49:15 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-04 13:43:02 +03:00
|
|
|
// If neither is 'auto', 'block-end' is ignored
|
|
|
|
if (!blockStartIsAuto && !blockEndIsAuto) {
|
|
|
|
blockEndIsAuto = true;
|
1999-01-16 23:58:17 +03:00
|
|
|
}
|
|
|
|
|
2015-06-04 13:43:02 +03:00
|
|
|
if (blockStartIsAuto) {
|
|
|
|
if (blockEndIsAuto) {
|
1999-01-22 07:12:03 +03:00
|
|
|
// If both are 'auto' (their initial values), the computed values are 0
|
2015-06-04 13:43:02 +03:00
|
|
|
offsets.BStart(aWM) = offsets.BEnd(aWM) = 0;
|
1999-01-22 07:12:03 +03:00
|
|
|
} else {
|
2015-06-04 13:43:02 +03:00
|
|
|
// 'blockEnd' isn't 'auto' so compute its value
|
|
|
|
offsets.BEnd(aWM) = nsLayoutUtils::
|
|
|
|
ComputeBSizeDependentValue(aCBSize.BSize(aWM),
|
|
|
|
position->mOffset.Get(blockEnd));
|
|
|
|
|
|
|
|
// Computed value for 'blockStart' is minus the value of 'blockEnd'
|
|
|
|
offsets.BStart(aWM) = -offsets.BEnd(aWM);
|
1999-01-22 07:12:03 +03:00
|
|
|
}
|
|
|
|
|
1999-01-16 23:58:17 +03:00
|
|
|
} else {
|
2015-06-04 13:43:02 +03:00
|
|
|
NS_ASSERTION(blockEndIsAuto, "unexpected specified constraint");
|
|
|
|
|
|
|
|
// 'blockStart' isn't 'auto' so compute its value
|
|
|
|
offsets.BStart(aWM) = nsLayoutUtils::
|
|
|
|
ComputeBSizeDependentValue(aCBSize.BSize(aWM),
|
|
|
|
position->mOffset.Get(blockStart));
|
1999-01-22 07:12:03 +03:00
|
|
|
|
2015-06-04 13:43:02 +03:00
|
|
|
// Computed value for 'blockEnd' is minus the value of 'blockStart'
|
|
|
|
offsets.BEnd(aWM) = -offsets.BStart(aWM);
|
1999-01-16 23:58:17 +03:00
|
|
|
}
|
2013-09-10 22:33:59 +04:00
|
|
|
|
2015-06-04 13:43:02 +03:00
|
|
|
// Convert the offsets to physical coordinates and store them on the frame
|
|
|
|
aComputedOffsets = offsets.GetPhysicalMargin(aWM);
|
2013-09-10 22:33:59 +04:00
|
|
|
FrameProperties props = aFrame->Properties();
|
2015-06-04 13:43:02 +03:00
|
|
|
nsMargin* physicalOffsets = static_cast<nsMargin*>
|
2013-09-10 22:33:59 +04:00
|
|
|
(props.Get(nsIFrame::ComputedOffsetProperty()));
|
2015-06-04 13:43:02 +03:00
|
|
|
if (physicalOffsets) {
|
|
|
|
*physicalOffsets = aComputedOffsets;
|
2013-09-10 22:33:59 +04:00
|
|
|
} else {
|
|
|
|
props.Set(nsIFrame::ComputedOffsetProperty(),
|
|
|
|
new nsMargin(aComputedOffsets));
|
|
|
|
}
|
1999-01-16 23:58:17 +03:00
|
|
|
}
|
|
|
|
|
2013-07-16 04:28:09 +04:00
|
|
|
/* static */ void
|
2013-08-09 04:20:17 +04:00
|
|
|
nsHTMLReflowState::ApplyRelativePositioning(nsIFrame* aFrame,
|
|
|
|
const nsMargin& aComputedOffsets,
|
2013-07-16 04:28:09 +04:00
|
|
|
nsPoint* aPosition)
|
|
|
|
{
|
2013-09-17 15:44:16 +04:00
|
|
|
if (!aFrame->IsRelativelyPositioned()) {
|
|
|
|
NS_ASSERTION(!aFrame->Properties().Get(nsIFrame::NormalPositionProperty()),
|
|
|
|
"We assume that changing the 'position' property causes "
|
|
|
|
"frame reconstruction. If that ever changes, this code "
|
|
|
|
"should call "
|
|
|
|
"props.Delete(nsIFrame::NormalPositionProperty())");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-08-09 04:20:17 +04:00
|
|
|
// Store the normal position
|
|
|
|
FrameProperties props = aFrame->Properties();
|
|
|
|
nsPoint* normalPosition = static_cast<nsPoint*>
|
|
|
|
(props.Get(nsIFrame::NormalPositionProperty()));
|
|
|
|
if (normalPosition) {
|
|
|
|
*normalPosition = *aPosition;
|
|
|
|
} else {
|
|
|
|
props.Set(nsIFrame::NormalPositionProperty(), new nsPoint(*aPosition));
|
|
|
|
}
|
|
|
|
|
|
|
|
const nsStyleDisplay* display = aFrame->StyleDisplay();
|
|
|
|
if (NS_STYLE_POSITION_RELATIVE == display->mPosition) {
|
2013-07-16 04:28:09 +04:00
|
|
|
*aPosition += nsPoint(aComputedOffsets.left, aComputedOffsets.top);
|
2013-09-14 03:53:48 +04:00
|
|
|
} else if (NS_STYLE_POSITION_STICKY == display->mPosition &&
|
2013-09-25 23:28:08 +04:00
|
|
|
!aFrame->GetNextContinuation() &&
|
|
|
|
!aFrame->GetPrevContinuation() &&
|
2014-02-07 05:45:28 +04:00
|
|
|
!(aFrame->GetStateBits() & NS_FRAME_PART_OF_IBSPLIT)) {
|
2013-09-14 03:53:48 +04:00
|
|
|
// Sticky positioning for elements with multiple frames needs to be
|
|
|
|
// computed all at once. We can't safely do that here because we might be
|
|
|
|
// partway through (re)positioning the frames, so leave it until the scroll
|
|
|
|
// container reflows and calls StickyScrollContainer::UpdatePositions.
|
|
|
|
// For single-frame sticky positioned elements, though, go ahead and apply
|
|
|
|
// it now to avoid unnecessary overflow updates later.
|
2013-09-12 03:30:56 +04:00
|
|
|
StickyScrollContainer* ssc =
|
|
|
|
StickyScrollContainer::GetStickyScrollContainerForFrame(aFrame);
|
|
|
|
if (ssc) {
|
|
|
|
*aPosition = ssc->ComputePosition(aFrame);
|
|
|
|
}
|
2013-07-16 04:28:09 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-18 06:00:23 +03:00
|
|
|
nsIFrame*
|
2015-08-06 23:01:31 +03:00
|
|
|
nsHTMLReflowState::GetHypotheticalBoxContainer(nsIFrame* aFrame,
|
|
|
|
nscoord& aCBIStartEdge,
|
|
|
|
LogicalSize& aCBSize)
|
2000-04-16 08:07:02 +04:00
|
|
|
{
|
2011-05-12 08:04:30 +04:00
|
|
|
aFrame = aFrame->GetContainingBlock();
|
2006-12-18 06:00:23 +03:00
|
|
|
NS_ASSERTION(aFrame != frame, "How did that happen?");
|
2003-06-29 07:43:05 +04:00
|
|
|
|
2006-12-18 06:00:23 +03:00
|
|
|
/* Now aFrame is the containing block we want */
|
|
|
|
|
2009-07-27 12:47:02 +04:00
|
|
|
/* Check whether the containing block is currently being reflowed.
|
2006-12-18 06:00:23 +03:00
|
|
|
If so, use the info from the reflow state. */
|
|
|
|
const nsHTMLReflowState* state;
|
|
|
|
if (aFrame->GetStateBits() & NS_FRAME_IN_REFLOW) {
|
|
|
|
for (state = parentReflowState; state && state->frame != aFrame;
|
|
|
|
state = state->parentReflowState) {
|
|
|
|
/* do nothing */
|
2000-04-16 08:07:02 +04:00
|
|
|
}
|
2006-12-18 06:00:23 +03:00
|
|
|
} else {
|
2012-07-30 18:20:58 +04:00
|
|
|
state = nullptr;
|
2006-12-18 06:00:23 +03:00
|
|
|
}
|
2015-06-04 13:43:02 +03:00
|
|
|
|
2006-12-18 06:00:23 +03:00
|
|
|
if (state) {
|
2015-08-12 13:02:02 +03:00
|
|
|
WritingMode wm = state->GetWritingMode();
|
|
|
|
NS_ASSERTION(wm == aFrame->GetWritingMode(), "unexpected writing mode");
|
|
|
|
aCBIStartEdge = state->ComputedLogicalBorderPadding().IStart(wm);
|
2015-08-06 23:01:31 +03:00
|
|
|
aCBSize = state->ComputedSize(wm);
|
2006-12-18 06:00:23 +03:00
|
|
|
} else {
|
|
|
|
/* Didn't find a reflow state for aFrame. Just compute the information we
|
|
|
|
want, on the assumption that aFrame already knows its size. This really
|
|
|
|
ought to be true by now. */
|
2006-12-18 08:08:01 +03:00
|
|
|
NS_ASSERTION(!(aFrame->GetStateBits() & NS_FRAME_IN_REFLOW),
|
2006-12-18 06:00:23 +03:00
|
|
|
"aFrame shouldn't be in reflow; we'll lie if it is");
|
2015-08-12 13:02:02 +03:00
|
|
|
WritingMode wm = aFrame->GetWritingMode();
|
2015-06-04 13:43:02 +03:00
|
|
|
LogicalMargin borderPadding = aFrame->GetLogicalUsedBorderAndPadding(wm);
|
|
|
|
aCBIStartEdge = borderPadding.IStart(wm);
|
2015-08-06 23:01:31 +03:00
|
|
|
aCBSize = aFrame->GetLogicalSize(wm) - borderPadding.Size(wm);
|
2000-04-16 08:07:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return aFrame;
|
|
|
|
}
|
|
|
|
|
2015-08-12 13:02:02 +03:00
|
|
|
struct nsHypotheticalPosition {
|
|
|
|
// offset from inline-start edge of containing block (which is a padding edge)
|
|
|
|
nscoord mIStart;
|
2015-06-05 10:47:09 +03:00
|
|
|
// offset from block-start edge of containing block (which is a padding edge)
|
|
|
|
nscoord mBStart;
|
|
|
|
WritingMode mWritingMode;
|
2000-04-16 08:07:02 +04:00
|
|
|
};
|
2015-06-04 13:43:02 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool
|
2011-06-11 03:02:14 +04:00
|
|
|
GetIntrinsicSizeFor(nsIFrame* aFrame, nsSize& aIntrinsicSize, nsIAtom* aFrameType)
|
2000-04-16 08:07:02 +04:00
|
|
|
{
|
|
|
|
// See if it is an image frame
|
2011-09-29 10:19:26 +04:00
|
|
|
bool success = false;
|
2000-04-16 08:07:02 +04:00
|
|
|
|
|
|
|
// Currently the only type of replaced frame that we can get the intrinsic
|
|
|
|
// size for is an image frame
|
|
|
|
// XXX We should add back the GetReflowMetrics() function and one of the
|
|
|
|
// things should be the intrinsic size...
|
2011-06-11 03:02:14 +04:00
|
|
|
if (aFrameType == nsGkAtoms::imageFrame) {
|
2000-04-16 08:07:02 +04:00
|
|
|
nsImageFrame* imageFrame = (nsImageFrame*)aFrame;
|
|
|
|
|
2010-09-09 00:40:38 +04:00
|
|
|
if (NS_SUCCEEDED(imageFrame->GetIntrinsicImageSize(aIntrinsicSize))) {
|
|
|
|
success = (aIntrinsicSize != nsSize(0, 0));
|
|
|
|
}
|
2000-04-16 08:07:02 +04:00
|
|
|
}
|
2010-09-09 00:40:38 +04:00
|
|
|
return success;
|
2000-04-16 08:07:02 +04:00
|
|
|
}
|
|
|
|
|
2007-05-04 03:11:00 +04:00
|
|
|
/**
|
2015-08-06 23:01:31 +03:00
|
|
|
* aInsideBoxSizing returns the part of the padding, border, and margin
|
|
|
|
* in the aAxis dimension that goes inside the edge given by box-sizing;
|
2007-05-04 03:11:00 +04:00
|
|
|
* aOutsideBoxSizing returns the rest.
|
|
|
|
*/
|
|
|
|
void
|
2015-08-06 23:01:31 +03:00
|
|
|
nsHTMLReflowState::CalculateBorderPaddingMargin(
|
|
|
|
LogicalAxis aAxis,
|
|
|
|
nscoord aContainingBlockSize,
|
2007-05-04 03:11:00 +04:00
|
|
|
nscoord* aInsideBoxSizing,
|
|
|
|
nscoord* aOutsideBoxSizing)
|
2000-04-16 08:07:02 +04:00
|
|
|
{
|
2015-06-04 13:43:02 +03:00
|
|
|
WritingMode wm = GetWritingMode();
|
2015-08-06 23:01:31 +03:00
|
|
|
mozilla::css::Side startSide =
|
|
|
|
wm.PhysicalSide(MakeLogicalSide(aAxis, eLogicalEdgeStart));
|
|
|
|
mozilla::css::Side endSide =
|
|
|
|
wm.PhysicalSide(MakeLogicalSide(aAxis, eLogicalEdgeEnd));
|
2015-06-04 13:43:02 +03:00
|
|
|
|
2015-08-06 23:01:31 +03:00
|
|
|
nsMargin styleBorder = mStyleBorder->GetComputedBorder();
|
|
|
|
nscoord borderStartEnd =
|
|
|
|
styleBorder.Side(startSide) + styleBorder.Side(endSide);
|
|
|
|
|
|
|
|
nscoord paddingStartEnd, marginStartEnd;
|
2000-04-16 08:07:02 +04:00
|
|
|
|
|
|
|
// See if the style system can provide us the padding directly
|
2015-06-04 13:43:02 +03:00
|
|
|
nsMargin stylePadding;
|
|
|
|
if (mStylePadding->GetPadding(stylePadding)) {
|
2015-08-06 23:01:31 +03:00
|
|
|
paddingStartEnd =
|
|
|
|
stylePadding.Side(startSide) + stylePadding.Side(endSide);
|
2015-06-04 13:43:02 +03:00
|
|
|
} else {
|
2015-08-06 23:01:31 +03:00
|
|
|
// We have to compute the start and end values
|
|
|
|
nscoord start, end;
|
|
|
|
start = nsLayoutUtils::
|
|
|
|
ComputeCBDependentValue(aContainingBlockSize,
|
|
|
|
mStylePadding->mPadding.Get(startSide));
|
|
|
|
end = nsLayoutUtils::
|
|
|
|
ComputeCBDependentValue(aContainingBlockSize,
|
|
|
|
mStylePadding->mPadding.Get(endSide));
|
|
|
|
paddingStartEnd = start + end;
|
2000-04-16 08:07:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// See if the style system can provide us the margin directly
|
2015-06-04 13:43:02 +03:00
|
|
|
nsMargin styleMargin;
|
|
|
|
if (mStyleMargin->GetMargin(styleMargin)) {
|
2015-08-06 23:01:31 +03:00
|
|
|
marginStartEnd =
|
|
|
|
styleMargin.Side(startSide) + styleMargin.Side(endSide);
|
2015-06-04 13:43:02 +03:00
|
|
|
} else {
|
2015-08-06 23:01:31 +03:00
|
|
|
nscoord start, end;
|
|
|
|
// We have to compute the start and end values
|
|
|
|
if (eStyleUnit_Auto == mStyleMargin->mMargin.GetUnit(startSide)) {
|
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
|
|
|
// XXX FIXME (or does CalculateBlockSideMargins do this?)
|
2015-08-06 23:01:31 +03:00
|
|
|
start = 0; // just ignore
|
2000-04-16 08:07:02 +04:00
|
|
|
} else {
|
2015-08-06 23:01:31 +03:00
|
|
|
start = nsLayoutUtils::
|
|
|
|
ComputeCBDependentValue(aContainingBlockSize,
|
|
|
|
mStyleMargin->mMargin.Get(startSide));
|
2000-04-16 08:07:02 +04:00
|
|
|
}
|
2015-08-06 23:01:31 +03:00
|
|
|
if (eStyleUnit_Auto == mStyleMargin->mMargin.GetUnit(endSide)) {
|
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
|
|
|
// XXX FIXME (or does CalculateBlockSideMargins do this?)
|
2015-08-06 23:01:31 +03:00
|
|
|
end = 0; // just ignore
|
2000-04-16 08:07:02 +04:00
|
|
|
} else {
|
2015-08-06 23:01:31 +03:00
|
|
|
end = nsLayoutUtils::
|
|
|
|
ComputeCBDependentValue(aContainingBlockSize,
|
|
|
|
mStyleMargin->mMargin.Get(endSide));
|
2000-04-16 08:07:02 +04:00
|
|
|
}
|
2015-08-06 23:01:31 +03:00
|
|
|
marginStartEnd = start + end;
|
2000-04-16 08:07:02 +04:00
|
|
|
}
|
|
|
|
|
2015-08-06 23:01:31 +03:00
|
|
|
nscoord outside = paddingStartEnd + borderStartEnd + marginStartEnd;
|
2007-05-04 03:11:00 +04:00
|
|
|
nscoord inside = 0;
|
2015-05-29 22:16:53 +03:00
|
|
|
switch (mStylePosition->mBoxSizing) {
|
|
|
|
case NS_STYLE_BOX_SIZING_BORDER:
|
2015-08-06 23:01:31 +03:00
|
|
|
inside += borderStartEnd;
|
2015-05-29 22:16:53 +03:00
|
|
|
// fall through
|
|
|
|
case NS_STYLE_BOX_SIZING_PADDING:
|
2015-08-06 23:01:31 +03:00
|
|
|
inside += paddingStartEnd;
|
2007-05-04 03:11:00 +04:00
|
|
|
}
|
|
|
|
outside -= inside;
|
|
|
|
*aInsideBoxSizing = inside;
|
|
|
|
*aOutsideBoxSizing = outside;
|
|
|
|
return;
|
2000-04-16 08:07:02 +04:00
|
|
|
}
|
|
|
|
|
2004-11-14 23:22:58 +03:00
|
|
|
/**
|
2011-10-17 18:59:28 +04:00
|
|
|
* Returns true iff a pre-order traversal of the normal child
|
2004-11-14 23:22:58 +03:00
|
|
|
* frames rooted at aFrame finds no non-empty frame before aDescendant.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool AreAllEarlierInFlowFramesEmpty(nsIFrame* aFrame,
|
|
|
|
nsIFrame* aDescendant, bool* aFound) {
|
2004-11-14 23:22:58 +03:00
|
|
|
if (aFrame == aDescendant) {
|
2011-10-17 18:59:28 +04:00
|
|
|
*aFound = true;
|
|
|
|
return true;
|
2004-11-14 23:22:58 +03:00
|
|
|
}
|
2004-11-15 08:01:11 +03:00
|
|
|
if (!aFrame->IsSelfEmpty()) {
|
2011-10-17 18:59:28 +04:00
|
|
|
*aFound = false;
|
|
|
|
return false;
|
2004-11-14 23:22:58 +03:00
|
|
|
}
|
2015-06-29 23:02:21 +03:00
|
|
|
for (nsIFrame* f : aFrame->PrincipalChildList()) {
|
2011-09-29 10:19:26 +04:00
|
|
|
bool allEmpty = AreAllEarlierInFlowFramesEmpty(f, aDescendant, aFound);
|
2004-11-14 23:22:58 +03:00
|
|
|
if (*aFound || !allEmpty) {
|
|
|
|
return allEmpty;
|
|
|
|
}
|
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
*aFound = false;
|
|
|
|
return true;
|
2004-11-14 23:22:58 +03:00
|
|
|
}
|
|
|
|
|
2015-08-12 13:02:02 +03:00
|
|
|
// Calculate the position of the hypothetical box that the element would have
|
|
|
|
// if it were in the flow.
|
|
|
|
// The values returned are relative to the padding edge of the absolute
|
|
|
|
// containing block. The writing-mode of the hypothetical box position will
|
2015-08-06 23:01:31 +03:00
|
|
|
// have the same block direction as the absolute containing block, but may
|
|
|
|
// differ in inline-bidi direction.
|
|
|
|
// In the code below, |cbrs->frame| is the absolute containing block, while
|
|
|
|
// |containingBlock| is the nearest block container of the placeholder frame,
|
|
|
|
// which may be different from the absolute containing block.
|
1999-01-13 09:37:31 +03:00
|
|
|
void
|
2015-08-12 13:02:02 +03:00
|
|
|
nsHTMLReflowState::CalculateHypotheticalPosition
|
|
|
|
(nsPresContext* aPresContext,
|
|
|
|
nsIFrame* aPlaceholderFrame,
|
|
|
|
const nsHTMLReflowState* cbrs,
|
|
|
|
nsHypotheticalPosition& aHypotheticalPos,
|
|
|
|
nsIAtom* aFrameType)
|
1999-01-13 09:37:31 +03:00
|
|
|
{
|
2002-08-16 03:00:23 +04:00
|
|
|
NS_ASSERTION(mStyleDisplay->mOriginalDisplay != NS_STYLE_DISPLAY_NONE,
|
|
|
|
"mOriginalDisplay has not been properly initialized");
|
2015-06-04 13:43:02 +03:00
|
|
|
|
2015-06-05 10:47:09 +03:00
|
|
|
// Find the nearest containing block frame to the placeholder frame,
|
|
|
|
// and its inline-start edge and width.
|
2015-08-06 23:01:31 +03:00
|
|
|
nscoord blockIStartContentEdge;
|
|
|
|
// Dummy writing mode for blockContentSize, will be changed as needed by
|
|
|
|
// GetHypotheticalBoxContainer.
|
|
|
|
WritingMode cbwm = cbrs->GetWritingMode();
|
|
|
|
LogicalSize blockContentSize(cbwm);
|
2015-06-05 10:47:09 +03:00
|
|
|
nsIFrame* containingBlock =
|
|
|
|
GetHypotheticalBoxContainer(aPlaceholderFrame, blockIStartContentEdge,
|
2015-08-06 23:01:31 +03:00
|
|
|
blockContentSize);
|
|
|
|
// Now blockContentSize is in containingBlock's writing mode.
|
2015-06-05 10:47:09 +03:00
|
|
|
|
2015-06-04 13:43:02 +03:00
|
|
|
// If it's a replaced element and it has a 'auto' value for
|
|
|
|
//'inline size', see if we can get the intrinsic size. This will allow
|
|
|
|
// us to exactly determine both the inline edges
|
2015-06-05 10:47:09 +03:00
|
|
|
WritingMode wm = containingBlock->GetWritingMode();
|
|
|
|
|
|
|
|
nsStyleCoord styleISize = mStylePosition->ISize(wm);
|
2015-06-04 13:43:02 +03:00
|
|
|
bool isAutoISize = styleISize.GetUnit() == eStyleUnit_Auto;
|
2000-04-16 08:07:02 +04:00
|
|
|
nsSize intrinsicSize;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool knowIntrinsicSize = false;
|
2015-06-04 13:43:02 +03:00
|
|
|
if (NS_FRAME_IS_REPLACED(mFrameType) && isAutoISize) {
|
2000-04-16 08:07:02 +04:00
|
|
|
// See if we can get the intrinsic size of the element
|
2011-06-11 03:02:14 +04:00
|
|
|
knowIntrinsicSize = GetIntrinsicSizeFor(frame, intrinsicSize, aFrameType);
|
2000-04-16 08:07:02 +04:00
|
|
|
}
|
|
|
|
|
2015-06-04 13:43:02 +03:00
|
|
|
// See if we can calculate what the box inline size would have been if
|
|
|
|
// the element had been in the flow
|
|
|
|
nscoord boxISize;
|
|
|
|
bool knowBoxISize = false;
|
2002-08-16 03:00:23 +04:00
|
|
|
if ((NS_STYLE_DISPLAY_INLINE == mStyleDisplay->mOriginalDisplay) &&
|
2000-04-16 08:07:02 +04:00
|
|
|
!NS_FRAME_IS_REPLACED(mFrameType)) {
|
2015-06-04 13:43:02 +03:00
|
|
|
// For non-replaced inline-level elements the 'inline size' property
|
|
|
|
// doesn't apply, so we don't know what the inline size would have
|
|
|
|
// been without reflowing it
|
2000-04-16 08:07:02 +04:00
|
|
|
|
|
|
|
} else {
|
|
|
|
// It's either a replaced inline-level element or a block-level element
|
|
|
|
|
2015-06-04 13:43:02 +03:00
|
|
|
// Determine the total amount of inline direction
|
|
|
|
// border/padding/margin that the element would have had if it had
|
|
|
|
// been in the flow. Note that we ignore any 'auto' and 'inherit'
|
|
|
|
// values
|
2007-05-04 03:11:00 +04:00
|
|
|
nscoord insideBoxSizing, outsideBoxSizing;
|
2015-08-06 23:01:31 +03:00
|
|
|
CalculateBorderPaddingMargin(eLogicalAxisInline,
|
|
|
|
blockContentSize.ISize(wm),
|
|
|
|
&insideBoxSizing, &outsideBoxSizing);
|
2000-04-16 08:07:02 +04:00
|
|
|
|
2015-06-04 13:43:02 +03:00
|
|
|
if (NS_FRAME_IS_REPLACED(mFrameType) && isAutoISize) {
|
|
|
|
// It's a replaced element with an 'auto' inline size so the box
|
|
|
|
// inline size is its intrinsic size plus any border/padding/margin
|
2000-04-16 08:07:02 +04:00
|
|
|
if (knowIntrinsicSize) {
|
2015-06-05 10:47:09 +03:00
|
|
|
boxISize = LogicalSize(wm, intrinsicSize).ISize(wm) +
|
2015-06-04 13:43:02 +03:00
|
|
|
outsideBoxSizing + insideBoxSizing;
|
|
|
|
knowBoxISize = true;
|
2000-04-16 08:07:02 +04:00
|
|
|
}
|
|
|
|
|
2015-06-04 13:43:02 +03:00
|
|
|
} else if (isAutoISize) {
|
|
|
|
// The box inline size is the containing block inline size
|
2015-08-06 23:01:31 +03:00
|
|
|
boxISize = blockContentSize.ISize(wm);
|
2015-06-04 13:43:02 +03:00
|
|
|
knowBoxISize = true;
|
|
|
|
|
2000-04-16 08:07:02 +04:00
|
|
|
} else {
|
|
|
|
// We need to compute it. It's important we do this, because if it's
|
2008-02-26 00:16:21 +03:00
|
|
|
// percentage based this computed value may be different from the computed
|
2000-04-16 08:07:02 +04:00
|
|
|
// value calculated using the absolute containing block width
|
2015-08-06 23:01:31 +03:00
|
|
|
boxISize = ComputeISizeValue(blockContentSize.ISize(wm),
|
2007-05-04 03:11:00 +04:00
|
|
|
insideBoxSizing, outsideBoxSizing,
|
2015-06-04 13:43:02 +03:00
|
|
|
styleISize) +
|
2007-05-04 03:11:00 +04:00
|
|
|
insideBoxSizing + outsideBoxSizing;
|
2015-06-04 13:43:02 +03:00
|
|
|
knowBoxISize = true;
|
2000-04-16 08:07:02 +04:00
|
|
|
}
|
|
|
|
}
|
2015-06-04 13:43:02 +03:00
|
|
|
|
2003-01-29 14:35:10 +03:00
|
|
|
// Get the placeholder x-offset and y-offset in the coordinate
|
2010-04-02 06:09:05 +04:00
|
|
|
// space of its containing block
|
2009-07-27 12:47:02 +04:00
|
|
|
// XXXbz the placeholder is not fully reflowed yet if our containing block is
|
2004-04-24 21:56:23 +04:00
|
|
|
// relatively positioned...
|
2015-07-16 12:07:57 +03:00
|
|
|
nsSize containerSize = containingBlock->GetStateBits() & NS_FRAME_IN_REFLOW
|
|
|
|
? cbrs->ComputedSizeAsContainerIfConstrained()
|
|
|
|
: containingBlock->GetSize();
|
2015-07-16 23:04:06 +03:00
|
|
|
LogicalPoint
|
|
|
|
placeholderOffset(wm, aPlaceholderFrame->GetOffsetTo(containingBlock),
|
|
|
|
containerSize);
|
2015-06-05 10:47:09 +03:00
|
|
|
|
|
|
|
// First, determine the hypothetical box's mBStart. We want to check the
|
|
|
|
// content insertion frame of containingBlock for block-ness, but make
|
2010-04-02 06:09:05 +04:00
|
|
|
// sure to compute all coordinates in the coordinate system of
|
2015-06-05 10:47:09 +03:00
|
|
|
// containingBlock.
|
2010-04-02 06:09:05 +04:00
|
|
|
nsBlockFrame* blockFrame =
|
2015-06-05 10:47:09 +03:00
|
|
|
nsLayoutUtils::GetAsBlock(containingBlock->GetContentInsertionFrame());
|
2008-07-14 02:10:23 +04:00
|
|
|
if (blockFrame) {
|
2015-07-16 12:07:57 +03:00
|
|
|
// Use a null containerSize to convert a LogicalPoint functioning as a
|
|
|
|
// vector into a physical nsPoint vector.
|
|
|
|
const nsSize nullContainerSize;
|
|
|
|
LogicalPoint blockOffset(wm, blockFrame->GetOffsetTo(containingBlock),
|
|
|
|
nullContainerSize);
|
2011-11-07 09:25:56 +04:00
|
|
|
bool isValid;
|
|
|
|
nsBlockInFlowLineIterator iter(blockFrame, aPlaceholderFrame, &isValid);
|
|
|
|
if (!isValid) {
|
2010-10-07 08:25:47 +04:00
|
|
|
// Give up. We're probably dealing with somebody using
|
|
|
|
// position:absolute inside native-anonymous content anyway.
|
2015-08-12 13:02:02 +03:00
|
|
|
aHypotheticalPos.mBStart = placeholderOffset.B(wm);
|
2000-04-16 08:07:02 +04:00
|
|
|
} else {
|
2011-11-07 09:25:56 +04:00
|
|
|
NS_ASSERTION(iter.GetContainer() == blockFrame,
|
|
|
|
"Found placeholder in wrong block!");
|
|
|
|
nsBlockFrame::line_iterator lineBox = iter.GetLine();
|
|
|
|
|
2010-10-07 08:25:47 +04:00
|
|
|
// How we determine the hypothetical box depends on whether the element
|
|
|
|
// would have been inline-level or block-level
|
2015-06-05 10:47:09 +03:00
|
|
|
LogicalRect lineBounds =
|
|
|
|
lineBox->GetBounds().ConvertTo(wm, lineBox->mWritingMode,
|
2015-07-16 12:07:57 +03:00
|
|
|
lineBox->mContainerSize);
|
2012-08-02 15:38:51 +04:00
|
|
|
if (mStyleDisplay->IsOriginalDisplayInlineOutsideStyle()) {
|
2015-06-05 10:47:09 +03:00
|
|
|
// Use the block-start of the inline box which the placeholder lives in
|
|
|
|
// as the hypothetical box's block-start.
|
2015-08-12 13:02:02 +03:00
|
|
|
aHypotheticalPos.mBStart = lineBounds.BStart(wm) + blockOffset.B(wm);
|
2010-10-07 08:25:47 +04:00
|
|
|
} else {
|
|
|
|
// The element would have been block-level which means it would
|
|
|
|
// be below the line containing the placeholder frame, unless
|
|
|
|
// all the frames before it are empty. In that case, it would
|
|
|
|
// have been just before this line.
|
|
|
|
// XXXbz the line box is not fully reflowed yet if our
|
|
|
|
// containing block is relatively positioned...
|
2011-11-07 09:25:56 +04:00
|
|
|
if (lineBox != iter.End()) {
|
2010-10-07 08:25:47 +04:00
|
|
|
nsIFrame * firstFrame = lineBox->mFirstChild;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool found = false;
|
2011-11-07 09:25:56 +04:00
|
|
|
bool allEmpty = true;
|
2010-10-07 08:25:47 +04:00
|
|
|
while (firstFrame) { // See bug 223064
|
|
|
|
allEmpty = AreAllEarlierInFlowFramesEmpty(firstFrame,
|
|
|
|
aPlaceholderFrame, &found);
|
|
|
|
if (found || !allEmpty)
|
|
|
|
break;
|
|
|
|
firstFrame = firstFrame->GetNextSibling();
|
|
|
|
}
|
|
|
|
NS_ASSERTION(firstFrame, "Couldn't find placeholder!");
|
|
|
|
|
2011-11-07 09:25:56 +04:00
|
|
|
if (allEmpty) {
|
|
|
|
// The top of the hypothetical box is the top of the line
|
|
|
|
// containing the placeholder, since there is nothing in the
|
|
|
|
// line before our placeholder except empty frames.
|
2015-08-12 13:02:02 +03:00
|
|
|
aHypotheticalPos.mBStart =
|
|
|
|
lineBounds.BStart(wm) + blockOffset.B(wm);
|
2011-11-07 09:25:56 +04:00
|
|
|
} else {
|
|
|
|
// The top of the hypothetical box is just below the line
|
|
|
|
// containing the placeholder.
|
2015-08-12 13:02:02 +03:00
|
|
|
aHypotheticalPos.mBStart =
|
|
|
|
lineBounds.BEnd(wm) + blockOffset.B(wm);
|
2011-11-07 09:25:56 +04:00
|
|
|
}
|
2003-10-18 12:04:37 +04:00
|
|
|
} else {
|
2015-06-05 10:47:09 +03:00
|
|
|
// Just use the placeholder's block-offset wrt the containing block
|
2015-08-12 13:02:02 +03:00
|
|
|
aHypotheticalPos.mBStart = placeholderOffset.B(wm);
|
2003-10-18 12:04:37 +04:00
|
|
|
}
|
2000-04-16 08:07:02 +04:00
|
|
|
}
|
|
|
|
}
|
2005-12-21 06:30:28 +03:00
|
|
|
} else {
|
|
|
|
// The containing block is not a block, so it's probably something
|
|
|
|
// like a XUL box, etc.
|
2015-06-05 10:47:09 +03:00
|
|
|
// Just use the placeholder's block-offset
|
2015-08-12 13:02:02 +03:00
|
|
|
aHypotheticalPos.mBStart = placeholderOffset.B(wm);
|
2015-06-05 10:47:09 +03:00
|
|
|
}
|
2000-04-16 08:07:02 +04:00
|
|
|
|
2015-08-12 13:02:02 +03:00
|
|
|
// Second, determine the hypothetical box's mIStart.
|
2015-06-05 10:47:09 +03:00
|
|
|
// How we determine the hypothetical box depends on whether the element
|
|
|
|
// would have been inline-level or block-level
|
|
|
|
if (mStyleDisplay->IsOriginalDisplayInlineOutsideStyle()) {
|
|
|
|
// The placeholder represents the left edge of the hypothetical box
|
2015-08-12 13:02:02 +03:00
|
|
|
aHypotheticalPos.mIStart = placeholderOffset.I(wm);
|
2003-01-29 14:35:10 +03:00
|
|
|
} else {
|
2015-08-12 13:02:02 +03:00
|
|
|
aHypotheticalPos.mIStart = blockIStartContentEdge;
|
1999-01-13 09:37:31 +03:00
|
|
|
}
|
|
|
|
|
2000-04-16 08:07:02 +04:00
|
|
|
// The current coordinate space is that of the nearest block to the placeholder.
|
|
|
|
// Convert to the coordinate space of the absolute containing block
|
2005-01-15 22:29:14 +03:00
|
|
|
// One weird thing here is that for fixed-positioned elements we want to do
|
|
|
|
// the conversion incorrectly; specifically we want to ignore any scrolling
|
|
|
|
// that may have happened;
|
|
|
|
nsPoint cbOffset;
|
2008-11-26 02:22:39 +03:00
|
|
|
if (mStyleDisplay->mPosition == NS_STYLE_POSITION_FIXED &&
|
|
|
|
// Exclude cases inside -moz-transform where fixed is like absolute.
|
|
|
|
nsLayoutUtils::IsReallyFixedPos(frame)) {
|
2014-12-14 20:22:06 +03:00
|
|
|
// In this case, cbrs->frame will likely be an ancestor of
|
2015-06-05 10:47:09 +03:00
|
|
|
// containingBlock, so can just walk our way up the frame tree.
|
2006-04-05 02:36:01 +04:00
|
|
|
// Make sure to not add positions of frames whose parent is a
|
|
|
|
// scrollFrame, since we're doing fixed positioning, which assumes
|
|
|
|
// everything is scrolled to (0,0).
|
2005-01-15 22:29:14 +03:00
|
|
|
cbOffset.MoveTo(0, 0);
|
|
|
|
do {
|
2015-06-05 10:47:09 +03:00
|
|
|
cbOffset += containingBlock->GetPositionIgnoringScrolling();
|
|
|
|
nsContainerFrame* parent = containingBlock->GetParent();
|
2014-12-14 20:22:06 +03:00
|
|
|
if (!parent) {
|
|
|
|
// Oops, our absolute containing block isn't an ancestor of the
|
|
|
|
// placeholder's containing block. This can happen if the placeholder
|
|
|
|
// is pushed to a different page in a printing context. 'cbOffset' is
|
2015-06-05 10:47:09 +03:00
|
|
|
// currently relative to the root frame (containingBlock) - so just
|
2014-12-14 20:22:06 +03:00
|
|
|
// subtract the offset to the absolute containing block to make it
|
|
|
|
// relative to that.
|
2015-06-05 10:47:09 +03:00
|
|
|
cbOffset -= containingBlock->GetOffsetTo(cbrs->frame);
|
2014-12-14 20:22:06 +03:00
|
|
|
break;
|
|
|
|
}
|
2015-06-05 10:47:09 +03:00
|
|
|
containingBlock = parent;
|
|
|
|
} while (containingBlock != cbrs->frame);
|
2005-01-15 22:29:14 +03:00
|
|
|
} else {
|
2008-11-26 02:22:39 +03:00
|
|
|
// XXXldb We need to either ignore scrolling for the absolute
|
|
|
|
// positioning case too (and take the incompatibility) or figure out
|
|
|
|
// how to make these positioned elements actually *move* when we
|
|
|
|
// scroll, and thus avoid the resulting incremental reflow bugs.
|
2015-06-05 10:47:09 +03:00
|
|
|
cbOffset = containingBlock->GetOffsetTo(cbrs->frame);
|
2005-01-15 22:29:14 +03:00
|
|
|
}
|
2015-08-06 23:01:31 +03:00
|
|
|
nsSize cbrsSize = cbrs->ComputedSizeAsContainerIfConstrained();
|
2015-07-16 12:07:57 +03:00
|
|
|
LogicalPoint logCBOffs(wm, cbOffset, cbrsSize - containerSize);
|
2015-08-12 13:02:02 +03:00
|
|
|
aHypotheticalPos.mIStart += logCBOffs.I(wm);
|
|
|
|
aHypotheticalPos.mBStart += logCBOffs.B(wm);
|
2015-06-05 10:47:09 +03:00
|
|
|
|
2004-04-24 21:56:23 +04:00
|
|
|
// The specified offsets are relative to the absolute containing block's
|
2005-07-26 00:15:31 +04:00
|
|
|
// padding edge and our current values are relative to the border edge, so
|
|
|
|
// translate.
|
2015-06-05 10:47:09 +03:00
|
|
|
LogicalMargin border =
|
|
|
|
cbrs->ComputedLogicalBorderPadding() - cbrs->ComputedLogicalPadding();
|
|
|
|
border = border.ConvertTo(wm, cbrs->GetWritingMode());
|
2015-08-12 13:02:02 +03:00
|
|
|
aHypotheticalPos.mIStart -= border.IStart(wm);
|
|
|
|
aHypotheticalPos.mBStart -= border.BStart(wm);
|
2015-08-06 23:01:31 +03:00
|
|
|
|
2015-08-12 13:02:02 +03:00
|
|
|
// At this point, we have computed aHypotheticalPos using the writing mode
|
2015-08-06 23:01:31 +03:00
|
|
|
// of the placeholder's containing block.
|
|
|
|
|
|
|
|
if (cbwm.GetBlockDir() != wm.GetBlockDir()) {
|
2015-08-12 13:02:02 +03:00
|
|
|
// If the block direction we used in calculating aHypotheticalPos does not
|
2015-08-06 23:01:31 +03:00
|
|
|
// match the absolute containing block's, we need to convert here so that
|
2015-08-12 13:02:02 +03:00
|
|
|
// aHypotheticalPos is usable in relation to the absolute containing block.
|
2015-08-06 23:01:31 +03:00
|
|
|
// This requires computing or measuring the abspos frame's block-size,
|
2015-08-12 13:02:02 +03:00
|
|
|
// which is not otherwise required/used here (as aHypotheticalPos
|
|
|
|
// records only the block-start coordinate).
|
2015-08-06 23:01:31 +03:00
|
|
|
|
|
|
|
// This is similar to the inline-size calculation for a replaced
|
|
|
|
// inline-level element or a block-level element (above), except that
|
|
|
|
// 'auto' sizing is handled differently in the block direction for non-
|
|
|
|
// replaced elements and replaced elements lacking an intrinsic size.
|
|
|
|
|
|
|
|
// Determine the total amount of block direction
|
|
|
|
// border/padding/margin that the element would have had if it had
|
|
|
|
// been in the flow. Note that we ignore any 'auto' and 'inherit'
|
|
|
|
// values.
|
|
|
|
nscoord insideBoxSizing, outsideBoxSizing;
|
|
|
|
CalculateBorderPaddingMargin(eLogicalAxisBlock,
|
|
|
|
blockContentSize.BSize(wm),
|
|
|
|
&insideBoxSizing, &outsideBoxSizing);
|
|
|
|
|
|
|
|
nscoord boxBSize;
|
|
|
|
nsStyleCoord styleBSize = mStylePosition->BSize(wm);
|
|
|
|
bool isAutoBSize = styleBSize.GetUnit() == eStyleUnit_Auto;
|
|
|
|
if (isAutoBSize) {
|
|
|
|
if (NS_FRAME_IS_REPLACED(mFrameType) && knowIntrinsicSize) {
|
|
|
|
// It's a replaced element with an 'auto' block size so the box
|
|
|
|
// block size is its intrinsic size plus any border/padding/margin
|
|
|
|
boxBSize = LogicalSize(wm, intrinsicSize).BSize(wm) +
|
|
|
|
outsideBoxSizing + insideBoxSizing;
|
|
|
|
} else {
|
|
|
|
// XXX Bug 1191801
|
|
|
|
// Figure out how to get the correct boxBSize here (need to reflow the
|
|
|
|
// positioned frame?)
|
|
|
|
boxBSize = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// We need to compute it. It's important we do this, because if it's
|
|
|
|
// percentage-based this computed value may be different from the
|
|
|
|
// computed value calculated using the absolute containing block height.
|
|
|
|
boxBSize = ComputeBSizeValue(blockContentSize.BSize(wm),
|
|
|
|
insideBoxSizing, styleBSize) +
|
|
|
|
insideBoxSizing + outsideBoxSizing;
|
|
|
|
}
|
|
|
|
|
|
|
|
LogicalSize boxSize(wm, knowBoxISize ? boxISize : 0, boxBSize);
|
|
|
|
|
2015-08-12 13:02:02 +03:00
|
|
|
LogicalPoint origin(wm, aHypotheticalPos.mIStart,
|
|
|
|
aHypotheticalPos.mBStart);
|
2015-08-06 23:01:31 +03:00
|
|
|
origin = origin.ConvertTo(cbwm, wm, cbrsSize -
|
|
|
|
boxSize.GetPhysicalSize(wm));
|
|
|
|
|
2015-08-12 13:02:02 +03:00
|
|
|
aHypotheticalPos.mIStart = origin.I(cbwm);
|
|
|
|
aHypotheticalPos.mBStart = origin.B(cbwm);
|
|
|
|
aHypotheticalPos.mWritingMode = cbwm;
|
2015-08-06 23:01:31 +03:00
|
|
|
} else {
|
2015-08-12 13:02:02 +03:00
|
|
|
aHypotheticalPos.mWritingMode = wm;
|
2015-08-06 23:01:31 +03:00
|
|
|
}
|
2000-04-16 08:07:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsHTMLReflowState::InitAbsoluteConstraints(nsPresContext* aPresContext,
|
2000-04-16 08:07:02 +04:00
|
|
|
const nsHTMLReflowState* cbrs,
|
2015-06-04 13:43:02 +03:00
|
|
|
const LogicalSize& aCBSize,
|
2011-06-11 03:02:14 +04:00
|
|
|
nsIAtom* aFrameType)
|
2000-04-16 08:07:02 +04:00
|
|
|
{
|
2015-06-04 13:43:02 +03:00
|
|
|
WritingMode wm = GetWritingMode();
|
2015-06-05 10:47:09 +03:00
|
|
|
WritingMode cbwm = cbrs->GetWritingMode();
|
|
|
|
NS_PRECONDITION(aCBSize.BSize(cbwm) != NS_AUTOHEIGHT,
|
|
|
|
"containing block bsize must be constrained");
|
2000-04-16 08:07:02 +04:00
|
|
|
|
2011-06-11 03:02:14 +04:00
|
|
|
NS_ASSERTION(aFrameType != nsGkAtoms::tableFrame,
|
2011-05-10 04:36:10 +04:00
|
|
|
"InitAbsoluteConstraints should not be called on table frames");
|
|
|
|
NS_ASSERTION(frame->GetStateBits() & NS_FRAME_OUT_OF_FLOW,
|
2009-02-24 21:38:20 +03:00
|
|
|
"Why are we here?");
|
|
|
|
|
2000-04-16 08:07:02 +04:00
|
|
|
// Get the placeholder frame
|
2011-11-07 09:25:56 +04:00
|
|
|
nsIFrame* placeholderFrame;
|
2000-04-16 08:07:02 +04:00
|
|
|
|
2011-11-07 09:25:56 +04:00
|
|
|
placeholderFrame = aPresContext->PresShell()->GetPlaceholderFrameFor(frame);
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_ASSERTION(nullptr != placeholderFrame, "no placeholder frame");
|
2000-04-16 08:07:02 +04:00
|
|
|
|
|
|
|
// If both 'left' and 'right' are 'auto' or both 'top' and 'bottom' are
|
2015-08-12 13:02:02 +03:00
|
|
|
// 'auto', then compute the hypothetical box position where the element would
|
2000-04-16 08:07:02 +04:00
|
|
|
// have been if it had been in the flow
|
2015-08-12 13:02:02 +03:00
|
|
|
nsHypotheticalPosition hypotheticalPos;
|
2000-04-16 08:07:02 +04:00
|
|
|
if (((eStyleUnit_Auto == mStylePosition->mOffset.GetLeftUnit()) &&
|
|
|
|
(eStyleUnit_Auto == mStylePosition->mOffset.GetRightUnit())) ||
|
|
|
|
((eStyleUnit_Auto == mStylePosition->mOffset.GetTopUnit()) &&
|
|
|
|
(eStyleUnit_Auto == mStylePosition->mOffset.GetBottomUnit()))) {
|
2015-08-12 13:02:02 +03:00
|
|
|
CalculateHypotheticalPosition(aPresContext, placeholderFrame, cbrs,
|
|
|
|
hypotheticalPos, aFrameType);
|
2000-04-16 08:07:02 +04:00
|
|
|
}
|
1999-01-13 09:37:31 +03:00
|
|
|
|
|
|
|
// Initialize the 'left' and 'right' computed offsets
|
2000-04-16 08:07:02 +04:00
|
|
|
// XXX Handle new 'static-position' value...
|
2015-06-05 10:47:09 +03:00
|
|
|
|
|
|
|
bool iStartIsAuto = false, iEndIsAuto = false;
|
|
|
|
bool bStartIsAuto = false, bEndIsAuto = false;
|
|
|
|
|
|
|
|
// Size of the containing block in its writing mode
|
|
|
|
LogicalSize cbSize = aCBSize;
|
|
|
|
|
|
|
|
LogicalMargin offsets = ComputedLogicalOffsets().ConvertTo(cbwm, wm);
|
|
|
|
|
|
|
|
if (eStyleUnit_Auto == mStylePosition->mOffset.GetIStartUnit(cbwm)) {
|
|
|
|
offsets.IStart(cbwm) = 0;
|
|
|
|
iStartIsAuto = true;
|
1999-01-13 09:37:31 +03:00
|
|
|
} else {
|
2015-06-05 10:47:09 +03:00
|
|
|
offsets.IStart(cbwm) = nsLayoutUtils::
|
|
|
|
ComputeCBDependentValue(cbSize.ISize(cbwm),
|
|
|
|
mStylePosition->mOffset.GetIStart(cbwm));
|
1999-01-13 09:37:31 +03:00
|
|
|
}
|
2015-06-05 10:47:09 +03:00
|
|
|
if (eStyleUnit_Auto == mStylePosition->mOffset.GetIEndUnit(cbwm)) {
|
|
|
|
offsets.IEnd(cbwm) = 0;
|
|
|
|
iEndIsAuto = true;
|
1999-01-13 09:37:31 +03:00
|
|
|
} else {
|
2015-06-05 10:47:09 +03:00
|
|
|
offsets.IEnd(cbwm) = nsLayoutUtils::
|
|
|
|
ComputeCBDependentValue(cbSize.ISize(cbwm),
|
|
|
|
mStylePosition->mOffset.GetIEnd(cbwm));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (iStartIsAuto && iEndIsAuto) {
|
2015-08-12 13:02:02 +03:00
|
|
|
if (cbwm.IsBidiLTR() != hypotheticalPos.mWritingMode.IsBidiLTR()) {
|
|
|
|
offsets.IEnd(cbwm) = hypotheticalPos.mIStart;
|
2015-06-05 10:47:09 +03:00
|
|
|
iEndIsAuto = false;
|
1999-01-13 09:37:31 +03:00
|
|
|
} else {
|
2015-08-12 13:02:02 +03:00
|
|
|
offsets.IStart(cbwm) = hypotheticalPos.mIStart;
|
2015-06-05 10:47:09 +03:00
|
|
|
iStartIsAuto = false;
|
2000-04-16 08:07:02 +04:00
|
|
|
}
|
1999-01-13 09:37:31 +03:00
|
|
|
}
|
|
|
|
|
2015-06-05 10:47:09 +03:00
|
|
|
if (eStyleUnit_Auto == mStylePosition->mOffset.GetBStartUnit(cbwm)) {
|
|
|
|
offsets.BStart(cbwm) = 0;
|
|
|
|
bStartIsAuto = true;
|
1999-01-13 09:37:31 +03:00
|
|
|
} else {
|
2015-06-05 10:47:09 +03:00
|
|
|
offsets.BStart(cbwm) = nsLayoutUtils::
|
|
|
|
ComputeBSizeDependentValue(cbSize.BSize(cbwm),
|
|
|
|
mStylePosition->mOffset.GetBStart(cbwm));
|
1999-01-13 09:37:31 +03:00
|
|
|
}
|
2015-06-05 10:47:09 +03:00
|
|
|
if (eStyleUnit_Auto == mStylePosition->mOffset.GetBEndUnit(cbwm)) {
|
|
|
|
offsets.BEnd(cbwm) = 0;
|
|
|
|
bEndIsAuto = true;
|
1999-01-13 09:37:31 +03:00
|
|
|
} else {
|
2015-06-05 10:47:09 +03:00
|
|
|
offsets.BEnd(cbwm) = nsLayoutUtils::
|
|
|
|
ComputeBSizeDependentValue(cbSize.BSize(cbwm),
|
|
|
|
mStylePosition->mOffset.GetBEnd(cbwm));
|
1999-01-13 09:37:31 +03:00
|
|
|
}
|
|
|
|
|
2015-06-05 10:47:09 +03:00
|
|
|
if (bStartIsAuto && bEndIsAuto) {
|
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
|
|
|
// Treat 'top' like 'static-position'
|
2015-08-12 13:02:02 +03:00
|
|
|
offsets.BStart(cbwm) = hypotheticalPos.mBStart;
|
2015-06-05 10:47:09 +03:00
|
|
|
bStartIsAuto = false;
|
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
|
|
|
}
|
|
|
|
|
2015-06-05 10:47:09 +03:00
|
|
|
SetComputedLogicalOffsets(offsets.ConvertTo(wm, cbwm));
|
|
|
|
|
|
|
|
bool iSizeIsAuto = eStyleUnit_Auto == mStylePosition->ISize(cbwm).GetUnit();
|
|
|
|
bool bSizeIsAuto = eStyleUnit_Auto == mStylePosition->BSize(cbwm).GetUnit();
|
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
|
|
|
|
2014-11-11 14:02:41 +03:00
|
|
|
typedef nsIFrame::ComputeSizeFlags ComputeSizeFlags;
|
|
|
|
ComputeSizeFlags computeSizeFlags = ComputeSizeFlags::eDefault;
|
2015-06-05 10:47:09 +03:00
|
|
|
if (wm.IsOrthogonalTo(cbwm)) {
|
|
|
|
if (bStartIsAuto || bEndIsAuto) {
|
|
|
|
computeSizeFlags =
|
|
|
|
ComputeSizeFlags(computeSizeFlags | ComputeSizeFlags::eShrinkWrap);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (iStartIsAuto || iEndIsAuto) {
|
|
|
|
computeSizeFlags =
|
|
|
|
ComputeSizeFlags(computeSizeFlags | ComputeSizeFlags::eShrinkWrap);
|
|
|
|
}
|
2012-03-16 22:01:05 +04:00
|
|
|
}
|
|
|
|
|
2015-06-05 10:47:09 +03:00
|
|
|
LogicalSize computedSize(wm);
|
2012-01-25 05:21:29 +04:00
|
|
|
{
|
2012-05-21 09:18:27 +04:00
|
|
|
AutoMaybeDisableFontInflation an(frame);
|
2012-01-25 05:21:29 +04:00
|
|
|
|
2015-06-05 10:47:09 +03:00
|
|
|
computedSize =
|
|
|
|
frame->ComputeSize(rendContext, wm, cbSize.ConvertTo(wm, cbwm),
|
|
|
|
cbSize.ConvertTo(wm, cbwm).ISize(wm), // XXX or AvailableISize()?
|
2014-08-24 18:34:44 +04:00
|
|
|
ComputedLogicalMargin().Size(wm) +
|
|
|
|
ComputedLogicalOffsets().Size(wm),
|
|
|
|
ComputedLogicalBorderPadding().Size(wm) -
|
|
|
|
ComputedLogicalPadding().Size(wm),
|
|
|
|
ComputedLogicalPadding().Size(wm),
|
2012-03-16 22:01:05 +04:00
|
|
|
computeSizeFlags);
|
2015-06-05 10:47:09 +03:00
|
|
|
ComputedISize() = computedSize.ISize(wm);
|
|
|
|
ComputedBSize() = computedSize.BSize(wm);
|
|
|
|
NS_ASSERTION(ComputedISize() >= 0, "Bogus inline-size");
|
|
|
|
NS_ASSERTION(ComputedBSize() == NS_UNCONSTRAINEDSIZE ||
|
|
|
|
ComputedBSize() >= 0, "Bogus block-size");
|
2012-01-25 05:21:29 +04:00
|
|
|
}
|
2015-06-05 10:47:09 +03:00
|
|
|
computedSize = computedSize.ConvertTo(cbwm, wm);
|
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
|
|
|
|
|
|
|
// XXX Now that we have ComputeSize, can we condense many of the
|
|
|
|
// branches off of widthIsAuto?
|
2000-04-16 08:07:02 +04:00
|
|
|
|
2015-06-05 10:47:09 +03:00
|
|
|
LogicalMargin margin = ComputedLogicalMargin().ConvertTo(cbwm, wm);
|
|
|
|
const LogicalMargin borderPadding =
|
|
|
|
ComputedLogicalBorderPadding().ConvertTo(cbwm, wm);
|
|
|
|
|
|
|
|
if (iStartIsAuto) {
|
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
|
|
|
// We know 'right' is not 'auto' anymore thanks to the hypothetical
|
|
|
|
// box code above.
|
|
|
|
// Solve for 'left'.
|
2015-06-05 10:47:09 +03:00
|
|
|
if (iSizeIsAuto) {
|
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 This, and the corresponding code in
|
|
|
|
// nsAbsoluteContainingBlock.cpp, could probably go away now that
|
|
|
|
// we always compute widths.
|
2015-06-05 10:47:09 +03:00
|
|
|
offsets.IStart(cbwm) = NS_AUTOOFFSET;
|
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
|
|
|
} else {
|
2015-06-05 10:47:09 +03:00
|
|
|
offsets.IStart(cbwm) =
|
|
|
|
cbSize.ISize(cbwm) - offsets.IEnd(cbwm) -
|
|
|
|
computedSize.ISize(cbwm) - margin.IStartEnd(cbwm) -
|
|
|
|
borderPadding.IStartEnd(cbwm);
|
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
|
|
|
}
|
2015-06-05 10:47:09 +03:00
|
|
|
} else if (iEndIsAuto) {
|
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
|
|
|
// We know 'left' is not 'auto' anymore thanks to the hypothetical
|
|
|
|
// box code above.
|
|
|
|
// Solve for 'right'.
|
2015-06-05 10:47:09 +03:00
|
|
|
if (iSizeIsAuto) {
|
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 This, and the corresponding code in
|
|
|
|
// nsAbsoluteContainingBlock.cpp, could probably go away now that
|
|
|
|
// we always compute widths.
|
2015-06-05 10:47:09 +03:00
|
|
|
offsets.IEnd(cbwm) = NS_AUTOOFFSET;
|
1999-01-13 09:37:31 +03:00
|
|
|
} else {
|
2015-06-05 10:47:09 +03:00
|
|
|
offsets.IEnd(cbwm) =
|
|
|
|
cbSize.ISize(cbwm) - offsets.IStart(cbwm) -
|
|
|
|
computedSize.ISize(cbwm) - margin.IStartEnd(cbwm) -
|
|
|
|
borderPadding.IStartEnd(cbwm);
|
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
|
|
|
}
|
|
|
|
} else {
|
2015-06-05 10:47:09 +03:00
|
|
|
// Neither 'inline-start' nor 'inline-end' is 'auto'.
|
|
|
|
|
|
|
|
if (wm.IsOrthogonalTo(cbwm)) {
|
|
|
|
// For orthogonal blocks, we need to handle the case where the block had
|
|
|
|
// unconstrained block-size, which mapped to unconstrained inline-size
|
|
|
|
// in the containing block's writing mode.
|
|
|
|
nscoord autoISize = cbSize.ISize(cbwm) - margin.IStartEnd(cbwm) -
|
|
|
|
borderPadding.IStartEnd(cbwm) - offsets.IStartEnd(cbwm);
|
|
|
|
if (autoISize < 0) {
|
|
|
|
autoISize = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (computedSize.ISize(cbwm) == NS_UNCONSTRAINEDSIZE) {
|
|
|
|
// For non-replaced elements with block-size auto, the block-size
|
|
|
|
// fills the remaining space.
|
|
|
|
computedSize.ISize(cbwm) = autoISize;
|
|
|
|
|
|
|
|
// XXX Do these need box-sizing adjustments?
|
|
|
|
LogicalSize maxSize = ComputedMaxSize(cbwm);
|
|
|
|
LogicalSize minSize = ComputedMinSize(cbwm);
|
|
|
|
if (computedSize.ISize(cbwm) > maxSize.ISize(cbwm)) {
|
|
|
|
computedSize.ISize(cbwm) = maxSize.ISize(cbwm);
|
|
|
|
}
|
|
|
|
if (computedSize.ISize(cbwm) < minSize.ISize(cbwm)) {
|
|
|
|
computedSize.ISize(cbwm) = minSize.ISize(cbwm);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// However, the inline-size might
|
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
|
|
|
// still not fill all the available space (even though we didn't
|
|
|
|
// shrink-wrap) in case:
|
2015-06-05 10:47:09 +03:00
|
|
|
// * inline-size was specified
|
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
|
|
|
// * we're dealing with a replaced element
|
2015-06-05 10:47:09 +03:00
|
|
|
// * width was constrained by min- or max-inline-size.
|
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
|
|
|
|
2015-06-05 10:47:09 +03:00
|
|
|
nscoord availMarginSpace =
|
|
|
|
aCBSize.ISize(cbwm) - offsets.IStartEnd(cbwm) - margin.IStartEnd(cbwm) -
|
|
|
|
borderPadding.IStartEnd(cbwm) - computedSize.ISize(cbwm);
|
|
|
|
bool marginIStartIsAuto =
|
|
|
|
eStyleUnit_Auto == mStyleMargin->mMargin.GetIStartUnit(cbwm);
|
|
|
|
bool marginIEndIsAuto =
|
|
|
|
eStyleUnit_Auto == mStyleMargin->mMargin.GetIEndUnit(cbwm);
|
|
|
|
|
|
|
|
if (marginIStartIsAuto) {
|
|
|
|
if (marginIEndIsAuto) {
|
2011-03-04 00:18:42 +03:00
|
|
|
if (availMarginSpace < 0) {
|
|
|
|
// Note that this case is different from the neither-'auto'
|
|
|
|
// case below, where the spec says to ignore 'left'/'right'.
|
2015-06-05 10:47:09 +03:00
|
|
|
// Ignore the specified value for 'margin-right'.
|
|
|
|
margin.IEnd(cbwm) = availMarginSpace;
|
2011-03-04 00:18:42 +03:00
|
|
|
} else {
|
|
|
|
// Both 'margin-left' and 'margin-right' are 'auto', so they get
|
|
|
|
// equal values
|
2015-06-05 10:47:09 +03:00
|
|
|
margin.IStart(cbwm) = availMarginSpace / 2;
|
|
|
|
margin.IEnd(cbwm) = availMarginSpace - margin.IStart(cbwm);
|
2011-03-04 00:18:42 +03:00
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
} else {
|
|
|
|
// Just 'margin-left' is 'auto'
|
2015-06-05 10:47:09 +03:00
|
|
|
margin.IStart(cbwm) = availMarginSpace;
|
2000-04-16 08:07:02 +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
|
|
|
} else {
|
2015-06-05 10:47:09 +03:00
|
|
|
if (marginIEndIsAuto) {
|
2011-03-04 00:18:42 +03:00
|
|
|
// Just 'margin-right' is 'auto'
|
2015-06-05 10:47:09 +03:00
|
|
|
margin.IEnd(cbwm) = availMarginSpace;
|
2011-03-04 00:18:42 +03:00
|
|
|
} else {
|
|
|
|
// We're over-constrained so use the direction of the containing
|
|
|
|
// block to dictate which value to ignore. (And note that the
|
|
|
|
// spec says to ignore 'left' or 'right' rather than
|
|
|
|
// 'margin-left' or 'margin-right'.)
|
|
|
|
// Note that this case is different from the both-'auto' case
|
|
|
|
// above, where the spec says to ignore
|
|
|
|
// 'margin-left'/'margin-right'.
|
2015-06-05 10:47:09 +03:00
|
|
|
// Ignore the specified value for 'right'.
|
|
|
|
offsets.IEnd(cbwm) += availMarginSpace;
|
2011-03-04 00:18:42 +03:00
|
|
|
}
|
2000-04-16 08:07:02 +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
|
|
|
}
|
2000-04-16 08:07:02 +04:00
|
|
|
|
2015-06-05 10:47:09 +03:00
|
|
|
if (bStartIsAuto) {
|
|
|
|
// solve for block-start
|
|
|
|
if (bSizeIsAuto) {
|
|
|
|
offsets.BStart(cbwm) = NS_AUTOOFFSET;
|
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
|
|
|
} else {
|
2015-06-05 10:47:09 +03:00
|
|
|
offsets.BStart(cbwm) = cbSize.BSize(cbwm) - margin.BStartEnd(cbwm) -
|
|
|
|
borderPadding.BStartEnd(cbwm) - computedSize.BSize(cbwm) -
|
|
|
|
offsets.BEnd(cbwm);
|
2000-04-16 08:07:02 +04:00
|
|
|
}
|
2015-06-05 10:47:09 +03:00
|
|
|
} else if (bEndIsAuto) {
|
|
|
|
// solve for block-end
|
|
|
|
if (bSizeIsAuto) {
|
|
|
|
offsets.BEnd(cbwm) = NS_AUTOOFFSET;
|
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
|
|
|
} else {
|
2015-06-05 10:47:09 +03:00
|
|
|
offsets.BEnd(cbwm) = cbSize.BSize(cbwm) - margin.BStartEnd(cbwm) -
|
|
|
|
borderPadding.BStartEnd(cbwm) - computedSize.BSize(cbwm) -
|
|
|
|
offsets.BStart(cbwm);
|
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
|
|
|
}
|
|
|
|
} else {
|
2015-06-05 10:47:09 +03:00
|
|
|
// Neither block-start nor -end is 'auto'.
|
|
|
|
nscoord autoBSize = cbSize.BSize(cbwm) - margin.BStartEnd(cbwm) -
|
|
|
|
borderPadding.BStartEnd(cbwm) - offsets.BStartEnd(cbwm);
|
|
|
|
if (autoBSize < 0) {
|
|
|
|
autoBSize = 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
|
|
|
}
|
|
|
|
|
2015-06-05 10:47:09 +03:00
|
|
|
if (computedSize.BSize(cbwm) == NS_UNCONSTRAINEDSIZE) {
|
|
|
|
// For non-replaced elements with block-size auto, the block-size
|
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
|
|
|
// fills the remaining space.
|
2015-06-05 10:47:09 +03:00
|
|
|
computedSize.BSize(cbwm) = autoBSize;
|
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
|
|
|
|
|
|
|
// XXX Do these need box-sizing adjustments?
|
2015-06-05 10:47:09 +03:00
|
|
|
LogicalSize maxSize = ComputedMaxSize(cbwm);
|
|
|
|
LogicalSize minSize = ComputedMinSize(cbwm);
|
2015-06-05 10:47:09 +03:00
|
|
|
if (computedSize.BSize(cbwm) > maxSize.BSize(cbwm)) {
|
|
|
|
computedSize.BSize(cbwm) = maxSize.BSize(cbwm);
|
|
|
|
}
|
|
|
|
if (computedSize.BSize(cbwm) < minSize.BSize(cbwm)) {
|
|
|
|
computedSize.BSize(cbwm) = minSize.BSize(cbwm);
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2015-06-05 10:47:09 +03:00
|
|
|
// The block-size might still not fill all the available space in case:
|
|
|
|
// * bsize was specified
|
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
|
|
|
// * we're dealing with a replaced element
|
2015-06-05 10:47:09 +03:00
|
|
|
// * bsize was constrained by min- or max-bsize.
|
|
|
|
nscoord availMarginSpace = autoBSize - computedSize.BSize(cbwm);
|
|
|
|
bool marginBStartIsAuto =
|
|
|
|
eStyleUnit_Auto == mStyleMargin->mMargin.GetBStartUnit(cbwm);
|
|
|
|
bool marginBEndIsAuto =
|
|
|
|
eStyleUnit_Auto == mStyleMargin->mMargin.GetBEndUnit(cbwm);
|
|
|
|
|
|
|
|
if (marginBStartIsAuto) {
|
|
|
|
if (marginBEndIsAuto) {
|
2015-07-17 19:04:24 +03:00
|
|
|
if (availMarginSpace < 0) {
|
|
|
|
// FIXME: Note that the spec doesn't actually say we should do this!
|
|
|
|
margin.BEnd(cbwm) = availMarginSpace;
|
|
|
|
} else {
|
|
|
|
// Both margin-block-start and -end are 'auto', so they get
|
|
|
|
// equal values
|
|
|
|
margin.BStart(cbwm) = availMarginSpace / 2;
|
|
|
|
margin.BEnd(cbwm) = availMarginSpace - margin.BStart(cbwm);
|
|
|
|
}
|
1999-01-13 09:37:31 +03:00
|
|
|
} else {
|
2015-06-05 10:47:09 +03:00
|
|
|
// Just margin-block-start is 'auto'
|
|
|
|
margin.BStart(cbwm) = availMarginSpace;
|
1999-01-13 09:37:31 +03:00
|
|
|
}
|
1999-02-18 07:40:16 +03:00
|
|
|
} else {
|
2015-06-05 10:47:09 +03:00
|
|
|
if (marginBEndIsAuto) {
|
|
|
|
// Just margin-block-end is 'auto'
|
|
|
|
margin.BEnd(cbwm) = availMarginSpace;
|
2011-03-04 00:18:42 +03:00
|
|
|
} else {
|
|
|
|
// We're over-constrained so ignore the specified value for
|
2015-06-05 10:47:09 +03:00
|
|
|
// block-end. (And note that the spec says to ignore 'bottom'
|
2011-03-04 00:18:42 +03:00
|
|
|
// rather than 'margin-bottom'.)
|
2015-06-05 10:47:09 +03:00
|
|
|
offsets.BEnd(cbwm) += availMarginSpace;
|
2011-03-04 00:18:42 +03:00
|
|
|
}
|
1999-07-28 07:51:37 +04:00
|
|
|
}
|
1999-07-20 06:48:18 +04:00
|
|
|
}
|
2015-06-05 10:47:09 +03:00
|
|
|
ComputedBSize() = computedSize.ConvertTo(wm, cbwm).BSize(wm);
|
|
|
|
ComputedISize() = computedSize.ConvertTo(wm, cbwm).ISize(wm);
|
|
|
|
|
|
|
|
SetComputedLogicalOffsets(offsets.ConvertTo(wm, cbwm));
|
|
|
|
SetComputedLogicalMargin(margin.ConvertTo(wm, cbwm));
|
2000-04-16 08:07:02 +04:00
|
|
|
}
|
1999-03-11 18:13:17 +03:00
|
|
|
|
2015-06-04 13:43:02 +03:00
|
|
|
// This will not be converted to abstract coordinates because it's only
|
|
|
|
// used in CalcQuirkContainingBlockHeight
|
|
|
|
nscoord
|
|
|
|
GetBlockMarginBorderPadding(const nsHTMLReflowState* aReflowState)
|
2000-04-29 01:05:31 +04:00
|
|
|
{
|
|
|
|
nscoord result = 0;
|
|
|
|
if (!aReflowState) return result;
|
|
|
|
|
|
|
|
// zero auto margins
|
2013-12-27 21:59:21 +04:00
|
|
|
nsMargin margin = aReflowState->ComputedPhysicalMargin();
|
2015-07-17 19:04:24 +03:00
|
|
|
if (NS_AUTOMARGIN == margin.top)
|
2000-04-29 01:05:31 +04:00
|
|
|
margin.top = 0;
|
2015-07-17 19:04:24 +03:00
|
|
|
if (NS_AUTOMARGIN == margin.bottom)
|
2000-04-29 01:05:31 +04:00
|
|
|
margin.bottom = 0;
|
|
|
|
|
|
|
|
result += margin.top + margin.bottom;
|
2015-07-17 19:04:24 +03:00
|
|
|
result += aReflowState->ComputedPhysicalBorderPadding().top +
|
2013-12-27 21:59:21 +04:00
|
|
|
aReflowState->ComputedPhysicalBorderPadding().bottom;
|
2000-04-29 01:05:31 +04:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2015-07-17 19:04:24 +03:00
|
|
|
/* Get the height based on the viewport of the containing block specified
|
2000-04-29 01:05:31 +04:00
|
|
|
* in aReflowState when the containing block has mComputedHeight == NS_AUTOHEIGHT
|
2001-09-09 00:09:08 +04:00
|
|
|
* This will walk up the chain of containing blocks looking for a computed height
|
2003-10-06 17:13:37 +04:00
|
|
|
* until it finds the canvas frame, or it encounters a frame that is not a block,
|
|
|
|
* area, or scroll frame. This handles compatibility with IE (see bug 85016 and bug 219693)
|
2001-09-11 04:12:28 +04:00
|
|
|
*
|
2015-06-05 10:47:09 +03:00
|
|
|
* When we encounter scrolledContent block frames, we skip over them,
|
|
|
|
* since they are guaranteed to not be useful for computing the containing block.
|
2007-05-16 01:52:44 +04:00
|
|
|
*
|
|
|
|
* See also IsQuirkContainingBlockHeight.
|
2000-04-29 01:05:31 +04:00
|
|
|
*/
|
2007-05-16 01:52:44 +04:00
|
|
|
static nscoord
|
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
|
|
|
CalcQuirkContainingBlockHeight(const nsHTMLReflowState* aCBReflowState)
|
2000-04-29 01:05:31 +04:00
|
|
|
{
|
2013-04-23 06:41:19 +04:00
|
|
|
const nsHTMLReflowState* firstAncestorRS = nullptr; // a candidate for html frame
|
|
|
|
const nsHTMLReflowState* secondAncestorRS = nullptr; // a candidate for body frame
|
2015-07-17 19:04:24 +03:00
|
|
|
|
2003-01-28 08:19:20 +03:00
|
|
|
// initialize the default to NS_AUTOHEIGHT as this is the containings block
|
2015-07-17 19:04:24 +03:00
|
|
|
// computed height when this function is called. It is possible that we
|
2003-01-28 08:19:20 +03:00
|
|
|
// don't alter this height especially if we are restricted to one level
|
2015-07-17 19:04:24 +03:00
|
|
|
nscoord result = NS_AUTOHEIGHT;
|
|
|
|
|
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
|
|
|
const nsHTMLReflowState* rs = aCBReflowState;
|
2013-04-23 06:41:19 +04:00
|
|
|
for (; rs; rs = rs->parentReflowState) {
|
2003-10-31 23:19:18 +03:00
|
|
|
nsIAtom* frameType = rs->frame->GetType();
|
2015-07-17 19:04:24 +03:00
|
|
|
// if the ancestor is auto height then skip it and continue up if it
|
2009-01-04 22:52:38 +03:00
|
|
|
// is the first block frame and possibly the body/html
|
2006-12-26 20:47:52 +03:00
|
|
|
if (nsGkAtoms::blockFrame == frameType ||
|
2008-12-29 18:07:38 +03:00
|
|
|
#ifdef MOZ_XUL
|
|
|
|
nsGkAtoms::XULLabelFrame == frameType ||
|
|
|
|
#endif
|
2006-12-26 20:47:52 +03:00
|
|
|
nsGkAtoms::scrollFrame == frameType) {
|
2003-10-18 04:24:28 +04:00
|
|
|
|
2003-10-06 17:13:37 +04:00
|
|
|
secondAncestorRS = firstAncestorRS;
|
2013-04-23 06:41:19 +04:00
|
|
|
firstAncestorRS = rs;
|
2003-10-18 04:24:28 +04:00
|
|
|
|
|
|
|
// If the current frame we're looking at is positioned, we don't want to
|
|
|
|
// go any further (see bug 221784). The behavior we want here is: 1) If
|
|
|
|
// not auto-height, use this as the percentage base. 2) If auto-height,
|
|
|
|
// keep looking, unless the frame is positioned.
|
2007-08-02 22:08:05 +04:00
|
|
|
if (NS_AUTOHEIGHT == rs->ComputedHeight()) {
|
2012-08-02 15:38:50 +04:00
|
|
|
if (rs->frame->IsAbsolutelyPositioned()) {
|
2003-10-18 04:24:28 +04:00
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
continue;
|
|
|
|
}
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
|
|
|
}
|
2006-12-26 20:47:52 +03:00
|
|
|
else if (nsGkAtoms::canvasFrame == frameType) {
|
2007-12-05 06:05:57 +03:00
|
|
|
// Always continue on to the height calculation
|
2000-11-30 01:31:57 +03:00
|
|
|
}
|
2006-12-26 20:47:52 +03:00
|
|
|
else if (nsGkAtoms::pageContentFrame == frameType) {
|
2004-09-14 06:28:03 +04:00
|
|
|
nsIFrame* prevInFlow = rs->frame->GetPrevInFlow();
|
2002-04-11 01:32:41 +04:00
|
|
|
// only use the page content frame for a height basis if it is the first in flow
|
2015-07-17 19:04:24 +03:00
|
|
|
if (prevInFlow)
|
2002-04-11 01:32:41 +04:00
|
|
|
break;
|
|
|
|
}
|
2000-05-17 02:02:16 +04:00
|
|
|
else {
|
2000-04-29 01:05:31 +04:00
|
|
|
break;
|
|
|
|
}
|
2000-05-17 02:02:16 +04:00
|
|
|
|
2015-07-17 19:04:24 +03:00
|
|
|
// if the ancestor is the page content frame then the percent base is
|
2002-04-11 01:32:41 +04:00
|
|
|
// the avail height, otherwise it is the computed height
|
2006-12-26 20:47:52 +03:00
|
|
|
result = (nsGkAtoms::pageContentFrame == frameType)
|
2013-12-27 21:59:21 +04:00
|
|
|
? rs->AvailableHeight() : rs->ComputedHeight();
|
2000-05-17 02:02:16 +04:00
|
|
|
// if unconstrained - don't sutract borders - would result in huge height
|
|
|
|
if (NS_AUTOHEIGHT == result) return result;
|
|
|
|
|
2015-07-17 19:04:24 +03:00
|
|
|
// if we got to the canvas or page content frame, then subtract out
|
2000-04-29 01:05:31 +04:00
|
|
|
// margin/border/padding for the BODY and HTML elements
|
2015-07-17 19:04:24 +03:00
|
|
|
if ((nsGkAtoms::canvasFrame == frameType) ||
|
2006-12-26 20:47:52 +03:00
|
|
|
(nsGkAtoms::pageContentFrame == frameType)) {
|
2001-09-09 00:09:08 +04:00
|
|
|
|
2015-06-04 13:43:02 +03:00
|
|
|
result -= GetBlockMarginBorderPadding(firstAncestorRS);
|
|
|
|
result -= GetBlockMarginBorderPadding(secondAncestorRS);
|
2001-09-09 00:09:08 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2003-10-06 17:13:37 +04:00
|
|
|
// make sure the first ancestor is the HTML and the second is the BODY
|
|
|
|
if (firstAncestorRS) {
|
|
|
|
nsIContent* frameContent = firstAncestorRS->frame->GetContent();
|
2001-09-09 00:09:08 +04:00
|
|
|
if (frameContent) {
|
2015-06-05 10:47:09 +03:00
|
|
|
NS_ASSERTION(frameContent->IsHTMLElement(nsGkAtoms::html),
|
|
|
|
"First ancestor is not HTML");
|
2001-09-09 00:09:08 +04:00
|
|
|
}
|
|
|
|
}
|
2003-10-06 17:13:37 +04:00
|
|
|
if (secondAncestorRS) {
|
|
|
|
nsIContent* frameContent = secondAncestorRS->frame->GetContent();
|
2001-09-09 00:09:08 +04:00
|
|
|
if (frameContent) {
|
2015-06-05 10:47:09 +03:00
|
|
|
NS_ASSERTION(frameContent->IsHTMLElement(nsGkAtoms::body),
|
|
|
|
"Second ancestor is not BODY");
|
2001-09-09 00:09:08 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2015-07-17 19:04:24 +03:00
|
|
|
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
2008-12-29 18:07:38 +03:00
|
|
|
// if we got to the html frame (a block child of the canvas) ...
|
|
|
|
else if (nsGkAtoms::blockFrame == frameType &&
|
2011-11-09 08:22:36 +04:00
|
|
|
rs->parentReflowState &&
|
2008-12-29 18:07:38 +03:00
|
|
|
nsGkAtoms::canvasFrame ==
|
|
|
|
rs->parentReflowState->frame->GetType()) {
|
|
|
|
// ... then subtract out margin/border/padding for the BODY element
|
2015-06-04 13:43:02 +03:00
|
|
|
result -= GetBlockMarginBorderPadding(secondAncestorRS);
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-08-03 00:09:49 +04:00
|
|
|
// Make sure not to return a negative height here!
|
2013-01-15 16:22:03 +04:00
|
|
|
return std::max(result, 0);
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
2012-07-09 05:09:50 +04:00
|
|
|
|
1999-04-22 08:27:47 +04:00
|
|
|
// Called by InitConstraints() to compute the containing block rectangle for
|
|
|
|
// the element. Handles the special logic for absolutely positioned elements
|
2015-06-04 13:43:02 +03:00
|
|
|
LogicalSize
|
|
|
|
nsHTMLReflowState::ComputeContainingBlockRectangle(
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState* aContainingBlockRS)
|
1999-04-22 08:27:47 +04:00
|
|
|
{
|
|
|
|
// Unless the element is absolutely positioned, the containing block is
|
|
|
|
// formed by the content edge of the nearest block-level ancestor
|
2015-06-04 13:43:02 +03:00
|
|
|
LogicalSize cbSize = aContainingBlockRS->ComputedSize();
|
|
|
|
|
|
|
|
WritingMode wm = aContainingBlockRS->GetWritingMode();
|
2011-05-12 08:04:30 +04:00
|
|
|
|
|
|
|
// mFrameType for abs-pos tables is NS_CSS_FRAME_TYPE_BLOCK, so we need to
|
|
|
|
// special case them here.
|
|
|
|
if (NS_FRAME_GET_TYPE(mFrameType) == NS_CSS_FRAME_TYPE_ABSOLUTE ||
|
|
|
|
(frame->GetType() == nsGkAtoms::tableFrame &&
|
2012-08-02 15:38:50 +04:00
|
|
|
frame->IsAbsolutelyPositioned() &&
|
2011-05-12 08:04:30 +04:00
|
|
|
(frame->GetParent()->GetStateBits() & NS_FRAME_OUT_OF_FLOW))) {
|
1999-04-22 08:27:47 +04:00
|
|
|
// See if the ancestor is block-level or inline-level
|
1999-07-20 07:41:03 +04:00
|
|
|
if (NS_FRAME_GET_TYPE(aContainingBlockRS->mFrameType) == NS_CSS_FRAME_TYPE_INLINE) {
|
2004-04-24 21:56:23 +04:00
|
|
|
// Base our size on the actual size of the frame. In cases when this is
|
|
|
|
// completely bogus (eg initial reflow), this code shouldn't even be
|
2011-04-30 03:02:33 +04:00
|
|
|
// called, since the code in nsInlineFrame::Reflow will pass in
|
2004-04-24 21:56:23 +04:00
|
|
|
// the containing block dimensions to our constructor.
|
|
|
|
// XXXbz we should be taking the in-flows into account too, but
|
|
|
|
// that's very hard.
|
2015-06-04 13:43:02 +03:00
|
|
|
|
|
|
|
LogicalMargin computedBorder =
|
|
|
|
aContainingBlockRS->ComputedLogicalBorderPadding() -
|
|
|
|
aContainingBlockRS->ComputedLogicalPadding();
|
|
|
|
cbSize.ISize(wm) = aContainingBlockRS->frame->ISize(wm) -
|
|
|
|
computedBorder.IStartEnd(wm);
|
|
|
|
NS_ASSERTION(cbSize.ISize(wm) >= 0,
|
2015-07-16 12:08:10 +03:00
|
|
|
"Negative containing block isize!");
|
2015-06-04 13:43:02 +03:00
|
|
|
cbSize.BSize(wm) = aContainingBlockRS->frame->BSize(wm) -
|
|
|
|
computedBorder.BStartEnd(wm);
|
|
|
|
NS_ASSERTION(cbSize.BSize(wm) >= 0,
|
2015-07-16 12:08:10 +03:00
|
|
|
"Negative containing block bsize!");
|
1999-04-22 08:27:47 +04:00
|
|
|
} else {
|
|
|
|
// If the ancestor is block-level, the containing block is formed by the
|
|
|
|
// padding edge of the ancestor
|
2015-06-04 13:43:02 +03:00
|
|
|
cbSize.ISize(wm) +=
|
|
|
|
aContainingBlockRS->ComputedLogicalPadding().IStartEnd(wm);
|
|
|
|
cbSize.BSize(wm) +=
|
|
|
|
aContainingBlockRS->ComputedLogicalPadding().BStartEnd(wm);
|
1999-04-22 08:27:47 +04:00
|
|
|
}
|
2000-01-30 21:40:48 +03:00
|
|
|
} else {
|
2003-10-18 09:09:42 +04:00
|
|
|
// an element in quirks mode gets a containing block based on looking for a
|
|
|
|
// parent with a non-auto height if the element has a percent height
|
2015-06-04 13:43:02 +03:00
|
|
|
// Note: We don't emulate this quirk for percents in calc() or in
|
|
|
|
// vertical writing modes.
|
|
|
|
if (!wm.IsVertical() &&
|
2015-07-07 16:20:09 +03:00
|
|
|
NS_AUTOHEIGHT == cbSize.BSize(wm)) {
|
2003-12-25 00:51:50 +03:00
|
|
|
if (eCompatibility_NavQuirks == aPresContext->CompatibilityMode() &&
|
2003-10-18 09:09:42 +04:00
|
|
|
mStylePosition->mHeight.GetUnit() == eStyleUnit_Percent) {
|
2015-07-07 16:20:09 +03:00
|
|
|
cbSize.BSize(wm) = CalcQuirkContainingBlockHeight(aContainingBlockRS);
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
|
|
|
}
|
1999-04-22 08:27:47 +04:00
|
|
|
}
|
2015-06-04 13:43:02 +03:00
|
|
|
|
|
|
|
return cbSize.ConvertTo(GetWritingMode(), wm);
|
1999-04-22 08:27:47 +04:00
|
|
|
}
|
|
|
|
|
2002-04-11 04:00:40 +04:00
|
|
|
static eNormalLineHeightControl GetNormalLineHeightCalcControl(void)
|
|
|
|
{
|
|
|
|
if (sNormalLineHeightControl == eUninitialized) {
|
2004-04-30 03:34:19 +04:00
|
|
|
// browser.display.normal_lineheight_calc_control is not user
|
2005-11-21 01:05:24 +03:00
|
|
|
// changeable, so no need to register callback for it.
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t val =
|
2011-05-25 10:32:00 +04:00
|
|
|
Preferences::GetInt("browser.display.normal_lineheight_calc_control",
|
|
|
|
eNoExternalLeading);
|
|
|
|
sNormalLineHeightControl = static_cast<eNormalLineHeightControl>(val);
|
2002-04-11 04:00:40 +04:00
|
|
|
}
|
|
|
|
return sNormalLineHeightControl;
|
2001-10-24 08:51:34 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static inline bool
|
2015-07-03 13:37:33 +03:00
|
|
|
IsSideCaption(nsIFrame* aFrame, const nsStyleDisplay* aStyleDisplay,
|
|
|
|
WritingMode aWM)
|
2008-02-27 05:02:50 +03:00
|
|
|
{
|
2015-07-03 13:37:33 +03:00
|
|
|
if (aStyleDisplay->mDisplay != NS_STYLE_DISPLAY_TABLE_CAPTION) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2015-07-03 13:37:33 +03:00
|
|
|
}
|
2015-09-16 00:02:30 +03:00
|
|
|
uint8_t captionSide = aFrame->StyleTableBorder()->mCaptionSide;
|
|
|
|
return captionSide == NS_STYLE_CAPTION_SIDE_LEFT ||
|
|
|
|
captionSide == NS_STYLE_CAPTION_SIDE_RIGHT;
|
2008-02-27 05:02:50 +03:00
|
|
|
}
|
|
|
|
|
2015-11-03 23:45:33 +03:00
|
|
|
// Flex/grid items resolve block-axis percentage margin & padding against the
|
|
|
|
// containing block block-size (also for abs/fixed-pos child frames).
|
2013-04-23 20:01:34 +04:00
|
|
|
// For everything else: the CSS21 spec requires that margin and padding
|
2014-12-11 14:16:22 +03:00
|
|
|
// percentage values are calculated with respect to the inline-size of the
|
|
|
|
// containing block, even for margin & padding in the block axis.
|
2015-06-04 13:43:02 +03:00
|
|
|
static LogicalSize
|
|
|
|
OffsetPercentBasis(const nsIFrame* aFrame,
|
|
|
|
WritingMode aWM,
|
|
|
|
const LogicalSize& aContainingBlockSize)
|
2013-04-23 20:01:34 +04:00
|
|
|
{
|
2015-06-04 13:43:02 +03:00
|
|
|
LogicalSize offsetPercentBasis = aContainingBlockSize;
|
2015-11-03 23:45:33 +03:00
|
|
|
if (MOZ_LIKELY(!aFrame->GetParent() ||
|
|
|
|
!aFrame->GetParent()->IsFlexOrGridContainer())) {
|
2015-06-04 13:43:02 +03:00
|
|
|
offsetPercentBasis.BSize(aWM) = offsetPercentBasis.ISize(aWM);
|
|
|
|
} else if (offsetPercentBasis.BSize(aWM) == NS_AUTOHEIGHT) {
|
|
|
|
offsetPercentBasis.BSize(aWM) = 0;
|
2013-04-23 20:01:34 +04:00
|
|
|
}
|
|
|
|
|
2015-06-04 13:43:02 +03:00
|
|
|
return offsetPercentBasis;
|
2013-04-23 20:01:34 +04:00
|
|
|
}
|
|
|
|
|
1999-02-23 22:33:06 +03:00
|
|
|
// XXX refactor this code to have methods for each set of properties
|
|
|
|
// we are computing: width,height,line-height; margin; offsets
|
|
|
|
|
1999-01-05 22:44:41 +03:00
|
|
|
void
|
2015-06-04 13:43:02 +03:00
|
|
|
nsHTMLReflowState::InitConstraints(nsPresContext* aPresContext,
|
|
|
|
const LogicalSize& aContainingBlockSize,
|
|
|
|
const nsMargin* aBorder,
|
|
|
|
const nsMargin* aPadding,
|
|
|
|
nsIAtom* aFrameType)
|
1999-01-05 22:44:41 +03:00
|
|
|
{
|
2015-06-04 13:43:02 +03:00
|
|
|
WritingMode wm = GetWritingMode();
|
2010-05-02 01:40:16 +04:00
|
|
|
DISPLAY_INIT_CONSTRAINTS(frame, this,
|
2015-06-04 13:43:02 +03:00
|
|
|
aContainingBlockSize.ISize(wm),
|
|
|
|
aContainingBlockSize.BSize(wm),
|
2010-05-02 01:40:16 +04:00
|
|
|
aBorder, aPadding);
|
|
|
|
|
2013-04-23 20:01:34 +04:00
|
|
|
// If this is a reflow root, then set the computed width and
|
1999-01-05 22:44:41 +03:00
|
|
|
// height equal to the available space
|
2013-09-10 00:29:06 +04:00
|
|
|
if (nullptr == parentReflowState || mFlags.mDummyParentReflowState) {
|
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 This doesn't mean what it used to!
|
2015-06-11 09:42:56 +03:00
|
|
|
InitOffsets(wm, OffsetPercentBasis(frame, wm, aContainingBlockSize),
|
2013-04-11 18:51:52 +04:00
|
|
|
aFrameType, aBorder, aPadding);
|
2007-01-17 08:19:35 +03:00
|
|
|
// Override mComputedMargin since reflow roots start from the
|
|
|
|
// frame's boundary, which is inside the margin.
|
2013-12-27 21:59:21 +04:00
|
|
|
ComputedPhysicalMargin().SizeTo(0, 0, 0, 0);
|
|
|
|
ComputedPhysicalOffsets().SizeTo(0, 0, 0, 0);
|
|
|
|
|
2015-06-05 10:47:09 +03:00
|
|
|
ComputedISize() =
|
|
|
|
AvailableISize() - ComputedLogicalBorderPadding().IStartEnd(wm);
|
|
|
|
if (ComputedISize() < 0) {
|
|
|
|
ComputedISize() = 0;
|
|
|
|
}
|
|
|
|
if (AvailableBSize() != NS_UNCONSTRAINEDSIZE) {
|
|
|
|
ComputedBSize() =
|
|
|
|
AvailableBSize() - ComputedLogicalBorderPadding().BStartEnd(wm);
|
|
|
|
if (ComputedBSize() < 0) {
|
|
|
|
ComputedBSize() = 0;
|
|
|
|
}
|
2007-02-26 00:29:17 +03:00
|
|
|
} else {
|
2015-06-05 10:47:09 +03:00
|
|
|
ComputedBSize() = NS_UNCONSTRAINEDSIZE;
|
2007-02-26 00:29:17 +03:00
|
|
|
}
|
2007-01-17 08:19:35 +03:00
|
|
|
|
2013-12-27 21:59:21 +04:00
|
|
|
ComputedMinWidth() = ComputedMinHeight() = 0;
|
|
|
|
ComputedMaxWidth() = ComputedMaxHeight() = NS_UNCONSTRAINEDSIZE;
|
1999-01-05 22:44:41 +03:00
|
|
|
} else {
|
|
|
|
// Get the containing block reflow state
|
2004-04-24 21:56:23 +04:00
|
|
|
const nsHTMLReflowState* cbrs = mCBReflowState;
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_ASSERTION(nullptr != cbrs, "no containing block");
|
1999-01-05 22:44:41 +03:00
|
|
|
|
1999-09-16 18:33:19 +04:00
|
|
|
// If we weren't given a containing block width and height, then
|
|
|
|
// compute one
|
2015-06-04 13:43:02 +03:00
|
|
|
LogicalSize cbSize = (aContainingBlockSize == LogicalSize(wm, -1, -1))
|
|
|
|
? ComputeContainingBlockRectangle(aPresContext, cbrs)
|
|
|
|
: aContainingBlockSize;
|
1999-04-22 08:27:47 +04:00
|
|
|
|
1999-07-28 07:51:37 +04:00
|
|
|
// See if the containing block height is based on the size of its
|
1999-02-14 07:43:44 +03:00
|
|
|
// content
|
2003-10-31 23:19:18 +03:00
|
|
|
nsIAtom* fType;
|
2015-06-04 13:43:02 +03:00
|
|
|
if (NS_AUTOHEIGHT == cbSize.BSize(wm)) {
|
2007-12-05 06:05:57 +03:00
|
|
|
// See if the containing block is a cell frame which needs
|
2001-11-07 01:57:17 +03:00
|
|
|
// to use the mComputedHeight of the cell instead of what the cell block passed in.
|
2007-12-05 06:05:57 +03:00
|
|
|
// XXX It seems like this could lead to bugs with min-height and friends
|
1999-02-14 07:43:44 +03:00
|
|
|
if (cbrs->parentReflowState) {
|
2007-12-05 06:05:57 +03:00
|
|
|
fType = cbrs->frame->GetType();
|
|
|
|
if (IS_TABLE_CELL(fType)) {
|
2015-06-04 13:43:02 +03:00
|
|
|
// use the cell's computed block size
|
|
|
|
cbSize.BSize(wm) = cbrs->ComputedSize(wm).BSize(wm);
|
2001-11-07 01:57:17 +03:00
|
|
|
}
|
1999-02-14 07:43:44 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-11 18:51:52 +04:00
|
|
|
// XXX Might need to also pass the CB height (not width) for page boxes,
|
|
|
|
// too, if we implement them.
|
2015-06-11 09:42:56 +03:00
|
|
|
|
|
|
|
// For calculating positioning offsets, margins, borders and
|
|
|
|
// padding, we use the writing mode of the containing block
|
|
|
|
WritingMode cbwm = cbrs->GetWritingMode();
|
|
|
|
InitOffsets(cbwm, OffsetPercentBasis(frame, cbwm,
|
|
|
|
cbSize.ConvertTo(cbwm, wm)),
|
2013-04-11 18:51:52 +04:00
|
|
|
aFrameType, aBorder, aPadding);
|
1999-03-06 01:24:27 +03:00
|
|
|
|
2015-06-11 09:42:56 +03:00
|
|
|
// For calculating the size of this box, we use its own writing mode
|
2015-06-04 13:43:02 +03:00
|
|
|
const nsStyleCoord &blockSize = mStylePosition->BSize(wm);
|
|
|
|
nsStyleUnit blockSizeUnit = blockSize.GetUnit();
|
1999-01-05 22:44:41 +03:00
|
|
|
|
2015-06-04 13:43:02 +03:00
|
|
|
// Check for a percentage based block size and a containing block
|
|
|
|
// block size that depends on the content block size
|
|
|
|
// XXX twiddling blockSizeUnit doesn't help anymore
|
2010-08-25 14:17:55 +04:00
|
|
|
// FIXME Shouldn't we fix that?
|
2015-06-04 13:43:02 +03:00
|
|
|
if (blockSize.HasPercent()) {
|
|
|
|
if (NS_AUTOHEIGHT == cbSize.BSize(wm)) {
|
|
|
|
// this if clause enables %-blockSize on replaced inline frames,
|
|
|
|
// such as images. See bug 54119. The else clause "blockSizeUnit = eStyleUnit_Auto;"
|
2000-10-10 01:19:36 +04:00
|
|
|
// used to be called exclusively.
|
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 (NS_FRAME_REPLACED(NS_CSS_FRAME_TYPE_INLINE) == mFrameType ||
|
|
|
|
NS_FRAME_REPLACED_CONTAINS_BLOCK(
|
|
|
|
NS_CSS_FRAME_TYPE_INLINE) == mFrameType) {
|
2000-10-10 01:19:36 +04:00
|
|
|
// Get the containing block reflow state
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_ASSERTION(nullptr != cbrs, "no containing block");
|
2000-10-10 01:19:36 +04:00
|
|
|
// in quirks mode, get the cb height using the special quirk method
|
2015-06-04 13:43:02 +03:00
|
|
|
if (!wm.IsVertical() &&
|
|
|
|
eCompatibility_NavQuirks == aPresContext->CompatibilityMode()) {
|
2002-09-04 08:00:41 +04:00
|
|
|
if (!IS_TABLE_CELL(fType)) {
|
2015-06-04 13:43:02 +03:00
|
|
|
cbSize.BSize(wm) = CalcQuirkContainingBlockHeight(cbrs);
|
|
|
|
if (cbSize.BSize(wm) == NS_AUTOHEIGHT) {
|
|
|
|
blockSizeUnit = eStyleUnit_Auto;
|
2003-10-24 11:31:50 +04:00
|
|
|
}
|
2002-09-04 08:00:41 +04:00
|
|
|
}
|
|
|
|
else {
|
2015-06-04 13:43:02 +03:00
|
|
|
blockSizeUnit = eStyleUnit_Auto;
|
2002-09-04 08:00:41 +04:00
|
|
|
}
|
2000-10-10 01:19:36 +04:00
|
|
|
}
|
2015-06-04 13:43:02 +03:00
|
|
|
// in standard mode, use the cb block size. if it's "auto",
|
|
|
|
// as will be the case by default in BODY, use auto block size
|
|
|
|
// as per CSS2 spec.
|
|
|
|
else
|
2000-10-10 01:19:36 +04:00
|
|
|
{
|
2015-06-04 13:43:02 +03:00
|
|
|
nscoord computedBSize = cbrs->ComputedSize(wm).BSize(wm);
|
|
|
|
if (NS_AUTOHEIGHT != computedBSize) {
|
|
|
|
cbSize.BSize(wm) = computedBSize;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
blockSizeUnit = eStyleUnit_Auto;
|
|
|
|
}
|
2000-10-10 01:19:36 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2015-06-04 13:43:02 +03:00
|
|
|
// default to interpreting the blockSize like 'auto'
|
|
|
|
blockSizeUnit = eStyleUnit_Auto;
|
2000-10-10 01:19:36 +04:00
|
|
|
}
|
1999-01-05 22:44:41 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-11 09:42:56 +03:00
|
|
|
// Compute our offsets if the element is relatively positioned. We
|
|
|
|
// need the correct containing block inline-size and block-size
|
|
|
|
// here, which is why we need to do it after all the quirks-n-such
|
|
|
|
// above. (If the element is sticky positioned, we need to wait
|
|
|
|
// until the scroll container knows its size, so we compute offsets
|
|
|
|
// from StickyScrollContainer::UpdatePositions.)
|
2013-09-06 17:35:16 +04:00
|
|
|
if (mStyleDisplay->IsRelativelyPositioned(frame) &&
|
|
|
|
NS_STYLE_POSITION_RELATIVE == mStyleDisplay->mPosition) {
|
2015-06-11 09:42:56 +03:00
|
|
|
ComputeRelativeOffsets(cbwm, frame, cbSize.ConvertTo(cbwm, wm),
|
|
|
|
ComputedPhysicalOffsets());
|
2004-01-06 02:48:57 +03:00
|
|
|
} else {
|
|
|
|
// Initialize offsets to 0
|
2013-12-27 21:59:21 +04:00
|
|
|
ComputedPhysicalOffsets().SizeTo(0, 0, 0, 0);
|
2004-01-06 02:48:57 +03:00
|
|
|
}
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
// Calculate the computed values for min and max properties. Note that
|
|
|
|
// this MUST come after we've computed our border and padding.
|
2015-06-04 13:43:02 +03:00
|
|
|
ComputeMinMaxValues(cbSize);
|
1999-03-11 04:23:10 +03:00
|
|
|
|
2015-07-16 12:08:10 +03:00
|
|
|
// Calculate the computed inlineSize and blockSize.
|
|
|
|
// This varies by frame type.
|
2000-04-16 08:07:02 +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 (NS_CSS_FRAME_TYPE_INTERNAL_TABLE == mFrameType) {
|
1999-03-11 18:13:17 +03:00
|
|
|
// Internal table elements. The rules vary depending on the type.
|
2015-07-16 12:08:10 +03:00
|
|
|
// Calculate the computed isize
|
2011-09-29 10:19:26 +04:00
|
|
|
bool rowOrRowGroup = false;
|
2015-06-04 13:43:02 +03:00
|
|
|
const nsStyleCoord &inlineSize = mStylePosition->ISize(wm);
|
|
|
|
nsStyleUnit inlineSizeUnit = inlineSize.GetUnit();
|
1999-03-05 07:24:20 +03:00
|
|
|
if ((NS_STYLE_DISPLAY_TABLE_ROW == mStyleDisplay->mDisplay) ||
|
|
|
|
(NS_STYLE_DISPLAY_TABLE_ROW_GROUP == mStyleDisplay->mDisplay)) {
|
2015-06-04 13:43:02 +03:00
|
|
|
// 'inlineSize' property doesn't apply to table rows and row groups
|
|
|
|
inlineSizeUnit = eStyleUnit_Auto;
|
2011-10-17 18:59:28 +04:00
|
|
|
rowOrRowGroup = true;
|
1999-01-05 22:44:41 +03:00
|
|
|
}
|
|
|
|
|
2012-11-21 20:19:37 +04:00
|
|
|
// calc() with percentages acts like auto on internal table elements
|
2015-06-04 13:43:02 +03:00
|
|
|
if (eStyleUnit_Auto == inlineSizeUnit ||
|
|
|
|
(inlineSize.IsCalcUnit() && inlineSize.CalcHasPercent())) {
|
|
|
|
ComputedISize() = AvailableISize();
|
1999-01-13 09:37:31 +03:00
|
|
|
|
2015-06-04 13:43:02 +03:00
|
|
|
if ((ComputedISize() != NS_UNCONSTRAINEDSIZE) && !rowOrRowGroup){
|
2000-10-06 03:49:25 +04:00
|
|
|
// Internal table elements don't have margins. Only tables and
|
|
|
|
// cells have border and padding
|
2015-06-04 13:43:02 +03:00
|
|
|
ComputedISize() -= ComputedLogicalBorderPadding().IStartEnd(wm);
|
|
|
|
if (ComputedISize() < 0)
|
|
|
|
ComputedISize() = 0;
|
1999-01-13 09:37:31 +03:00
|
|
|
}
|
2015-07-16 12:08:10 +03:00
|
|
|
NS_ASSERTION(ComputedISize() >= 0, "Bogus computed isize");
|
2015-06-04 13:43:02 +03:00
|
|
|
|
1999-01-05 22:44:41 +03:00
|
|
|
} else {
|
2015-06-04 13:43:02 +03:00
|
|
|
NS_ASSERTION(inlineSizeUnit == inlineSize.GetUnit(),
|
2015-07-16 12:08:10 +03:00
|
|
|
"unexpected inline size unit change");
|
2015-06-04 13:43:02 +03:00
|
|
|
ComputedISize() = ComputeISizeValue(cbSize.ISize(wm),
|
|
|
|
mStylePosition->mBoxSizing,
|
|
|
|
inlineSize);
|
1999-01-05 22:44:41 +03:00
|
|
|
}
|
|
|
|
|
2015-06-04 13:43:02 +03:00
|
|
|
// Calculate the computed block size
|
1999-03-05 07:24:20 +03:00
|
|
|
if ((NS_STYLE_DISPLAY_TABLE_COLUMN == mStyleDisplay->mDisplay) ||
|
|
|
|
(NS_STYLE_DISPLAY_TABLE_COLUMN_GROUP == mStyleDisplay->mDisplay)) {
|
2015-06-04 13:43:02 +03:00
|
|
|
// 'blockSize' property doesn't apply to table columns and column groups
|
|
|
|
blockSizeUnit = eStyleUnit_Auto;
|
1999-01-05 22:44:41 +03:00
|
|
|
}
|
2012-11-21 20:19:30 +04:00
|
|
|
// calc() with percentages acts like 'auto' on internal table elements
|
2015-06-04 13:43:02 +03:00
|
|
|
if (eStyleUnit_Auto == blockSizeUnit ||
|
|
|
|
(blockSize.IsCalcUnit() && blockSize.CalcHasPercent())) {
|
|
|
|
ComputedBSize() = NS_AUTOHEIGHT;
|
1999-01-05 22:44:41 +03:00
|
|
|
} else {
|
2015-06-04 13:43:02 +03:00
|
|
|
NS_ASSERTION(blockSizeUnit == blockSize.GetUnit(),
|
|
|
|
"unexpected block size unit change");
|
|
|
|
ComputedBSize() = ComputeBSizeValue(cbSize.BSize(wm),
|
|
|
|
mStylePosition->mBoxSizing,
|
|
|
|
blockSize);
|
1999-01-05 22:44:41 +03:00
|
|
|
}
|
1999-03-11 04:23:10 +03:00
|
|
|
|
|
|
|
// Doesn't apply to table elements
|
2013-12-27 21:59:21 +04:00
|
|
|
ComputedMinWidth() = ComputedMinHeight() = 0;
|
|
|
|
ComputedMaxWidth() = ComputedMaxHeight() = NS_UNCONSTRAINEDSIZE;
|
1999-03-11 04:23:10 +03:00
|
|
|
|
1999-07-20 07:41:03 +04:00
|
|
|
} else if (NS_FRAME_GET_TYPE(mFrameType) == NS_CSS_FRAME_TYPE_ABSOLUTE) {
|
1999-05-11 02:59:03 +04:00
|
|
|
// XXX not sure if this belongs here or somewhere else - cwk
|
2015-06-05 10:47:09 +03:00
|
|
|
InitAbsoluteConstraints(aPresContext, cbrs, cbSize.ConvertTo(cbrs->GetWritingMode(), wm), aFrameType);
|
1999-03-05 07:24:20 +03:00
|
|
|
} else {
|
2012-05-21 09:18:27 +04:00
|
|
|
AutoMaybeDisableFontInflation an(frame);
|
2012-01-25 05:21:29 +04:00
|
|
|
|
2012-04-13 19:52:13 +04:00
|
|
|
bool isBlock = NS_CSS_FRAME_TYPE_BLOCK == NS_FRAME_GET_TYPE(mFrameType);
|
2014-11-11 14:02:41 +03:00
|
|
|
typedef nsIFrame::ComputeSizeFlags ComputeSizeFlags;
|
|
|
|
ComputeSizeFlags computeSizeFlags =
|
|
|
|
isBlock ? ComputeSizeFlags::eDefault : ComputeSizeFlags::eShrinkWrap;
|
2012-04-13 19:52:13 +04:00
|
|
|
|
|
|
|
// Make sure legend frames with display:block and width:auto still
|
|
|
|
// shrink-wrap.
|
2015-04-07 21:56:58 +03:00
|
|
|
// Also shrink-wrap blocks that are orthogonal to their container.
|
2012-04-13 19:52:13 +04:00
|
|
|
if (isBlock &&
|
|
|
|
((aFrameType == nsGkAtoms::legendFrame &&
|
2013-02-16 09:38:33 +04:00
|
|
|
frame->StyleContext()->GetPseudo() != nsCSSAnonBoxes::scrolledContent) ||
|
2012-04-13 19:52:13 +04:00
|
|
|
(aFrameType == nsGkAtoms::scrollFrame &&
|
2015-04-07 21:56:58 +03:00
|
|
|
frame->GetContentInsertionFrame()->GetType() == nsGkAtoms::legendFrame) ||
|
|
|
|
(mCBReflowState &&
|
|
|
|
mCBReflowState->GetWritingMode().IsOrthogonalTo(mWritingMode)))) {
|
2014-11-11 14:02:41 +03:00
|
|
|
computeSizeFlags =
|
|
|
|
ComputeSizeFlags(computeSizeFlags | ComputeSizeFlags::eShrinkWrap);
|
2012-03-16 22:01:05 +04:00
|
|
|
}
|
|
|
|
|
2015-11-03 19:52:40 +03:00
|
|
|
nsIFrame* parent = frame->GetParent();
|
|
|
|
nsIAtom* parentFrameType = parent ? parent->GetType() : nullptr;
|
|
|
|
if (parentFrameType == nsGkAtoms::flexContainerFrame) {
|
2014-11-11 14:02:41 +03:00
|
|
|
computeSizeFlags =
|
|
|
|
ComputeSizeFlags(computeSizeFlags | ComputeSizeFlags::eShrinkWrap);
|
2012-09-30 10:38:46 +04:00
|
|
|
|
|
|
|
// If we're inside of a flex container that needs to measure our
|
|
|
|
// auto height, pass that information along to ComputeSize().
|
|
|
|
if (mFlags.mIsFlexContainerMeasuringHeight) {
|
2014-11-11 14:02:41 +03:00
|
|
|
computeSizeFlags =
|
|
|
|
ComputeSizeFlags(computeSizeFlags | ComputeSizeFlags::eUseAutoHeight);
|
2012-09-30 10:38:46 +04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
MOZ_ASSERT(!mFlags.mIsFlexContainerMeasuringHeight,
|
|
|
|
"We're not in a flex container, so the flag "
|
|
|
|
"'mIsFlexContainerMeasuringHeight' shouldn't be set");
|
2012-09-30 10:38:46 +04:00
|
|
|
}
|
|
|
|
|
2014-10-25 15:09:25 +04:00
|
|
|
if (cbSize.ISize(wm) == NS_UNCONSTRAINEDSIZE) {
|
|
|
|
// For orthogonal flows, where we found a parent orthogonal-limit
|
|
|
|
// for AvailableISize() in Init(), we'll use the same here as well.
|
|
|
|
cbSize.ISize(wm) = AvailableISize();
|
|
|
|
}
|
|
|
|
|
2014-08-24 18:34:44 +04:00
|
|
|
LogicalSize size =
|
2015-06-04 13:43:02 +03:00
|
|
|
frame->ComputeSize(rendContext, wm, cbSize, AvailableISize(),
|
2014-08-24 18:34:44 +04:00
|
|
|
ComputedLogicalMargin().Size(wm),
|
|
|
|
ComputedLogicalBorderPadding().Size(wm) -
|
|
|
|
ComputedLogicalPadding().Size(wm),
|
|
|
|
ComputedLogicalPadding().Size(wm),
|
2012-03-16 22:01:05 +04:00
|
|
|
computeSizeFlags);
|
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
|
|
|
|
2014-08-24 18:34:44 +04:00
|
|
|
ComputedISize() = size.ISize(wm);
|
|
|
|
ComputedBSize() = size.BSize(wm);
|
|
|
|
NS_ASSERTION(ComputedISize() >= 0, "Bogus inline-size");
|
|
|
|
NS_ASSERTION(ComputedBSize() == NS_UNCONSTRAINEDSIZE ||
|
|
|
|
ComputedBSize() >= 0, "Bogus block-size");
|
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
|
|
|
|
2015-11-03 19:52:40 +03:00
|
|
|
// Exclude inline tables, side captions, flex and grid items from block
|
|
|
|
// margin calculations.
|
2012-09-30 10:38:46 +04:00
|
|
|
if (isBlock &&
|
2015-07-03 13:37:33 +03:00
|
|
|
!IsSideCaption(frame, mStyleDisplay, cbwm) &&
|
2013-05-22 07:44:52 +04:00
|
|
|
mStyleDisplay->mDisplay != NS_STYLE_DISPLAY_INLINE_TABLE &&
|
2015-11-03 19:52:40 +03:00
|
|
|
parentFrameType != nsGkAtoms::flexContainerFrame &&
|
|
|
|
parentFrameType != nsGkAtoms::gridContainerFrame) {
|
2014-11-26 13:24:16 +03:00
|
|
|
CalculateBlockSideMargins(aFrameType);
|
2013-05-22 07:44:52 +04:00
|
|
|
}
|
1999-03-05 07:24:20 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-10 00:14:05 +03:00
|
|
|
static void
|
|
|
|
UpdateProp(FrameProperties& aProps,
|
|
|
|
const FramePropertyDescriptor* aProperty,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aNeeded,
|
2010-11-10 00:14:05 +03:00
|
|
|
nsMargin& aNewValue)
|
|
|
|
{
|
|
|
|
if (aNeeded) {
|
|
|
|
nsMargin* propValue = static_cast<nsMargin*>(aProps.Get(aProperty));
|
|
|
|
if (propValue) {
|
|
|
|
*propValue = aNewValue;
|
|
|
|
} else {
|
|
|
|
aProps.Set(aProperty, new nsMargin(aNewValue));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
aProps.Delete(aProperty);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-03-05 07:24:20 +03:00
|
|
|
void
|
2015-06-11 09:42:56 +03:00
|
|
|
nsCSSOffsetState::InitOffsets(WritingMode aWM,
|
|
|
|
const LogicalSize& aPercentBasis,
|
2011-06-11 03:02:14 +04:00
|
|
|
nsIAtom* aFrameType,
|
2006-12-12 18:18:40 +03:00
|
|
|
const nsMargin *aBorder,
|
|
|
|
const nsMargin *aPadding)
|
1999-03-05 07:24:20 +03:00
|
|
|
{
|
2015-06-04 13:43:02 +03:00
|
|
|
DISPLAY_INIT_OFFSETS(frame, this, aPercentBasis, aBorder, aPadding);
|
2010-05-02 01:40:16 +04:00
|
|
|
|
2010-11-10 00:14:05 +03:00
|
|
|
// Since we are in reflow, we don't need to store these properties anymore
|
|
|
|
// unless they are dependent on width, in which case we store the new value.
|
|
|
|
nsPresContext *presContext = frame->PresContext();
|
|
|
|
FrameProperties props(presContext->PropertyTable(), frame);
|
|
|
|
props.Delete(nsIFrame::UsedBorderProperty());
|
|
|
|
|
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
|
|
|
// Compute margins from the specified margin style information. These
|
|
|
|
// become the default computed values, and may be adjusted below
|
|
|
|
// XXX fix to provide 0,0 for the top&bottom margins for
|
|
|
|
// inline-non-replaced elements
|
2015-06-11 09:42:56 +03:00
|
|
|
bool needMarginProp = ComputeMargin(aWM, aPercentBasis);
|
2010-11-10 00:14:05 +03:00
|
|
|
// XXX We need to include 'auto' horizontal margins in this too!
|
|
|
|
// ... but if we did that, we'd need to fix nsFrame::GetUsedMargin
|
|
|
|
// to use it even when the margins are all zero (since sometimes
|
|
|
|
// they get treated as auto)
|
|
|
|
::UpdateProp(props, nsIFrame::UsedMarginProperty(), needMarginProp,
|
2013-12-27 21:59:21 +04:00
|
|
|
ComputedPhysicalMargin());
|
2010-11-10 00:14:05 +03:00
|
|
|
|
2007-01-18 01:31:07 +03:00
|
|
|
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStyleDisplay *disp = frame->StyleDisplay();
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isThemed = frame->IsThemed(disp);
|
|
|
|
bool needPaddingProp;
|
2009-01-15 06:27:09 +03:00
|
|
|
nsIntMargin widget;
|
2007-01-18 01:31:07 +03:00
|
|
|
if (isThemed &&
|
|
|
|
presContext->GetTheme()->GetWidgetPadding(presContext->DeviceContext(),
|
|
|
|
frame, disp->mAppearance,
|
2009-01-15 06:27:09 +03:00
|
|
|
&widget)) {
|
2013-12-27 21:59:21 +04:00
|
|
|
ComputedPhysicalPadding().top = presContext->DevPixelsToAppUnits(widget.top);
|
|
|
|
ComputedPhysicalPadding().right = presContext->DevPixelsToAppUnits(widget.right);
|
|
|
|
ComputedPhysicalPadding().bottom = presContext->DevPixelsToAppUnits(widget.bottom);
|
|
|
|
ComputedPhysicalPadding().left = presContext->DevPixelsToAppUnits(widget.left);
|
2011-10-17 18:59:28 +04:00
|
|
|
needPaddingProp = false;
|
2007-01-18 01:31:07 +03:00
|
|
|
}
|
2013-03-07 13:01:52 +04:00
|
|
|
else if (frame->IsSVGText()) {
|
2013-12-27 21:59:21 +04:00
|
|
|
ComputedPhysicalPadding().SizeTo(0, 0, 0, 0);
|
2012-08-23 05:24:19 +04:00
|
|
|
needPaddingProp = false;
|
2012-08-02 15:38:48 +04:00
|
|
|
}
|
2007-01-18 01:31:07 +03:00
|
|
|
else if (aPadding) { // padding is an input arg
|
2013-12-27 21:59:21 +04:00
|
|
|
ComputedPhysicalPadding() = *aPadding;
|
2014-01-15 13:47:36 +04:00
|
|
|
needPaddingProp = frame->StylePadding()->IsWidthDependent() ||
|
|
|
|
(frame->GetStateBits() & NS_FRAME_REFLOW_ROOT);
|
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
|
|
|
}
|
|
|
|
else {
|
2015-06-11 09:42:56 +03:00
|
|
|
needPaddingProp = ComputePadding(aWM, aPercentBasis, aFrameType);
|
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-01-18 01:31:07 +03:00
|
|
|
|
|
|
|
if (isThemed) {
|
2009-01-15 06:27:09 +03:00
|
|
|
nsIntMargin widget;
|
2007-01-18 01:31:07 +03:00
|
|
|
presContext->GetTheme()->GetWidgetBorder(presContext->DeviceContext(),
|
|
|
|
frame, disp->mAppearance,
|
2009-01-15 06:27:09 +03:00
|
|
|
&widget);
|
2013-12-27 21:59:21 +04:00
|
|
|
ComputedPhysicalBorderPadding().top =
|
2009-01-15 06:27:09 +03:00
|
|
|
presContext->DevPixelsToAppUnits(widget.top);
|
2013-12-27 21:59:21 +04:00
|
|
|
ComputedPhysicalBorderPadding().right =
|
2009-01-15 06:27:09 +03:00
|
|
|
presContext->DevPixelsToAppUnits(widget.right);
|
2013-12-27 21:59:21 +04:00
|
|
|
ComputedPhysicalBorderPadding().bottom =
|
2009-01-15 06:27:09 +03:00
|
|
|
presContext->DevPixelsToAppUnits(widget.bottom);
|
2013-12-27 21:59:21 +04:00
|
|
|
ComputedPhysicalBorderPadding().left =
|
2009-01-15 06:27:09 +03:00
|
|
|
presContext->DevPixelsToAppUnits(widget.left);
|
2007-01-18 01:31:07 +03:00
|
|
|
}
|
2013-03-07 13:01:52 +04:00
|
|
|
else if (frame->IsSVGText()) {
|
2013-12-27 21:59:21 +04:00
|
|
|
ComputedPhysicalBorderPadding().SizeTo(0, 0, 0, 0);
|
2012-08-02 15:38:48 +04:00
|
|
|
}
|
2007-01-18 01:31:07 +03:00
|
|
|
else if (aBorder) { // border is an input arg
|
2013-12-27 21:59:21 +04:00
|
|
|
ComputedPhysicalBorderPadding() = *aBorder;
|
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
|
|
|
}
|
|
|
|
else {
|
2013-12-27 21:59:21 +04:00
|
|
|
ComputedPhysicalBorderPadding() = frame->StyleBorder()->GetComputedBorder();
|
1999-03-05 07:24:20 +03:00
|
|
|
}
|
2013-12-27 21:59:21 +04:00
|
|
|
ComputedPhysicalBorderPadding() += ComputedPhysicalPadding();
|
1999-05-04 00:53:27 +04:00
|
|
|
|
2011-06-11 03:02:14 +04:00
|
|
|
if (aFrameType == nsGkAtoms::tableFrame) {
|
2007-07-08 11:08:04 +04:00
|
|
|
nsTableFrame *tableFrame = static_cast<nsTableFrame*>(frame);
|
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 (tableFrame->IsBorderCollapse()) {
|
|
|
|
// border-collapsed tables don't use any of their padding, and
|
|
|
|
// only part of their border. We need to do this here before we
|
|
|
|
// try to do anything like handling 'auto' widths,
|
2014-02-06 23:32:05 +04:00
|
|
|
// 'box-sizing', or 'auto' margins.
|
2013-12-27 21:59:21 +04:00
|
|
|
ComputedPhysicalPadding().SizeTo(0,0,0,0);
|
2015-06-10 04:13:49 +03:00
|
|
|
SetComputedLogicalBorderPadding(
|
|
|
|
tableFrame->GetIncludedOuterBCBorder(mWritingMode));
|
1999-03-05 07:24:20 +03:00
|
|
|
}
|
Bug 659828 - Part 1: Apply table margins to the outer table frame instead of the inner table frame (also fixes bug 87277); r=dbaron
Outer table frames act as CSS2.1 table wrapper boxes. We used to lay them out
without taking their margins into the account, which meant that their width was
always equal to the available width. This breaks horizontal positioning of
absolutely positioned kids of a table frame.
The main purpose of this patch is to apply the margins of tables to their outer
frame, instead of the inner frame. This means that the inner table frame will
always have a zero margin, which means that a lot of the stuff which used to
rely on the fact that table margins are applied to the inner frame need to
change.
In particular, in order to get the computed margins of a table, we used to query
the inner table frame, and this patch corrects that. Also, when shrink wrapping
tables, we used to not take the margins of the inner table frame into account,
which is fixed by this patch too. nsBlockReflowState::
ComputeReplacedBlockOffsetsForFloats also needed to be changed to read the
margin values from the outer frame too.
Also, as part of this patch, we start to respect the CSS2.1 margin model for
captions on all sides. This means that in particular, the top/bottom margins on
the top-outside and bottom-outside captions will not be collapsed with the
top/bottom margins of the table, and that the margins of the caption element
contribute to the width and height of the outer table frame. The
427129-table-caption reftest has been modified to match this new behavior.
Another side effect of this bug is fixing bug 87277, and the reftests for that
bug are marked as passing in this patch.
2011-06-01 03:02:56 +04:00
|
|
|
|
|
|
|
// The margin is inherited to the outer table frame via
|
|
|
|
// the ::-moz-table-outer rule in ua.css.
|
2013-12-27 21:59:21 +04:00
|
|
|
ComputedPhysicalMargin().SizeTo(0, 0, 0, 0);
|
2011-06-11 03:02:14 +04:00
|
|
|
} else if (aFrameType == nsGkAtoms::scrollbarFrame) {
|
2009-07-30 07:43:22 +04:00
|
|
|
// scrollbars may have had their width or height smashed to zero
|
|
|
|
// by the associated scrollframe, in which case we must not report
|
2009-08-18 02:38:12 +04:00
|
|
|
// any padding or border.
|
2009-07-30 07:43:22 +04:00
|
|
|
nsSize size(frame->GetSize());
|
2009-08-18 02:38:12 +04:00
|
|
|
if (size.width == 0 || size.height == 0) {
|
2013-12-27 21:59:21 +04:00
|
|
|
ComputedPhysicalPadding().SizeTo(0,0,0,0);
|
|
|
|
ComputedPhysicalBorderPadding().SizeTo(0,0,0,0);
|
2009-07-30 07:43:22 +04:00
|
|
|
}
|
1999-03-05 07:24:20 +03:00
|
|
|
}
|
2010-11-10 00:14:05 +03:00
|
|
|
::UpdateProp(props, nsIFrame::UsedPaddingProperty(), needPaddingProp,
|
2013-12-27 21:59:21 +04:00
|
|
|
ComputedPhysicalPadding());
|
1999-03-05 07:24:20 +03:00
|
|
|
}
|
1999-01-05 22:44:41 +03:00
|
|
|
|
1999-05-04 00:53:27 +04:00
|
|
|
// This code enforces section 10.3.3 of the CSS2 spec for this formula:
|
|
|
|
//
|
|
|
|
// 'margin-left' + 'border-left-width' + 'padding-left' + 'width' +
|
|
|
|
// 'padding-right' + 'border-right-width' + 'margin-right'
|
2015-07-17 19:04:24 +03:00
|
|
|
// = width of containing block
|
1999-03-05 07:24:20 +03:00
|
|
|
//
|
1999-05-04 00:53:27 +04:00
|
|
|
// Note: the width unit is not auto when this is called
|
1999-03-05 07:24:20 +03:00
|
|
|
void
|
2014-11-26 13:24:16 +03:00
|
|
|
nsHTMLReflowState::CalculateBlockSideMargins(nsIAtom* aFrameType)
|
1999-05-04 00:53:27 +04:00
|
|
|
{
|
2014-11-26 13:24:16 +03:00
|
|
|
// Calculations here are done in the containing block's writing mode,
|
|
|
|
// which is where margins will eventually be applied: we're calculating
|
|
|
|
// margins that will be used by the container in its inline direction,
|
|
|
|
// which in the case of an orthogonal contained block will correspond to
|
|
|
|
// the block direction of this reflow state. So in the orthogonal-flow
|
|
|
|
// case, "CalculateBlock*Side*Margins" will actually end up adjusting
|
|
|
|
// the BStart/BEnd margins; those are the "sides" of the block from its
|
|
|
|
// container's point of view.
|
|
|
|
WritingMode cbWM =
|
|
|
|
mCBReflowState ? mCBReflowState->GetWritingMode(): GetWritingMode();
|
|
|
|
|
|
|
|
nscoord availISizeCBWM = AvailableSize(cbWM).ISize(cbWM);
|
2014-11-28 17:53:57 +03:00
|
|
|
nscoord computedISizeCBWM = ComputedSize(cbWM).ISize(cbWM);
|
|
|
|
if (computedISizeCBWM == NS_UNCONSTRAINEDSIZE) {
|
|
|
|
// For orthogonal flows, where we found a parent orthogonal-limit
|
|
|
|
// for AvailableISize() in Init(), we'll use the same here as well.
|
|
|
|
computedISizeCBWM = availISizeCBWM;
|
|
|
|
}
|
2014-11-26 13:24:16 +03:00
|
|
|
|
2015-06-16 02:36:11 +03:00
|
|
|
LAYOUT_WARN_IF_FALSE(NS_UNCONSTRAINEDSIZE != computedISizeCBWM &&
|
2015-06-16 02:36:12 +03:00
|
|
|
NS_UNCONSTRAINEDSIZE != availISizeCBWM,
|
|
|
|
"have unconstrained inline-size; this should only "
|
|
|
|
"result from very large sizes, not attempts at "
|
|
|
|
"intrinsic inline-size calculation");
|
1999-05-04 00:53:27 +04:00
|
|
|
|
2014-11-26 13:24:16 +03:00
|
|
|
LogicalMargin margin =
|
|
|
|
ComputedLogicalMargin().ConvertTo(cbWM, mWritingMode);
|
|
|
|
LogicalMargin borderPadding =
|
|
|
|
ComputedLogicalBorderPadding().ConvertTo(cbWM, mWritingMode);
|
|
|
|
nscoord sum = margin.IStartEnd(cbWM) +
|
|
|
|
borderPadding.IStartEnd(cbWM) + computedISizeCBWM;
|
|
|
|
if (sum == availISizeCBWM) {
|
1999-05-04 00:53:27 +04:00
|
|
|
// The sum is already correct
|
|
|
|
return;
|
2014-10-24 15:24:39 +04:00
|
|
|
}
|
1999-05-04 00:53:27 +04:00
|
|
|
|
2014-10-24 15:24:39 +04:00
|
|
|
// Determine the start and end margin values. The isize value
|
1999-05-04 00:53:27 +04:00
|
|
|
// remains constant while we do this.
|
2004-02-04 08:18:37 +03:00
|
|
|
|
1999-05-04 00:53:27 +04:00
|
|
|
// Calculate how much space is available for margins
|
2014-11-26 13:24:16 +03:00
|
|
|
nscoord availMarginSpace = availISizeCBWM - sum;
|
2004-02-04 08:18:37 +03:00
|
|
|
|
|
|
|
// If the available margin space is negative, then don't follow the
|
|
|
|
// usual overconstraint rules.
|
|
|
|
if (availMarginSpace < 0) {
|
2014-11-26 13:24:16 +03:00
|
|
|
margin.IEnd(cbWM) += availMarginSpace;
|
|
|
|
SetComputedLogicalMargin(margin.ConvertTo(mWritingMode, cbWM));
|
2004-02-04 08:18:37 +03:00
|
|
|
return;
|
1999-07-05 22:45:12 +04:00
|
|
|
}
|
2004-02-04 08:18:37 +03:00
|
|
|
|
|
|
|
// The css2 spec clearly defines how block elements should behave
|
|
|
|
// in section 10.3.3.
|
2014-10-24 15:24:39 +04:00
|
|
|
const nsStyleSides& styleSides = mStyleMargin->mMargin;
|
2015-05-11 13:37:46 +03:00
|
|
|
bool isAutoStartMargin = eStyleUnit_Auto == styleSides.GetIStartUnit(cbWM);
|
|
|
|
bool isAutoEndMargin = eStyleUnit_Auto == styleSides.GetIEndUnit(cbWM);
|
2014-10-24 15:24:39 +04:00
|
|
|
if (!isAutoStartMargin && !isAutoEndMargin) {
|
2004-02-04 08:18:37 +03:00
|
|
|
// Neither margin is 'auto' so we're over constrained. Use the
|
|
|
|
// 'direction' property of the parent to tell which margin to
|
|
|
|
// ignore
|
|
|
|
// First check if there is an HTML alignment that we should honor
|
|
|
|
const nsHTMLReflowState* prs = parentReflowState;
|
2011-06-11 03:02:14 +04:00
|
|
|
if (aFrameType == nsGkAtoms::tableFrame) {
|
2006-12-26 20:47:52 +03:00
|
|
|
NS_ASSERTION(prs->frame->GetType() == nsGkAtoms::tableOuterFrame,
|
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
|
|
|
"table not inside outer table");
|
|
|
|
// Center the table within the outer table based on the alignment
|
|
|
|
// of the outer table's parent.
|
|
|
|
prs = prs->parentReflowState;
|
|
|
|
}
|
2004-02-04 08:18:37 +03:00
|
|
|
if (prs &&
|
2005-06-16 03:45:06 +04:00
|
|
|
(prs->mStyleText->mTextAlign == NS_STYLE_TEXT_ALIGN_MOZ_LEFT ||
|
|
|
|
prs->mStyleText->mTextAlign == NS_STYLE_TEXT_ALIGN_MOZ_CENTER ||
|
2004-02-04 08:18:37 +03:00
|
|
|
prs->mStyleText->mTextAlign == NS_STYLE_TEXT_ALIGN_MOZ_RIGHT)) {
|
2014-10-24 15:24:39 +04:00
|
|
|
if (prs->mWritingMode.IsBidiLTR()) {
|
|
|
|
isAutoStartMargin =
|
|
|
|
prs->mStyleText->mTextAlign != NS_STYLE_TEXT_ALIGN_MOZ_LEFT;
|
|
|
|
isAutoEndMargin =
|
|
|
|
prs->mStyleText->mTextAlign != NS_STYLE_TEXT_ALIGN_MOZ_RIGHT;
|
|
|
|
} else {
|
|
|
|
isAutoStartMargin =
|
|
|
|
prs->mStyleText->mTextAlign != NS_STYLE_TEXT_ALIGN_MOZ_RIGHT;
|
|
|
|
isAutoEndMargin =
|
|
|
|
prs->mStyleText->mTextAlign != NS_STYLE_TEXT_ALIGN_MOZ_LEFT;
|
|
|
|
}
|
2004-02-04 08:18:37 +03:00
|
|
|
}
|
|
|
|
// Otherwise apply the CSS rules, and ignore one margin by forcing
|
|
|
|
// it to 'auto', depending on 'direction'.
|
|
|
|
else {
|
2014-10-24 15:24:39 +04:00
|
|
|
isAutoEndMargin = true;
|
1999-05-04 00:53:27 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-09-21 04:15:16 +04:00
|
|
|
// Logic which is common to blocks and tables
|
2008-08-30 20:25:38 +04:00
|
|
|
// The computed margins need not be zero because the 'auto' could come from
|
|
|
|
// overconstraint or from HTML alignment so values need to be accumulated
|
|
|
|
|
2014-10-24 15:24:39 +04:00
|
|
|
if (isAutoStartMargin) {
|
|
|
|
if (isAutoEndMargin) {
|
2008-08-30 20:25:38 +04:00
|
|
|
// Both margins are 'auto' so the computed addition should be equal
|
2014-10-24 15:24:39 +04:00
|
|
|
nscoord forStart = availMarginSpace / 2;
|
2014-11-26 13:24:16 +03:00
|
|
|
margin.IStart(cbWM) += forStart;
|
|
|
|
margin.IEnd(cbWM) += availMarginSpace - forStart;
|
1999-09-21 04:15:16 +04:00
|
|
|
} else {
|
2014-11-26 13:24:16 +03:00
|
|
|
margin.IStart(cbWM) += availMarginSpace;
|
1999-01-05 22:44:41 +03:00
|
|
|
}
|
2014-10-24 15:24:39 +04:00
|
|
|
} else if (isAutoEndMargin) {
|
2014-11-26 13:24:16 +03:00
|
|
|
margin.IEnd(cbWM) += availMarginSpace;
|
1999-01-05 22:44:41 +03:00
|
|
|
}
|
2014-11-26 13:24:16 +03:00
|
|
|
SetComputedLogicalMargin(margin.ConvertTo(mWritingMode, cbWM));
|
1999-01-05 22:44:41 +03:00
|
|
|
}
|
|
|
|
|
2015-07-17 19:04:24 +03:00
|
|
|
#define NORMAL_LINE_HEIGHT_FACTOR 1.2f // in term of emHeight
|
2002-04-11 04:00:40 +04:00
|
|
|
// For "normal" we use the font's normal line height (em height + leading).
|
|
|
|
// If both internal leading and external leading specified by font itself
|
2015-07-17 19:04:24 +03:00
|
|
|
// are zeros, we should compensate this by creating extra (external) leading
|
|
|
|
// in eCompensateLeading mode. This is necessary because without this
|
|
|
|
// compensation, normal line height might looks too tight.
|
2002-04-11 04:00:40 +04:00
|
|
|
|
2015-07-17 19:04:24 +03:00
|
|
|
// For risk management, we use preference to control the behavior, and
|
2002-04-11 04:00:40 +04:00
|
|
|
// eNoExternalLeading is the old behavior.
|
|
|
|
static nscoord
|
2011-04-08 05:05:49 +04:00
|
|
|
GetNormalLineHeight(nsFontMetrics* aFontMetrics)
|
2002-04-11 04:00:40 +04:00
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_PRECONDITION(nullptr != aFontMetrics, "no font metrics");
|
2002-04-11 04:00:40 +04:00
|
|
|
|
|
|
|
nscoord normalLineHeight;
|
|
|
|
|
2011-04-08 08:18:43 +04:00
|
|
|
nscoord externalLeading = aFontMetrics->ExternalLeading();
|
|
|
|
nscoord internalLeading = aFontMetrics->InternalLeading();
|
|
|
|
nscoord emHeight = aFontMetrics->EmHeight();
|
2002-04-11 04:00:40 +04:00
|
|
|
switch (GetNormalLineHeightCalcControl()) {
|
|
|
|
case eIncludeExternalLeading:
|
|
|
|
normalLineHeight = emHeight+ internalLeading + externalLeading;
|
|
|
|
break;
|
|
|
|
case eCompensateLeading:
|
|
|
|
if (!internalLeading && !externalLeading)
|
|
|
|
normalLineHeight = NSToCoordRound(emHeight * NORMAL_LINE_HEIGHT_FACTOR);
|
|
|
|
else
|
|
|
|
normalLineHeight = emHeight+ internalLeading + externalLeading;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
//case eNoExternalLeading:
|
|
|
|
normalLineHeight = emHeight + internalLeading;
|
|
|
|
}
|
|
|
|
return normalLineHeight;
|
|
|
|
}
|
|
|
|
|
2011-11-24 06:48:23 +04:00
|
|
|
static inline nscoord
|
2009-05-19 02:13:12 +04:00
|
|
|
ComputeLineHeight(nsStyleContext* aStyleContext,
|
2014-11-04 17:45:00 +03:00
|
|
|
nscoord aBlockBSize,
|
2012-01-25 05:21:29 +04:00
|
|
|
float aFontSizeInflation)
|
1999-09-10 01:03:27 +04:00
|
|
|
{
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStyleCoord& lhCoord = aStyleContext->StyleText()->mLineHeight;
|
2008-07-18 03:37:12 +04:00
|
|
|
|
2012-01-25 05:21:29 +04:00
|
|
|
if (lhCoord.GetUnit() == eStyleUnit_Coord) {
|
|
|
|
nscoord result = lhCoord.GetCoordValue();
|
|
|
|
if (aFontSizeInflation != 1.0f) {
|
|
|
|
result = NSToCoordRound(result * aFontSizeInflation);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
2008-07-18 03:37:12 +04:00
|
|
|
|
|
|
|
if (lhCoord.GetUnit() == eStyleUnit_Factor)
|
2015-07-17 19:04:24 +03:00
|
|
|
// For factor units the computed value of the line-height property
|
2008-07-18 03:37:12 +04:00
|
|
|
// is found by multiplying the factor by the font's computed size
|
|
|
|
// (adjusted for min-size prefs and text zoom).
|
2012-01-25 05:21:29 +04:00
|
|
|
return NSToCoordRound(lhCoord.GetFactorValue() * aFontSizeInflation *
|
2013-02-17 01:51:02 +04:00
|
|
|
aStyleContext->StyleFont()->mFont.size);
|
2008-07-18 03:37:12 +04:00
|
|
|
|
2009-05-19 02:13:12 +04:00
|
|
|
NS_ASSERTION(lhCoord.GetUnit() == eStyleUnit_Normal ||
|
|
|
|
lhCoord.GetUnit() == eStyleUnit_Enumerated,
|
|
|
|
"bad line-height unit");
|
2015-07-17 19:04:24 +03:00
|
|
|
|
2009-05-19 02:13:12 +04:00
|
|
|
if (lhCoord.GetUnit() == eStyleUnit_Enumerated) {
|
|
|
|
NS_ASSERTION(lhCoord.GetIntValue() == NS_STYLE_LINE_HEIGHT_BLOCK_HEIGHT,
|
|
|
|
"bad line-height value");
|
2014-11-04 17:45:00 +03:00
|
|
|
if (aBlockBSize != NS_AUTOHEIGHT) {
|
|
|
|
return aBlockBSize;
|
2011-11-24 06:48:23 +04:00
|
|
|
}
|
2009-05-19 02:13:12 +04:00
|
|
|
}
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsFontMetrics> fm;
|
2008-07-18 03:37:12 +04:00
|
|
|
nsLayoutUtils::GetFontMetricsForStyleContext(aStyleContext,
|
2012-01-25 05:21:29 +04:00
|
|
|
getter_AddRefs(fm),
|
|
|
|
aFontSizeInflation);
|
2008-07-18 03:37:12 +04:00
|
|
|
return GetNormalLineHeight(fm);
|
1999-09-10 01:03:27 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nscoord
|
2009-05-19 02:13:12 +04:00
|
|
|
nsHTMLReflowState::CalcLineHeight() const
|
|
|
|
{
|
2014-11-04 17:45:00 +03:00
|
|
|
nscoord blockBSize =
|
|
|
|
nsLayoutUtils::IsNonWrapperBlock(frame) ? ComputedBSize() :
|
|
|
|
(mCBReflowState ? mCBReflowState->ComputedBSize() : NS_AUTOHEIGHT);
|
2009-05-19 02:13:12 +04:00
|
|
|
|
2014-11-04 17:45:00 +03:00
|
|
|
return CalcLineHeight(frame->GetContent(), frame->StyleContext(), blockBSize,
|
2012-05-21 09:18:28 +04:00
|
|
|
nsLayoutUtils::FontSizeInflationFor(frame));
|
2009-05-19 02:13:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ nscoord
|
2014-03-13 07:33:21 +04:00
|
|
|
nsHTMLReflowState::CalcLineHeight(nsIContent* aContent,
|
|
|
|
nsStyleContext* aStyleContext,
|
2014-11-04 17:45:00 +03:00
|
|
|
nscoord aBlockBSize,
|
2011-11-24 06:48:23 +04:00
|
|
|
float aFontSizeInflation)
|
2007-05-05 09:30:10 +04:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(aStyleContext, "Must have a style context");
|
2011-11-24 06:48:23 +04:00
|
|
|
|
|
|
|
nscoord lineHeight =
|
2014-11-04 17:45:00 +03:00
|
|
|
ComputeLineHeight(aStyleContext, aBlockBSize, aFontSizeInflation);
|
2007-05-05 09:30:10 +04:00
|
|
|
|
|
|
|
NS_ASSERTION(lineHeight >= 0, "ComputeLineHeight screwed up");
|
|
|
|
|
2014-03-15 04:00:12 +04:00
|
|
|
HTMLInputElement* input = HTMLInputElement::FromContentOrNull(aContent);
|
|
|
|
if (input && input->IsSingleLineTextControl()) {
|
|
|
|
// For Web-compatibility, single-line text input elements cannot
|
|
|
|
// have a line-height smaller than one.
|
2014-03-13 07:33:21 +04:00
|
|
|
nscoord lineHeightOne =
|
|
|
|
aFontSizeInflation * aStyleContext->StyleFont()->mFont.size;
|
|
|
|
if (lineHeight < lineHeightOne) {
|
|
|
|
lineHeight = lineHeightOne;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-05 09:30:10 +04:00
|
|
|
return lineHeight;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2015-06-11 09:42:56 +03:00
|
|
|
nsCSSOffsetState::ComputeMargin(WritingMode aWM,
|
|
|
|
const LogicalSize& aPercentBasis)
|
1999-03-06 01:24:27 +03:00
|
|
|
{
|
2012-08-02 15:38:48 +04:00
|
|
|
// SVG text frames have no margin.
|
2013-03-07 13:01:52 +04:00
|
|
|
if (frame->IsSVGText()) {
|
2012-08-02 15:38:48 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
1999-03-06 01:24:27 +03:00
|
|
|
// If style style can provide us the margin directly, then use it.
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStyleMargin *styleMargin = frame->StyleMargin();
|
2015-06-04 13:43:02 +03:00
|
|
|
|
2013-12-27 21:59:21 +04:00
|
|
|
bool isCBDependent = !styleMargin->GetMargin(ComputedPhysicalMargin());
|
2013-04-11 18:51:52 +04:00
|
|
|
if (isCBDependent) {
|
2015-06-11 09:42:56 +03:00
|
|
|
// We have to compute the value. Note that this calculation is
|
|
|
|
// performed according to the writing mode of the containing block
|
|
|
|
// (http://dev.w3.org/csswg/css-writing-modes-3/#orthogonal-flows)
|
|
|
|
LogicalMargin m(aWM);
|
|
|
|
m.IStart(aWM) = nsLayoutUtils::
|
|
|
|
ComputeCBDependentValue(aPercentBasis.ISize(aWM),
|
|
|
|
styleMargin->mMargin.GetIStart(aWM));
|
|
|
|
m.IEnd(aWM) = nsLayoutUtils::
|
|
|
|
ComputeCBDependentValue(aPercentBasis.ISize(aWM),
|
|
|
|
styleMargin->mMargin.GetIEnd(aWM));
|
|
|
|
|
|
|
|
m.BStart(aWM) = nsLayoutUtils::
|
|
|
|
ComputeCBDependentValue(aPercentBasis.BSize(aWM),
|
|
|
|
styleMargin->mMargin.GetBStart(aWM));
|
|
|
|
m.BEnd(aWM) = nsLayoutUtils::
|
|
|
|
ComputeCBDependentValue(aPercentBasis.BSize(aWM),
|
|
|
|
styleMargin->mMargin.GetBEnd(aWM));
|
|
|
|
|
|
|
|
SetComputedLogicalMargin(aWM, m);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ... but font-size-inflation-based margin adjustment uses the
|
|
|
|
// frame's writing mode
|
2012-07-10 19:46:07 +04:00
|
|
|
nscoord marginAdjustment = FontSizeInflationListMarginAdjustment(frame);
|
|
|
|
|
|
|
|
if (marginAdjustment > 0) {
|
2014-12-11 14:16:22 +03:00
|
|
|
LogicalMargin m = ComputedLogicalMargin();
|
|
|
|
m.IStart(mWritingMode) += marginAdjustment;
|
|
|
|
SetComputedLogicalMargin(m);
|
2012-07-10 19:46:07 +04:00
|
|
|
}
|
|
|
|
|
2013-04-11 18:51:52 +04:00
|
|
|
return isCBDependent;
|
1999-03-06 01:24:27 +03:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2015-06-11 09:42:56 +03:00
|
|
|
nsCSSOffsetState::ComputePadding(WritingMode aWM,
|
|
|
|
const LogicalSize& aPercentBasis,
|
2013-04-11 18:51:52 +04:00
|
|
|
nsIAtom* aFrameType)
|
1999-03-06 03:36:59 +03:00
|
|
|
{
|
|
|
|
// If style can provide us the padding directly, then use it.
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStylePadding *stylePadding = frame->StylePadding();
|
2013-12-27 21:59:21 +04:00
|
|
|
bool isCBDependent = !stylePadding->GetPadding(ComputedPhysicalPadding());
|
2010-11-10 00:14:05 +03:00
|
|
|
// a table row/col group, row/col doesn't have padding
|
|
|
|
// XXXldb Neither do border-collapse tables.
|
2011-06-11 03:02:14 +04:00
|
|
|
if (nsGkAtoms::tableRowGroupFrame == aFrameType ||
|
|
|
|
nsGkAtoms::tableColGroupFrame == aFrameType ||
|
|
|
|
nsGkAtoms::tableRowFrame == aFrameType ||
|
|
|
|
nsGkAtoms::tableColFrame == aFrameType) {
|
2013-12-27 21:59:21 +04:00
|
|
|
ComputedPhysicalPadding().SizeTo(0,0,0,0);
|
2010-11-10 00:14:05 +03:00
|
|
|
}
|
2013-04-11 18:51:52 +04:00
|
|
|
else if (isCBDependent) {
|
2015-06-11 09:42:56 +03:00
|
|
|
// We have to compute the value. This calculation is performed
|
|
|
|
// according to the writing mode of the containing block
|
|
|
|
// (http://dev.w3.org/csswg/css-writing-modes-3/#orthogonal-flows)
|
2010-09-09 19:21:46 +04:00
|
|
|
// clamp negative calc() results to 0
|
2015-06-11 09:42:56 +03:00
|
|
|
LogicalMargin p(aWM);
|
|
|
|
p.IStart(aWM) = std::max(0, nsLayoutUtils::
|
|
|
|
ComputeCBDependentValue(aPercentBasis.ISize(aWM),
|
|
|
|
stylePadding->mPadding.GetIStart(aWM)));
|
|
|
|
p.IEnd(aWM) = std::max(0, nsLayoutUtils::
|
|
|
|
ComputeCBDependentValue(aPercentBasis.ISize(aWM),
|
|
|
|
stylePadding->mPadding.GetIEnd(aWM)));
|
|
|
|
|
|
|
|
p.BStart(aWM) = std::max(0, nsLayoutUtils::
|
|
|
|
ComputeCBDependentValue(aPercentBasis.BSize(aWM),
|
|
|
|
stylePadding->mPadding.GetBStart(aWM)));
|
|
|
|
p.BEnd(aWM) = std::max(0, nsLayoutUtils::
|
|
|
|
ComputeCBDependentValue(aPercentBasis.BSize(aWM),
|
|
|
|
stylePadding->mPadding.GetBEnd(aWM)));
|
|
|
|
|
|
|
|
SetComputedLogicalPadding(aWM, p);
|
2000-12-22 02:05:15 +03:00
|
|
|
}
|
2013-04-11 18:51:52 +04:00
|
|
|
return isCBDependent;
|
1999-03-06 03:36:59 +03:00
|
|
|
}
|
|
|
|
|
1999-03-11 04:23:10 +03:00
|
|
|
void
|
2015-06-04 13:43:02 +03:00
|
|
|
nsHTMLReflowState::ComputeMinMaxValues(const LogicalSize&aCBSize)
|
1999-03-11 04:23:10 +03:00
|
|
|
{
|
2015-06-04 13:43:02 +03:00
|
|
|
WritingMode wm = GetWritingMode();
|
|
|
|
|
|
|
|
const nsStyleCoord& minISize = mStylePosition->MinISize(wm);
|
|
|
|
const nsStyleCoord& maxISize = mStylePosition->MaxISize(wm);
|
|
|
|
const nsStyleCoord& minBSize = mStylePosition->MinBSize(wm);
|
|
|
|
const nsStyleCoord& maxBSize = mStylePosition->MaxBSize(wm);
|
|
|
|
|
2014-07-22 19:24:37 +04:00
|
|
|
// NOTE: min-width:auto resolves to 0, except on a flex item. (But
|
|
|
|
// even there, it's supposed to be ignored (i.e. treated as 0) until
|
|
|
|
// the flex container explicitly resolves & considers it.)
|
2015-06-04 13:43:02 +03:00
|
|
|
if (eStyleUnit_Auto == minISize.GetUnit()) {
|
|
|
|
ComputedMinISize() = 0;
|
2014-07-22 19:24:34 +04:00
|
|
|
} else {
|
2015-06-04 13:43:02 +03:00
|
|
|
ComputedMinISize() = ComputeISizeValue(aCBSize.ISize(wm),
|
|
|
|
mStylePosition->mBoxSizing,
|
|
|
|
minISize);
|
2014-07-22 19:24:34 +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
|
|
|
|
2015-06-04 13:43:02 +03:00
|
|
|
if (eStyleUnit_None == maxISize.GetUnit()) {
|
1999-03-11 18:13:17 +03:00
|
|
|
// Specified value of 'none'
|
2015-06-04 13:43:02 +03:00
|
|
|
ComputedMaxISize() = NS_UNCONSTRAINEDSIZE; // no limit
|
1999-03-11 04:23:10 +03:00
|
|
|
} else {
|
2015-06-04 13:43:02 +03:00
|
|
|
ComputedMaxISize() = ComputeISizeValue(aCBSize.ISize(wm),
|
|
|
|
mStylePosition->mBoxSizing,
|
|
|
|
maxISize);
|
1999-03-11 04:23:10 +03:00
|
|
|
}
|
1999-03-11 18:13:17 +03:00
|
|
|
|
|
|
|
// If the computed value of 'min-width' is greater than the value of
|
|
|
|
// 'max-width', 'max-width' is set to the value of 'min-width'
|
2015-06-04 13:43:02 +03:00
|
|
|
if (ComputedMinISize() > ComputedMaxISize()) {
|
|
|
|
ComputedMaxISize() = ComputedMinISize();
|
1999-03-11 18:13:17 +03:00
|
|
|
}
|
|
|
|
|
2003-11-24 22:46:25 +03:00
|
|
|
// Check for percentage based values and a containing block height that
|
|
|
|
// depends on the content height. Treat them like 'auto'
|
2012-11-21 20:19:30 +04:00
|
|
|
// Likewise, check for calc() with percentages on internal table elements;
|
|
|
|
// that's treated as 'auto' too.
|
2012-09-30 10:38:46 +04:00
|
|
|
// Likewise, if we're a child of a flex container who's measuring our
|
|
|
|
// intrinsic height, then we want to disregard our min-height.
|
|
|
|
|
2014-07-22 19:24:37 +04:00
|
|
|
// NOTE: min-height:auto resolves to 0, except on a flex item. (But
|
|
|
|
// even there, it's supposed to be ignored (i.e. treated as 0) until
|
|
|
|
// the flex container explicitly resolves & considers it.)
|
2015-06-04 13:43:02 +03:00
|
|
|
if (eStyleUnit_Auto == minBSize.GetUnit() ||
|
|
|
|
(NS_AUTOHEIGHT == aCBSize.BSize(wm) &&
|
|
|
|
minBSize.HasPercent()) ||
|
2010-08-25 14:17:55 +04:00
|
|
|
(mFrameType == NS_CSS_FRAME_TYPE_INTERNAL_TABLE &&
|
2015-06-04 13:43:02 +03:00
|
|
|
minBSize.IsCalcUnit() && minBSize.CalcHasPercent()) ||
|
2012-09-30 10:38:46 +04:00
|
|
|
mFlags.mIsFlexContainerMeasuringHeight) {
|
2015-06-04 13:43:02 +03:00
|
|
|
ComputedMinBSize() = 0;
|
1999-03-11 04:23:10 +03:00
|
|
|
} else {
|
2015-06-04 13:43:02 +03:00
|
|
|
ComputedMinBSize() = ComputeBSizeValue(aCBSize.BSize(wm),
|
|
|
|
mStylePosition->mBoxSizing,
|
|
|
|
minBSize);
|
1999-03-11 04:23:10 +03:00
|
|
|
}
|
2015-06-04 13:43:02 +03:00
|
|
|
nsStyleUnit maxBSizeUnit = maxBSize.GetUnit();
|
|
|
|
if (eStyleUnit_None == maxBSizeUnit) {
|
1999-03-11 18:13:17 +03:00
|
|
|
// Specified value of 'none'
|
2015-06-04 13:43:02 +03:00
|
|
|
ComputedMaxBSize() = NS_UNCONSTRAINEDSIZE; // no limit
|
1999-03-11 04:23:10 +03:00
|
|
|
} else {
|
1999-03-11 18:13:17 +03:00
|
|
|
// Check for percentage based values and a containing block height that
|
2012-09-30 10:38:46 +04:00
|
|
|
// depends on the content height. Treat them like 'none'
|
2012-11-21 20:19:30 +04:00
|
|
|
// Likewise, check for calc() with percentages on internal table elements;
|
|
|
|
// that's treated as 'auto' too.
|
2012-09-30 10:38:46 +04:00
|
|
|
// Likewise, if we're a child of a flex container who's measuring our
|
|
|
|
// intrinsic height, then we want to disregard our max-height.
|
2015-06-04 13:43:02 +03:00
|
|
|
if ((NS_AUTOHEIGHT == aCBSize.BSize(wm) &&
|
|
|
|
maxBSize.HasPercent()) ||
|
2010-08-25 14:17:55 +04:00
|
|
|
(mFrameType == NS_CSS_FRAME_TYPE_INTERNAL_TABLE &&
|
2015-06-04 13:43:02 +03:00
|
|
|
maxBSize.IsCalcUnit() && maxBSize.CalcHasPercent()) ||
|
2012-09-30 10:38:46 +04:00
|
|
|
mFlags.mIsFlexContainerMeasuringHeight) {
|
2015-06-04 13:43:02 +03:00
|
|
|
ComputedMaxBSize() = NS_UNCONSTRAINEDSIZE;
|
1999-03-11 18:13:17 +03:00
|
|
|
} else {
|
2015-06-04 13:43:02 +03:00
|
|
|
ComputedMaxBSize() = ComputeBSizeValue(aCBSize.BSize(wm),
|
|
|
|
mStylePosition->mBoxSizing,
|
|
|
|
maxBSize);
|
1999-03-11 18:13:17 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the computed value of 'min-height' is greater than the value of
|
|
|
|
// 'max-height', 'max-height' is set to the value of 'min-height'
|
2015-06-04 13:43:02 +03:00
|
|
|
if (ComputedMinBSize() > ComputedMaxBSize()) {
|
|
|
|
ComputedMaxBSize() = ComputedMinBSize();
|
1999-03-11 04:23:10 +03:00
|
|
|
}
|
|
|
|
}
|
2007-03-11 23:34:15 +03:00
|
|
|
|
|
|
|
void
|
|
|
|
nsHTMLReflowState::SetTruncated(const nsHTMLReflowMetrics& aMetrics,
|
|
|
|
nsReflowStatus* aStatus) const
|
|
|
|
{
|
2013-12-27 21:59:21 +04:00
|
|
|
if (AvailableHeight() != NS_UNCONSTRAINEDSIZE &&
|
2013-12-27 21:59:52 +04:00
|
|
|
AvailableHeight() < aMetrics.Height() &&
|
2007-03-11 23:34:15 +03:00
|
|
|
!mFlags.mIsTopOfPage) {
|
|
|
|
*aStatus |= NS_FRAME_TRUNCATED;
|
|
|
|
} else {
|
|
|
|
*aStatus &= ~NS_FRAME_TRUNCATED;
|
|
|
|
}
|
|
|
|
}
|
2013-10-02 01:01:49 +04:00
|
|
|
|
|
|
|
bool
|
|
|
|
nsHTMLReflowState::IsFloating() const
|
|
|
|
{
|
|
|
|
return mStyleDisplay->IsFloating(frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t
|
|
|
|
nsHTMLReflowState::GetDisplay() const
|
|
|
|
{
|
|
|
|
return mStyleDisplay->GetDisplay(frame);
|
2015-07-17 19:04:24 +03:00
|
|
|
}
|