Bug 1251075 - Split out the parts of nsStyleDisplay::Is{Abs,Fixed}PosContainingBlock that don't depend on the frame. r?bz
The fact that HasTransform() depends on the frame requires the *Internal
functions rather than simply having the public function that takes a
frame call the public function that takes a style context.
MozReview-Commit-ID: CcWZjDTIr52
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -3026,36 +3026,69 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsSt
// value will be massaged to be something that makes sense for
// SVG text.
inline bool IsBlockInside(const nsIFrame* aContextFrame) const;
inline bool IsBlockOutside(const nsIFrame* aContextFrame) const;
inline bool IsInlineOutside(const nsIFrame* aContextFrame) const;
inline bool IsOriginalDisplayInlineOutside(const nsIFrame* aContextFrame) const;
inline uint8_t GetDisplay(const nsIFrame* aContextFrame) const;
inline bool IsFloating(const nsIFrame* aContextFrame) const;
- inline bool IsAbsPosContainingBlock(const nsIFrame* aContextFrame) const;
inline bool IsRelativelyPositioned(const nsIFrame* aContextFrame) const;
inline bool IsAbsolutelyPositioned(const nsIFrame* aContextFrame) const;
// These methods are defined in nsStyleStructInlines.h.
/**
+ * Returns whether the element is a containing block for its
+ * absolutely positioned descendants.
+ * aContextFrame is the frame for which this is the nsStyleDisplay.
+ */
+ inline bool IsAbsPosContainingBlock(const nsIFrame* aContextFrame) const;
+
+ /**
+ * The same as IsAbsPosContainingBlock, except skipping the tests that
+ * are based on the frame rather than the style context (thus
+ * potentially returning a false positive).
+ */
+ template<class StyleContextLike>
+ inline bool IsAbsPosContainingBlockForAppropriateFrame(
+ StyleContextLike* aStyleContext) const;
+
+ /**
* Returns true when the element has the transform property
* or a related property, and supports CSS transforms.
- * aContextFrame is the frame for which this is the nsStylePosition.
+ * aContextFrame is the frame for which this is the nsStyleDisplay.
*/
inline bool HasTransform(const nsIFrame* aContextFrame) const;
/**
* Returns true when the element is a containing block for its fixed-pos
* descendants.
- * aContextFrame is the frame for which this is the nsStylePosition.
+ * aContextFrame is the frame for which this is the nsStyleDisplay.
*/
inline bool IsFixedPosContainingBlock(const nsIFrame* aContextFrame) const;
+ /**
+ * The same as IsFixedPosContainingBlock, except skipping the tests that
+ * are based on the frame rather than the style context (thus
+ * potentially returning a false positive).
+ */
+ template<class StyleContextLike>
+ inline bool IsFixedPosContainingBlockForAppropriateFrame(
+ StyleContextLike* aStyleContext) const;
+
+private:
+ template<class StyleContextLike>
+ inline bool HasAbsPosContainingBlockStyleInternal(
+ StyleContextLike* aStyleContext) const;
+ template<class StyleContextLike>
+ inline bool HasFixedPosContainingBlockStyleInternal(
+ StyleContextLike* aStyleContext) const;
+
+public:
// Return the 'float' and 'clear' properties, with inline-{start,end} values
// resolved to {left,right} according to the given writing mode. These are
// defined in WritingModes.h.
inline mozilla::StyleFloat PhysicalFloats(mozilla::WritingMode aWM) const;
inline uint8_t PhysicalBreakType(mozilla::WritingMode aWM) const;
};
struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleTable
--- a/layout/style/nsStyleStructInlines.h
+++ b/layout/style/nsStyleStructInlines.h
@@ -139,40 +139,91 @@ nsStyleDisplay::IsFloating(const nsIFram
// this function in comments.
bool
nsStyleDisplay::HasTransform(const nsIFrame* aContextFrame) const
{
NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame");
return HasTransformStyle() && aContextFrame->IsFrameOfType(nsIFrame::eSupportsCSSTransforms);
}
+template<class StyleContextLike>
+bool
+nsStyleDisplay::HasFixedPosContainingBlockStyleInternal(
+ StyleContextLike* aStyleContext) const
+{
+ // NOTE: Any CSS properties that influence the output of this function
+ // should have the CSS_PROPERTY_FIXPOS_CB set on them.
+ NS_ASSERTION(aStyleContext->StyleDisplay() == this,
+ "unexpected aStyleContext");
+ return IsContainPaint() ||
+ HasPerspectiveStyle() ||
+ (mWillChangeBitField & NS_STYLE_WILL_CHANGE_FIXPOS_CB) ||
+ aStyleContext->StyleEffects()->HasFilters();
+}
+
+template<class StyleContextLike>
+bool
+nsStyleDisplay::IsFixedPosContainingBlockForAppropriateFrame(
+ StyleContextLike* aStyleContext) const
+{
+ // NOTE: Any CSS properties that influence the output of this function
+ // should have the CSS_PROPERTY_FIXPOS_CB set on them.
+ return HasFixedPosContainingBlockStyleInternal(aStyleContext) ||
+ HasTransformStyle();
+}
+
bool
nsStyleDisplay::IsFixedPosContainingBlock(const nsIFrame* aContextFrame) const
{
// NOTE: Any CSS properties that influence the output of this function
// should have the CSS_PROPERTY_FIXPOS_CB set on them.
- NS_ASSERTION(aContextFrame->StyleDisplay() == this,
- "unexpected aContextFrame");
- return (IsContainPaint() || HasTransform(aContextFrame) ||
- HasPerspectiveStyle() ||
- (mWillChangeBitField & NS_STYLE_WILL_CHANGE_FIXPOS_CB) ||
- aContextFrame->StyleEffects()->HasFilters()) &&
- !aContextFrame->IsSVGText();
+ if (!HasFixedPosContainingBlockStyleInternal(aContextFrame->StyleContext()) &&
+ !HasTransform(aContextFrame)) {
+ return false;
+ }
+ return !aContextFrame->IsSVGText();
+}
+
+template<class StyleContextLike>
+bool
+nsStyleDisplay::HasAbsPosContainingBlockStyleInternal(
+ StyleContextLike* aStyleContext) const
+{
+ // NOTE: Any CSS properties that influence the output of this function
+ // should have the CSS_PROPERTY_ABSPOS_CB set on them.
+ NS_ASSERTION(aStyleContext->StyleDisplay() == this,
+ "unexpected aStyleContext");
+ return IsAbsolutelyPositionedStyle() ||
+ IsRelativelyPositionedStyle() ||
+ (mWillChangeBitField & NS_STYLE_WILL_CHANGE_ABSPOS_CB);
+}
+
+template<class StyleContextLike>
+bool
+nsStyleDisplay::IsAbsPosContainingBlockForAppropriateFrame(StyleContextLike* aStyleContext) const
+{
+ // NOTE: Any CSS properties that influence the output of this function
+ // should have the CSS_PROPERTY_ABSPOS_CB set on them.
+ return HasAbsPosContainingBlockStyleInternal(aStyleContext) ||
+ HasFixedPosContainingBlockStyleInternal(aStyleContext) ||
+ HasTransformStyle();
}
bool
nsStyleDisplay::IsAbsPosContainingBlock(const nsIFrame* aContextFrame) const
{
- NS_ASSERTION(aContextFrame->StyleDisplay() == this,
- "unexpected aContextFrame");
- return ((IsAbsolutelyPositionedStyle() ||
- IsRelativelyPositionedStyle() ||
- (mWillChangeBitField & NS_STYLE_WILL_CHANGE_ABSPOS_CB)) &&
- !aContextFrame->IsSVGText()) ||
- IsFixedPosContainingBlock(aContextFrame);
+ // NOTE: Any CSS properties that influence the output of this function
+ // should have the CSS_PROPERTY_ABSPOS_CB set on them.
+ nsStyleContext* sc = aContextFrame->StyleContext();
+ if (!HasAbsPosContainingBlockStyleInternal(sc) &&
+ !HasFixedPosContainingBlockStyleInternal(sc) &&
+ !HasTransform(aContextFrame)) {
+ return false;
+ }
+ return !aContextFrame->IsSVGText();
}
bool
nsStyleDisplay::IsRelativelyPositioned(const nsIFrame* aContextFrame) const
{
NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame");
return IsRelativelyPositionedStyle() && !aContextFrame->IsSVGText();
}