mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 13:43:44 +00:00
import changes from tenfourfox:
bug1416529, bug1425520, bug1437450, bug1437087 - M1252374 reduce mallocs in displayList generation (c3b712f86) - closes #493: fix height for flexbox case M1030952 M1180107 (2a28a03ed)
This commit is contained in:
@@ -6764,9 +6764,17 @@ nsDocShell::ForceRefreshURI(nsIURI* aURI, int32_t aDelay, bool aMetaRefresh, nsI
|
||||
*/
|
||||
loadInfo->SetReferrer(mCurrentURI);
|
||||
|
||||
/* Don't ever "guess" on which owner to use to avoid picking
|
||||
* the current owner.
|
||||
*/
|
||||
// Set the triggering pricipal to aPrincipal if available, or current
|
||||
// document's principal otherwise.
|
||||
nsCOMPtr<nsIPrincipal> principal = aPrincipal;
|
||||
if (!principal) {
|
||||
nsCOMPtr<nsIDocument> doc = GetDocument();
|
||||
if (MOZ_UNLIKELY(!doc)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
principal = doc->NodePrincipal();
|
||||
}
|
||||
loadInfo->SetOwner(principal); // equivalent for SetTriggeringPrincipal
|
||||
loadInfo->SetOwnerIsExplicit(true);
|
||||
|
||||
/* Check if this META refresh causes a redirection
|
||||
@@ -6794,13 +6802,6 @@ nsDocShell::ForceRefreshURI(nsIURI* aURI, int32_t aDelay, bool aMetaRefresh, nsI
|
||||
loadInfo->SetLoadType(nsIDocShellLoadInfo::loadRefresh);
|
||||
}
|
||||
|
||||
// If the principal is null, the refresh will have a triggeringPrincipal
|
||||
// derived from the referrer URI, or will be set to the system principal
|
||||
// if there is no refererrer. See LoadURI()
|
||||
if (aPrincipal) {
|
||||
loadInfo->SetOwner(aPrincipal); // as called prior to bug 1286472
|
||||
}
|
||||
|
||||
/*
|
||||
* LoadURI(...) will cancel all refresh timers... This causes the
|
||||
* Timer and its refreshData instance to be released...
|
||||
|
||||
@@ -19,9 +19,8 @@ interface nsIRefreshURI : nsISupports {
|
||||
*
|
||||
* @param aUri The uri to refresh.
|
||||
* @param aPrincipal The triggeringPrincipal for the refresh load
|
||||
* May be null, in which case a principal will be built based on the
|
||||
* referrer URI of the previous docshell load, or will use the system
|
||||
* principal when there is no referrer.
|
||||
* May be null, in which case the principal of current document will be
|
||||
* applied.
|
||||
* @param aMillis The number of milliseconds to wait.
|
||||
* @param aRepeat Flag to indicate if the uri is to be
|
||||
* repeatedly refreshed every aMillis milliseconds.
|
||||
@@ -37,9 +36,8 @@ interface nsIRefreshURI : nsISupports {
|
||||
*
|
||||
* @param aURI The URI to refresh.
|
||||
* @param aPrincipal The triggeringPrincipal for the refresh load
|
||||
* May be null, in which case a principal will be built based on the
|
||||
* referrer URI of the previous docshell load, or will use the system
|
||||
* principal when there is no referrer.
|
||||
* May be null, in which case the principal of current document will be
|
||||
* applied.
|
||||
* @param aMillis The number of milliseconds by which this refresh would
|
||||
* be delayed if it were not being forced.
|
||||
* @param aMetaRefresh Flag to indicate if this is a meta refresh.
|
||||
@@ -70,9 +68,8 @@ interface nsIRefreshURI : nsISupports {
|
||||
*
|
||||
* @param aBaseURI base URI to resolve refresh uri with.
|
||||
* @param aPrincipal The triggeringPrincipal for the refresh load
|
||||
* May be null, in which case a principal will be built based on the
|
||||
* referrer URI of the previous docshell load, or will use the system
|
||||
* principal when there is no referrer.
|
||||
* May be null, in which case the principal of current document will be
|
||||
* applied.
|
||||
* @param aHeader The meta refresh header string.
|
||||
*/
|
||||
void setupRefreshURIFromHeader(in nsIURI aBaseURI,
|
||||
|
||||
@@ -496,7 +496,7 @@ nsDocumentEncoder::SerializeToStringRecursive(nsINode* aNode,
|
||||
}
|
||||
|
||||
if (!aDontSerializeRoot) {
|
||||
rv = SerializeNodeEnd(node, aStr);
|
||||
rv = SerializeNodeEnd(maybeFixedNode, aStr);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
|
||||
@@ -168,7 +168,14 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsEditor)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mEditorObservers)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDocStateListeners)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mEventTarget)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mEventListener)
|
||||
|
||||
if (tmp->mEventListener) {
|
||||
nsEditorEventListener* listener =
|
||||
reinterpret_cast<nsEditorEventListener*>(tmp->mEventListener.get());
|
||||
listener->Disconnect();
|
||||
tmp->mEventListener = nullptr;
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsEditor)
|
||||
|
||||
@@ -1408,6 +1408,12 @@ jit::ApplyTypeInformation(MIRGenerator* mir, MIRGraph& graph)
|
||||
bool
|
||||
jit::MakeMRegExpHoistable(MIRGraph& graph)
|
||||
{
|
||||
// If we are compiling try blocks, regular expressions may be observable
|
||||
// from catch blocks (which Ion does not compile). For now just disable the
|
||||
// pass in this case.
|
||||
if (graph.hasTryBlock())
|
||||
return true;
|
||||
|
||||
for (ReversePostorderIterator block(graph.rpoBegin()); block != graph.rpoEnd(); block++) {
|
||||
for (MDefinitionIterator iter(*block); iter; iter++) {
|
||||
if (!iter->isRegExp())
|
||||
|
||||
@@ -123,6 +123,16 @@ public:
|
||||
*/
|
||||
void DeleteAll();
|
||||
|
||||
/**
|
||||
* Check if a property exists (added for TenFourFox issue 493).
|
||||
*/
|
||||
bool Has(const nsIFrame* aFrame, const FramePropertyDescriptor* aProperty)
|
||||
{
|
||||
bool foundResult = false;
|
||||
(void)Get(aFrame, aProperty, &foundResult);
|
||||
return foundResult;
|
||||
}
|
||||
|
||||
size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
||||
|
||||
protected:
|
||||
@@ -239,6 +249,13 @@ public:
|
||||
{
|
||||
mTable->Delete(mFrame, aProperty);
|
||||
}
|
||||
// TenFourFox issue 493
|
||||
bool Has(const FramePropertyDescriptor* aProperty)
|
||||
{
|
||||
bool foundResult;
|
||||
(void)mTable->Get(mFrame, aProperty, &foundResult);
|
||||
return foundResult;
|
||||
}
|
||||
|
||||
private:
|
||||
FramePropertyTable* mTable;
|
||||
|
||||
@@ -593,7 +593,7 @@ nsDisplayListBuilder::nsDisplayListBuilder(nsIFrame* aReferenceFrame,
|
||||
mIsBuildingForPopup(nsLayoutUtils::IsPopup(aReferenceFrame))
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsDisplayListBuilder);
|
||||
PL_InitArenaPool(&mPool, "displayListArena", 1024,
|
||||
PL_InitArenaPool(&mPool, "displayListArena", 4096,
|
||||
std::max(NS_ALIGNMENT_OF(void*),NS_ALIGNMENT_OF(double))-1);
|
||||
RecomputeCurrentAnimatedGeometryRoot();
|
||||
|
||||
|
||||
@@ -3565,7 +3565,7 @@ ComputeMissingDimension(const nsSize& aDefaultObjectSize,
|
||||
return NSCoordSaturatingNonnegativeMultiply(knownDimensionSize, ratio);
|
||||
}
|
||||
|
||||
// 2. "Otherwise, if the missing dimension is present in the object’s
|
||||
// 2. "Otherwise, if the missing dimension is present in the object?™s
|
||||
// intrinsic dimensions, [...]"
|
||||
// NOTE: *Skipping* this case, because we already know it's not true -- we're
|
||||
// in this function because the missing dimension is *not* present in
|
||||
@@ -4725,33 +4725,58 @@ nsLayoutUtils::ComputeSizeWithIntrinsicDimensions(WritingMode aWM,
|
||||
bool isFlexItem = aFrame->IsFlexItem();
|
||||
bool isInlineFlexItem = false;
|
||||
|
||||
Maybe<nsStyleCoord> imposedMainSizeStyleCoord;
|
||||
|
||||
// If this is a flex item, and we're measuring its cross size after flexing
|
||||
// to resolve its main size, then we need to use the resolved main size
|
||||
// that the container provides to us *instead of* the main-size coordinate
|
||||
// from our style struct. (Otherwise, we'll be using an irrelevant value in
|
||||
// the aspect-ratio calculations below.)
|
||||
if (isFlexItem) {
|
||||
// Flex items use their "flex-basis" property in place of their main-size
|
||||
// property (e.g. "width") for sizing purposes, *unless* they have
|
||||
// "flex-basis:auto", in which case they use their main-size property after
|
||||
// all.
|
||||
uint32_t flexDirection =
|
||||
aFrame->GetParent()->StylePosition()->mFlexDirection;
|
||||
isInlineFlexItem =
|
||||
flexDirection == NS_STYLE_FLEX_DIRECTION_ROW ||
|
||||
flexDirection == NS_STYLE_FLEX_DIRECTION_ROW_REVERSE;
|
||||
|
||||
// NOTE: The logic here should match the similar chunk for determining
|
||||
// inlineStyleCoord and blockStyleCoord in nsFrame::ComputeSize().
|
||||
const nsStyleCoord* flexBasis = &(stylePos->mFlexBasis);
|
||||
if (flexBasis->GetUnit() != eStyleUnit_Auto) {
|
||||
// If FlexItemMainSizeOverride frame-property is set, then that means the
|
||||
// flex container is imposing a main-size on this flex item for it to use
|
||||
// as its size in the container's main axis.
|
||||
FrameProperties props = aFrame->Properties();
|
||||
bool didImposeMainSize;
|
||||
nscoord imposedMainSize =
|
||||
reinterpret_cast<nscoord>(props.Get(nsIFrame::FlexItemMainSizeOverride(), &didImposeMainSize));
|
||||
if (didImposeMainSize) {
|
||||
imposedMainSizeStyleCoord.emplace(imposedMainSize,
|
||||
nsStyleCoord::CoordConstructor);
|
||||
if (isInlineFlexItem) {
|
||||
inlineStyleCoord = flexBasis;
|
||||
inlineStyleCoord = imposedMainSizeStyleCoord.ptr();
|
||||
} else {
|
||||
// One caveat for vertical flex items: We don't support enumerated
|
||||
// values (e.g. "max-content") for height properties yet. So, if our
|
||||
// computed flex-basis is an enumerated value, we'll just behave as if
|
||||
// it were "auto", which means "use the main-size property after all"
|
||||
// (which is "height", in this case).
|
||||
// NOTE: Once we support intrinsic sizing keywords for "height",
|
||||
// we should remove this check.
|
||||
if (flexBasis->GetUnit() != eStyleUnit_Enumerated) {
|
||||
blockStyleCoord = flexBasis;
|
||||
blockStyleCoord = imposedMainSizeStyleCoord.ptr();
|
||||
}
|
||||
|
||||
} else {
|
||||
// Flex items use their "flex-basis" property in place of their main-size
|
||||
// property (e.g. "width") for sizing purposes, *unless* they have
|
||||
// "flex-basis:auto", in which case they use their main-size property
|
||||
// after all.
|
||||
// NOTE: The logic here should match the similar chunk for determining
|
||||
// inlineStyleCoord and blockStyleCoord in nsFrame::ComputeSize().
|
||||
const nsStyleCoord* flexBasis = &(stylePos->mFlexBasis);
|
||||
if (flexBasis->GetUnit() != eStyleUnit_Auto) {
|
||||
if (isInlineFlexItem) {
|
||||
inlineStyleCoord = flexBasis;
|
||||
} else {
|
||||
// One caveat for vertical flex items: We don't support enumerated
|
||||
// values (e.g. "max-content") for height properties yet. So, if our
|
||||
// computed flex-basis is an enumerated value, we'll just behave as if
|
||||
// it were "auto", which means "use the main-size property after all"
|
||||
// (which is "height", in this case).
|
||||
// NOTE: Once we support intrinsic sizing keywords for "height",
|
||||
// we should remove this check.
|
||||
if (flexBasis->GetUnit() != eStyleUnit_Enumerated) {
|
||||
blockStyleCoord = flexBasis;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -401,6 +401,9 @@ public:
|
||||
return mFlexShrink * mFlexBaseSize;
|
||||
}
|
||||
|
||||
const nsSize& IntrinsicRatio() const { return mIntrinsicRatio; }
|
||||
bool HasIntrinsicRatio() const { return mIntrinsicRatio != nsSize(); }
|
||||
|
||||
// Getters for margin:
|
||||
// ===================
|
||||
const nsMargin& GetMargin() const { return mMargin; }
|
||||
@@ -581,6 +584,10 @@ public:
|
||||
|
||||
uint32_t GetNumAutoMarginsInAxis(AxisOrientationType aAxis) const;
|
||||
|
||||
// Once the main size has been resolved, should we bother doing layout to
|
||||
// establish the cross size?
|
||||
bool CanMainSizeInfluenceCrossSize(const FlexboxAxisTracker& aAxisTracker) const;
|
||||
|
||||
protected:
|
||||
// Helper called by the constructor, to set mNeedsMinSizeAutoResolution:
|
||||
void CheckForMinSizeAuto(const nsHTMLReflowState& aFlexItemReflowState,
|
||||
@@ -593,6 +600,10 @@ protected:
|
||||
const float mFlexGrow;
|
||||
const float mFlexShrink;
|
||||
|
||||
public: // bustage kludge for bug 1030952 (see TenFourFox issue 493)
|
||||
const nsSize mIntrinsicRatio;
|
||||
protected:
|
||||
|
||||
const nsMargin mBorderPadding;
|
||||
nsMargin mMargin; // non-const because we need to resolve auto margins
|
||||
|
||||
@@ -1189,7 +1200,6 @@ MainSizeFromAspectRatio(nscoord aCrossSize,
|
||||
static nscoord
|
||||
PartiallyResolveAutoMinSize(const FlexItem& aFlexItem,
|
||||
const nsHTMLReflowState& aItemReflowState,
|
||||
const nsSize& aIntrinsicRatio,
|
||||
const FlexboxAxisTracker& aAxisTracker)
|
||||
{
|
||||
MOZ_ASSERT(aFlexItem.NeedsMinSizeAutoResolution(),
|
||||
@@ -1226,7 +1236,7 @@ PartiallyResolveAutoMinSize(const FlexItem& aFlexItem,
|
||||
// * if the item has an intrinsic aspect ratio, the width (height) calculated
|
||||
// from the aspect ratio and any definite size constraints in the opposite
|
||||
// dimension.
|
||||
if (aAxisTracker.GetCrossComponent(aIntrinsicRatio) != 0) {
|
||||
if (aAxisTracker.GetCrossComponent(aFlexItem.mIntrinsicRatio) != 0) {
|
||||
// We have a usable aspect ratio. (not going to divide by 0)
|
||||
const bool useMinSizeIfCrossSizeIsIndefinite = true;
|
||||
nscoord crossSizeToUseWithRatio =
|
||||
@@ -1235,7 +1245,7 @@ PartiallyResolveAutoMinSize(const FlexItem& aFlexItem,
|
||||
aAxisTracker);
|
||||
nscoord minMainSizeFromRatio =
|
||||
MainSizeFromAspectRatio(crossSizeToUseWithRatio,
|
||||
aIntrinsicRatio, aAxisTracker);
|
||||
aFlexItem.mIntrinsicRatio, aAxisTracker);
|
||||
minMainSize = std::min(minMainSize, minMainSizeFromRatio);
|
||||
}
|
||||
|
||||
@@ -1249,7 +1259,6 @@ PartiallyResolveAutoMinSize(const FlexItem& aFlexItem,
|
||||
static bool
|
||||
ResolveAutoFlexBasisFromRatio(FlexItem& aFlexItem,
|
||||
const nsHTMLReflowState& aItemReflowState,
|
||||
const nsSize& aIntrinsicRatio,
|
||||
const FlexboxAxisTracker& aAxisTracker)
|
||||
{
|
||||
MOZ_ASSERT(NS_AUTOHEIGHT == aFlexItem.GetFlexBaseSize(),
|
||||
@@ -1259,8 +1268,8 @@ ResolveAutoFlexBasisFromRatio(FlexItem& aFlexItem,
|
||||
// - a [used] flex-basis of 'main-size' [auto?] [We have this, if we're here.]
|
||||
// - a definite cross size
|
||||
// then the flex base size is calculated from its inner cross size and the
|
||||
// flex item’s intrinsic aspect ratio.
|
||||
if (aAxisTracker.GetCrossComponent(aIntrinsicRatio) != 0) {
|
||||
// flex item?™s intrinsic aspect ratio.
|
||||
if (aAxisTracker.GetCrossComponent(aFlexItem.mIntrinsicRatio) != 0) {
|
||||
// We have a usable aspect ratio. (not going to divide by 0)
|
||||
const bool useMinSizeIfCrossSizeIsIndefinite = false;
|
||||
nscoord crossSizeToUseWithRatio =
|
||||
@@ -1271,7 +1280,7 @@ ResolveAutoFlexBasisFromRatio(FlexItem& aFlexItem,
|
||||
// We have a definite cross-size
|
||||
nscoord mainSizeFromRatio =
|
||||
MainSizeFromAspectRatio(crossSizeToUseWithRatio,
|
||||
aIntrinsicRatio, aAxisTracker);
|
||||
aFlexItem.mIntrinsicRatio, aAxisTracker);
|
||||
aFlexItem.SetFlexBaseSizeAndMainSize(mainSizeFromRatio);
|
||||
return true;
|
||||
}
|
||||
@@ -1329,19 +1338,15 @@ nsFlexContainerFrame::
|
||||
}
|
||||
}
|
||||
|
||||
// We'll need the intrinsic ratio (if there is one), regardless of whether
|
||||
// we're resolving min-[width|height]:auto or flex-basis:auto.
|
||||
const nsSize ratio = aFlexItem.Frame()->GetIntrinsicRatio();
|
||||
|
||||
nscoord resolvedMinSize; // (only set/used if isMainMinSizeAuto==true)
|
||||
bool minSizeNeedsToMeasureContent = false; // assume the best
|
||||
if (isMainMinSizeAuto) {
|
||||
// Resolve the min-size, except for considering the min-content size.
|
||||
// (We'll consider that later, if we need to.)
|
||||
resolvedMinSize = PartiallyResolveAutoMinSize(aFlexItem, aItemReflowState,
|
||||
ratio, aAxisTracker);
|
||||
aAxisTracker);
|
||||
if (resolvedMinSize > 0 &&
|
||||
aAxisTracker.GetCrossComponent(ratio) == 0) {
|
||||
aAxisTracker.GetCrossComponent(aFlexItem.IntrinsicRatio()) == 0) {
|
||||
// We don't have a usable aspect ratio, so we need to consider our
|
||||
// min-content size as another candidate min-size, which we'll have to
|
||||
// min() with the current resolvedMinSize.
|
||||
@@ -1354,7 +1359,7 @@ nsFlexContainerFrame::
|
||||
bool flexBasisNeedsToMeasureContent = false; // assume the best
|
||||
if (isMainSizeAuto) {
|
||||
if (!ResolveAutoFlexBasisFromRatio(aFlexItem, aItemReflowState,
|
||||
ratio, aAxisTracker)) {
|
||||
aAxisTracker)) {
|
||||
flexBasisNeedsToMeasureContent = true;
|
||||
}
|
||||
}
|
||||
@@ -1474,6 +1479,7 @@ FlexItem::FlexItem(nsHTMLReflowState& aFlexItemReflowState,
|
||||
: mFrame(aFlexItemReflowState.frame),
|
||||
mFlexGrow(aFlexGrow),
|
||||
mFlexShrink(aFlexShrink),
|
||||
mIntrinsicRatio(mFrame->GetIntrinsicRatio()),
|
||||
mBorderPadding(aFlexItemReflowState.ComputedPhysicalBorderPadding()),
|
||||
mMargin(aFlexItemReflowState.ComputedPhysicalMargin()),
|
||||
mMainMinSize(aMainMinSize),
|
||||
@@ -1547,6 +1553,7 @@ FlexItem::FlexItem(nsIFrame* aChildFrame, nscoord aCrossSize)
|
||||
: mFrame(aChildFrame),
|
||||
mFlexGrow(0.0f),
|
||||
mFlexShrink(0.0f),
|
||||
mIntrinsicRatio(),
|
||||
// mBorderPadding uses default constructor,
|
||||
// mMargin uses default constructor,
|
||||
mFlexBaseSize(0),
|
||||
@@ -1656,6 +1663,45 @@ FlexItem::GetNumAutoMarginsInAxis(AxisOrientationType aAxis) const
|
||||
return numAutoMargins;
|
||||
}
|
||||
|
||||
bool
|
||||
FlexItem::CanMainSizeInfluenceCrossSize(
|
||||
const FlexboxAxisTracker& aAxisTracker) const
|
||||
{
|
||||
if (mIsStretched) {
|
||||
// We've already had our cross-size stretched for "align-self:stretch").
|
||||
// The container is imposing its cross size on us.
|
||||
return false;
|
||||
}
|
||||
|
||||
if (HasIntrinsicRatio()) {
|
||||
// For flex items that have an intrinsic ratio (and maintain it, i.e. are
|
||||
// not stretched, which we already checked above): changes to main-size
|
||||
// *do* influence the cross size.
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mIsStrut) {
|
||||
// Struts (for visibility:collapse items) have a predetermined size;
|
||||
// no need to measure anything.
|
||||
return false;
|
||||
}
|
||||
|
||||
if (IsAxisHorizontal(aAxisTracker.GetCrossAxis())) {
|
||||
// If the cross axis is horizontal, then changes to the item's main size
|
||||
// (height) can't influence its cross size (width), if the item is a block
|
||||
// with a horizontal writing-mode.
|
||||
// XXXdholbert This doesn't account for vertical writing-modes, items with
|
||||
// aspect ratios, items that are multicol elements, & items that are
|
||||
// multi-line vertical flex containers. In all of those cases, a change to
|
||||
// the height could influence the width.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Default assumption, if we haven't proven otherwise: the resolved main size
|
||||
// *can* change the cross size.
|
||||
return true;
|
||||
}
|
||||
|
||||
// Keeps track of our position along a particular axis (where a '0' position
|
||||
// corresponds to the 'start' edge of that axis).
|
||||
// This class shouldn't be instantiated directly -- rather, it should only be
|
||||
@@ -3276,16 +3322,17 @@ nsFlexContainerFrame::SizeItemInCrossAxis(
|
||||
FlexItem& aItem)
|
||||
{
|
||||
if (IsAxisHorizontal(aAxisTracker.GetCrossAxis())) {
|
||||
// XXXdholbert NOTE: For now, we should never hit this case, due to a
|
||||
// !IsAxisHorizontal(aAxisTracker.GetCrossAxis()) check that guards this
|
||||
// call in the caller. BUT, when we add support for vertical writing-modes,
|
||||
// (in bug 1079155 or a dependency), we'll relax that check, and we'll need
|
||||
// to be able to measure the baseline & width (given our resolved height)
|
||||
MOZ_ASSERT(aItem.HasIntrinsicRatio(),
|
||||
"For now, caller's CanMainSizeInfluenceCrossSize check should "
|
||||
"only allow us to get here for items with intrinsic ratio");
|
||||
// XXXdholbert When we finish support for vertical writing-modes,
|
||||
// (in bug 1079155 or a dependency), we'll relax the horizontal check in
|
||||
// CanMainSizeInfluenceCrossSize, and this function will need to be able
|
||||
// to measure the baseline & width (given our resolved height)
|
||||
// of vertical-writing-mode flex items here.
|
||||
MOZ_ASSERT_UNREACHABLE("Caller should use tentative cross size instead "
|
||||
"of calling SizeItemInCrossAxis");
|
||||
// (But if we do happen to get here, just trust the passed-in reflow state
|
||||
// for our cross size [width].)
|
||||
// For now, we only expect to get here for items with an intrinsic aspect
|
||||
// ratio; and for those items, we can just read the size off of the reflow
|
||||
// state, without performing reflow.
|
||||
aItem.SetCrossSize(aChildReflowState.ComputedWidth());
|
||||
return;
|
||||
}
|
||||
@@ -3492,6 +3539,40 @@ private:
|
||||
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
// Class to let us temporarily provide an override value for the the main-size
|
||||
// CSS property ('width' or 'height') on a flex item, for use in
|
||||
// nsLayoutUtils::ComputeSizeWithIntrinsicDimensions.
|
||||
// (We could use this overridden size more broadly, too, but it's probably
|
||||
// better to avoid property-table accesses. So, where possible, we communicate
|
||||
// the resolved main-size to the child via modifying its reflow state directly,
|
||||
// instead of using this class.)
|
||||
class MOZ_STACK_CLASS AutoFlexItemMainSizeOverride final
|
||||
{
|
||||
public:
|
||||
explicit AutoFlexItemMainSizeOverride(FlexItem& aItem
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: mItemProps(aItem.Frame()->Properties())
|
||||
{
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
|
||||
MOZ_ASSERT(!mItemProps.Has(nsIFrame::FlexItemMainSizeOverride()),
|
||||
"FlexItemMainSizeOverride prop shouldn't be set already; "
|
||||
"it should only be set temporarily (& not recursively)");
|
||||
NS_ASSERTION(aItem.HasIntrinsicRatio(),
|
||||
"This should only be needed for items with an aspect ratio");
|
||||
|
||||
mItemProps.Set(nsIFrame::FlexItemMainSizeOverride(), reinterpret_cast<void *>(aItem.GetMainSize()));
|
||||
}
|
||||
|
||||
~AutoFlexItemMainSizeOverride() {
|
||||
mItemProps.Remove(nsIFrame::FlexItemMainSizeOverride());
|
||||
}
|
||||
|
||||
private:
|
||||
const FrameProperties mItemProps;
|
||||
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
void
|
||||
nsFlexContainerFrame::DoFlexLayout(nsPresContext* aPresContext,
|
||||
nsHTMLReflowMetrics& aDesiredSize,
|
||||
@@ -3527,41 +3608,35 @@ nsFlexContainerFrame::DoFlexLayout(nsPresContext* aPresContext,
|
||||
nscoord sumLineCrossSizes = 0;
|
||||
for (FlexLine* line = lines.getFirst(); line; line = line->getNext()) {
|
||||
for (FlexItem* item = line->GetFirstItem(); item; item = item->getNext()) {
|
||||
// Note that we may already have the correct cross size. (We guess at it
|
||||
// in GenerateFlexItemForChild(), and we also may resolve it early for
|
||||
// stretched flex items.)
|
||||
//
|
||||
// We can skip measuring an item's cross size here in a few scenarios:
|
||||
// (A) If the flex item has already been stretched, then we're imposing
|
||||
// the container's cross size on it; no need to measure.
|
||||
// (B) If the flex item is a "strut", then it's just a placeholder with a
|
||||
// predetermined cross size; no need to measure.
|
||||
// (C) If the item's main-size can't affect its cross-size, then the
|
||||
// item's tentative cross size (which we got from the reflow state in
|
||||
// GenerateFlexItemForChild()) is correct. So, no need to re-measure.
|
||||
// (For now, this is equivalent to checking if the cross-axis is
|
||||
// horizontal, because until we enable vertical writing-modes, an
|
||||
// element's computed width can't be influenced by its computed
|
||||
// height.)
|
||||
if (!item->IsStretched() && // !A
|
||||
!item->IsStrut() && // !B
|
||||
!IsAxisHorizontal(aAxisTracker.GetCrossAxis())) { // !C
|
||||
// The item may already have the correct cross-size; only recalculate
|
||||
// if the item's main size resolution (flexing) could have influenced it:
|
||||
if (item->CanMainSizeInfluenceCrossSize(aAxisTracker)) {
|
||||
Maybe<AutoFlexItemMainSizeOverride> sizeOverride;
|
||||
if (item->HasIntrinsicRatio()) {
|
||||
// For flex items with an aspect ratio, we have to impose an override
|
||||
// for the main-size property *before* we even instantiate the reflow
|
||||
// state, in order for aspect ratio calculations to produce the right
|
||||
// cross size in the reflow state. (For other flex items, it's OK
|
||||
// (and cheaper) to impose our main size *after* the reflow state has
|
||||
// been constructed, since the main size shouldn't influence anything
|
||||
// about cross-size measurement until we actually reflow the child.)
|
||||
sizeOverride.emplace(*item);
|
||||
}
|
||||
|
||||
WritingMode wm = item->Frame()->GetWritingMode();
|
||||
LogicalSize availSize = aReflowState.ComputedSize(wm);
|
||||
availSize.BSize(wm) = NS_UNCONSTRAINEDSIZE;
|
||||
nsHTMLReflowState childReflowState(aPresContext, aReflowState,
|
||||
item->Frame(), availSize);
|
||||
// Override computed main-size
|
||||
if (IsAxisHorizontal(aAxisTracker.GetMainAxis())) {
|
||||
childReflowState.SetComputedWidth(item->GetMainSize());
|
||||
} else {
|
||||
// XXXdholbert NOTE: For now, we'll never hit this case, due to the
|
||||
// !IsAxisHorizontal(aAxisTracker.GetCrossAxis()) check above. But
|
||||
// when we add support for vertical writing modes, we'll relax that
|
||||
// check and be able to hit this code.
|
||||
childReflowState.SetComputedHeight(item->GetMainSize());
|
||||
if (!sizeOverride) {
|
||||
// Directly override the computed main-size, by tweaking reflow state:
|
||||
if (IsAxisHorizontal(aAxisTracker.GetMainAxis())) {
|
||||
childReflowState.SetComputedWidth(item->GetMainSize());
|
||||
} else {
|
||||
childReflowState.SetComputedHeight(item->GetMainSize());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SizeItemInCrossAxis(aPresContext, aAxisTracker,
|
||||
childReflowState, *item);
|
||||
}
|
||||
@@ -3842,20 +3917,29 @@ nsFlexContainerFrame::ReflowFlexItem(nsPresContext* aPresContext,
|
||||
didOverrideComputedHeight = true;
|
||||
}
|
||||
|
||||
// Override reflow state's computed cross-size, for stretched items.
|
||||
if (aItem.IsStretched()) {
|
||||
MOZ_ASSERT(aItem.GetAlignSelf() == NS_STYLE_ALIGN_ITEMS_STRETCH,
|
||||
"stretched item w/o 'align-self: stretch'?");
|
||||
// Override reflow state's computed cross-size if either:
|
||||
// - the item was stretched (in which case we're imposing a cross size)
|
||||
// ...or...
|
||||
// - the item it has an aspect ratio (in which case the cross-size that's
|
||||
// currently in the reflow state is based on arithmetic involving a stale
|
||||
// main-size value that we just stomped on above). (Note that we could handle
|
||||
// this case using an AutoFlexItemMainSizeOverride, as we do elsewhere; but
|
||||
// given that we *already know* the correct cross size to use here, it's
|
||||
// cheaper to just directly set it instead of setting a frame property.)
|
||||
if (aItem.IsStretched() ||
|
||||
aItem.HasIntrinsicRatio()) {
|
||||
if (IsAxisHorizontal(aAxisTracker.GetCrossAxis())) {
|
||||
childReflowState.SetComputedWidth(aItem.GetCrossSize());
|
||||
didOverrideComputedWidth = true;
|
||||
} else {
|
||||
// If this item's height is stretched, it's a relative height.
|
||||
aItem.Frame()->AddStateBits(NS_FRAME_CONTAINS_RELATIVE_HEIGHT);
|
||||
childReflowState.SetComputedHeight(aItem.GetCrossSize());
|
||||
didOverrideComputedHeight = true;
|
||||
}
|
||||
}
|
||||
if (aItem.IsStretched() && !IsAxisHorizontal(aAxisTracker.GetCrossAxis())) {
|
||||
// If this item's height is stretched, it's a relative height.
|
||||
aItem.Frame()->AddStateBits(NS_FRAME_CONTAINS_RELATIVE_HEIGHT);
|
||||
}
|
||||
|
||||
// XXXdholbert Might need to actually set the correct margins in the
|
||||
// reflow state at some point, so that they can be saved on the frame for
|
||||
|
||||
@@ -863,6 +863,12 @@ public:
|
||||
|
||||
NS_DECLARE_FRAME_PROPERTY(LineBaselineOffset, nullptr)
|
||||
|
||||
// Temporary override for a flex item's main-size property (either width
|
||||
// or height), imposed by its flex container.
|
||||
// XXX: We don't have bug 1064843, so use the previous declaration system
|
||||
// (see bug 1030952 part 3 and TenFourFox issue 493).
|
||||
NS_DECLARE_FRAME_PROPERTY(FlexItemMainSizeOverride, nullptr)
|
||||
|
||||
NS_DECLARE_FRAME_PROPERTY(CachedBackgroundImage, ReleaseValue<gfxASurface>)
|
||||
NS_DECLARE_FRAME_PROPERTY(CachedBackgroundImageDT,
|
||||
ReleaseValue<mozilla::gfx::DrawTarget>)
|
||||
|
||||
@@ -1033,7 +1033,7 @@ Http2Session::CleanupStream(Http2Stream *aStream, nsresult aResult,
|
||||
MOZ_ASSERT(pushSource->GetConsumerStream() == aStream);
|
||||
MOZ_ASSERT(!aStream->StreamID());
|
||||
MOZ_ASSERT(!(pushSource->StreamID() & 0x1));
|
||||
pushSource->SetConsumerStream(nullptr);
|
||||
aStream->ClearPushSource();
|
||||
}
|
||||
|
||||
if (aStream->DeferCleanup(aResult)) {
|
||||
|
||||
Reference in New Issue
Block a user