Bug 1365356 - patch 3 - Allow callers to pass an nsStyleDisplay to GetContainingBlock (and IsAbsolutelyPositioned, which it calls) if they have it on hand, to avoid internal calls to StyleDisplay(). r=mats

This commit is contained in:
Jonathan Kew 2017-05-17 15:47:36 +01:00
Родитель 6d345e8ee2
Коммит fef41b2663
4 изменённых файлов: 16 добавлений и 12 удалений

Просмотреть файл

@ -494,7 +494,7 @@ void ReflowInput::InitCBReflowInput()
return;
}
if (mParentReflowInput->mFrame == mFrame->GetContainingBlock()) {
if (mParentReflowInput->mFrame == mFrame->GetContainingBlock(0, mStyleDisplay)) {
// Inner table frames need to use the containing block of the outer
// table frame.
if (mFrame->IsTableFrame()) {
@ -526,7 +526,7 @@ IsQuirkContainingBlockHeight(const ReflowInput* rs, LayoutFrameType aFrameType)
// Note: This next condition could change due to a style change,
// but that would cause a style reflow anyway, which means we're ok.
if (NS_AUTOHEIGHT == rs->ComputedHeight()) {
if (!rs->mFrame->IsAbsolutelyPositioned()) {
if (!rs->mFrame->IsAbsolutelyPositioned(rs->mStyleDisplay)) {
return false;
}
}
@ -1980,7 +1980,7 @@ CalcQuirkContainingBlockHeight(const ReflowInput* aCBReflowInput)
// not auto-height, use this as the percentage base. 2) If auto-height,
// keep looking, unless the frame is positioned.
if (NS_AUTOHEIGHT == rs->ComputedHeight()) {
if (rs->mFrame->IsAbsolutelyPositioned()) {
if (rs->mFrame->IsAbsolutelyPositioned(rs->mStyleDisplay)) {
break;
} else {
continue;
@ -2061,7 +2061,7 @@ ReflowInput::ComputeContainingBlockRectangle(
// 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 ||
(mFrame->IsTableFrame() && mFrame->IsAbsolutelyPositioned() &&
(mFrame->IsTableFrame() && mFrame->IsAbsolutelyPositioned(mStyleDisplay) &&
(mFrame->GetParent()->GetStateBits() & NS_FRAME_OUT_OF_FLOW))) {
// See if the ancestor is block-level or inline-level
if (NS_FRAME_GET_TYPE(aContainingBlockRI->mFrameType) == NS_CSS_FRAME_TYPE_INLINE) {

Просмотреть файл

@ -1390,7 +1390,7 @@ nsIFrame::HasPerspective(const nsStyleDisplay* aStyleDisplay) const
if (!IsTransformed(disp)) {
return false;
}
nsIFrame* containingBlock = GetContainingBlock(SKIP_SCROLLED_FRAME);
nsIFrame* containingBlock = GetContainingBlock(SKIP_SCROLLED_FRAME, disp);
if (!containingBlock) {
return false;
}
@ -2785,7 +2785,8 @@ nsIFrame::BuildDisplayListForStackingContext(nsDisplayListBuilder* aBuilder,
resultList.AppendNewToTop(
new (aBuilder) nsDisplayPerspective(
aBuilder, this,
GetContainingBlock()->GetContent()->GetPrimaryFrame(), &resultList));
GetContainingBlock(0, disp)->GetContent()->GetPrimaryFrame(),
&resultList));
}
}
@ -7015,7 +7016,8 @@ GetNearestBlockContainer(nsIFrame* frame)
}
nsIFrame*
nsIFrame::GetContainingBlock(uint32_t aFlags) const
nsIFrame::GetContainingBlock(uint32_t aFlags,
const nsStyleDisplay* aStyleDisplay) const
{
if (!GetParent()) {
return nullptr;
@ -7024,7 +7026,7 @@ nsIFrame::GetContainingBlock(uint32_t aFlags) const
// still be in-flow. So we have to check to make sure that the frame
// is really out-of-flow too.
nsIFrame* f;
if (IsAbsolutelyPositioned() &&
if (IsAbsolutelyPositioned(aStyleDisplay) &&
(GetStateBits() & NS_FRAME_OUT_OF_FLOW)) {
f = GetParent(); // the parent is always the containing block
} else {

Просмотреть файл

@ -2758,7 +2758,8 @@ public:
// this and return the outer scroll frame.
SKIP_SCROLLED_FRAME = 0x01
};
nsIFrame* GetContainingBlock(uint32_t aFlags = 0) const;
nsIFrame* GetContainingBlock(uint32_t aFlags = 0,
const nsStyleDisplay* aStyleDisplay = nullptr) const;
/**
* Is this frame a containing block for floating elements?
@ -3610,7 +3611,7 @@ public:
inline bool IsAbsPosContainingBlock() const;
inline bool IsFixedPosContainingBlock() const;
inline bool IsRelativelyPositioned() const;
inline bool IsAbsolutelyPositioned() const;
inline bool IsAbsolutelyPositioned(const nsStyleDisplay* aStyleDisplay = nullptr) const;
/**
* Returns the vertical-align value to be used for layout, if it is one

Просмотреть файл

@ -66,9 +66,10 @@ nsIFrame::IsRelativelyPositioned() const
}
bool
nsIFrame::IsAbsolutelyPositioned() const
nsIFrame::IsAbsolutelyPositioned(const nsStyleDisplay* aStyleDisplay) const
{
return StyleDisplay()->IsAbsolutelyPositioned(this);
const nsStyleDisplay* disp = StyleDisplayWithOptionalParam(aStyleDisplay);
return disp->IsAbsolutelyPositioned(this);
}
bool