Bug 655877 - Part 14: Ignore float in SVG text frames. r=roc

This commit is contained in:
Cameron McCormack 2012-08-02 21:38:49 +10:00
parent b9878143c1
commit f41c8a5fe8
16 changed files with 72 additions and 39 deletions

View File

@ -517,7 +517,7 @@ CreateContinuation(nsIFrame* aFrame,
// doesn't go in the first letter frame. The continuation goes with the rest
// of the text that the first letter frame was made out of.
if (parent->GetType() == nsGkAtoms::letterFrame &&
parent->GetStyleDisplay()->IsFloating()) {
parent->IsFloating()) {
nsFirstLetterFrame* letterFrame = do_QueryFrame(parent);
rv = letterFrame->CreateContinuationForFloatingParent(presContext, aFrame,
aNewFrame, aIsFluid);

View File

@ -1068,7 +1068,11 @@ nsFrameConstructorState::GetGeometricParent(const nsStyleDisplay* aStyleDisplay,
// XXXbz couldn't we just force position to "static" on roots and
// float to "none"? That's OK per CSS 2.1, as far as I can tell.
if (aStyleDisplay->IsFloating() && mFloatedItems.containingBlock) {
if (aContentParentFrame && aContentParentFrame->IsSVGText()) {
return aContentParentFrame;
}
if (aStyleDisplay->IsFloatingStyle() && mFloatedItems.containingBlock) {
NS_ASSERTION(!aStyleDisplay->IsAbsolutelyPositioned(),
"Absolutely positioned _and_ floating?");
return mFloatedItems.containingBlock;
@ -1120,7 +1124,7 @@ nsFrameConstructorState::AddChild(nsIFrame* aNewFrame,
}
else
#endif // MOZ_XUL
if (aCanBeFloated && disp->IsFloating() &&
if (aCanBeFloated && aNewFrame->IsFloating() &&
mFloatedItems.containingBlock) {
NS_ASSERTION(aNewFrame->GetParent() == mFloatedItems.containingBlock,
"Float whose parent is not the float containing block?");
@ -2975,7 +2979,7 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsFrameConstructorState& aState,
NS_ASSERTION(!listStyle->GetStyleDisplay()->IsPositioned(),
"Ended up with positioned dropdown list somehow.");
NS_ASSERTION(!listStyle->GetStyleDisplay()->IsFloating(),
NS_ASSERTION(!listFrame->IsFloating(),
"Ended up with floating dropdown list somehow.");
// Initialize the scroll frame positioned. Note that it is NOT
@ -3356,7 +3360,7 @@ nsCSSFrameConstructor::FindHTMLData(Element* aElement,
nsCSSAnonBoxes::fieldsetContent) ||
!aElement->GetParent() ||
!aElement->GetParent()->IsHTML(nsGkAtoms::fieldset) ||
aStyleContext->GetStyleDisplay()->IsFloating() ||
aStyleContext->GetStyleDisplay()->IsFloatingStyle() ||
aStyleContext->GetStyleDisplay()->IsAbsolutelyPositioned())) {
// <legend> is only special inside fieldset, check both the frame tree
// parent and content tree parent due to XBL issues. For floated or
@ -4314,7 +4318,7 @@ nsCSSFrameConstructor::FindDisplayData(const nsStyleDisplay* aDisplay,
// The style system ensures that floated and positioned frames are
// block-level.
NS_ASSERTION(!(aDisplay->IsFloating() ||
NS_ASSERTION(!(aDisplay->IsFloatingStyle() ||
aDisplay->IsAbsolutelyPositioned()) ||
aDisplay->IsBlockOutside(),
"Style system did not apply CSS2.1 section 9.7 fixups");
@ -4487,10 +4491,11 @@ nsCSSFrameConstructor::ConstructNonScrollableBlock(nsFrameConstructorState& aSta
// we can check it later in nsFrame::ApplyPaginatedOverflowClipping.
bool clipPaginatedOverflow =
(aItem.mFCData->mBits & FCDATA_FORCED_NON_SCROLLABLE_BLOCK) != 0;
if (aDisplay->IsAbsolutelyPositioned() ||
aDisplay->IsFloating() ||
NS_STYLE_DISPLAY_INLINE_BLOCK == aDisplay->mDisplay ||
clipPaginatedOverflow) {
if ((aDisplay->IsAbsolutelyPositioned() ||
aDisplay->IsFloatingStyle() ||
NS_STYLE_DISPLAY_INLINE_BLOCK == aDisplay->mDisplay ||
clipPaginatedOverflow) &&
!aParentFrame->IsSVGText()) {
*aNewFrame = NS_NewBlockFormattingContext(mPresShell, styleContext);
if (clipPaginatedOverflow) {
(*aNewFrame)->AddStateBits(NS_BLOCK_CLIP_PAGINATED_OVERFLOW);
@ -5376,8 +5381,9 @@ nsCSSFrameConstructor::AddFrameConstructionItemsInternal(nsFrameConstructorState
// isOutOfFlow might be false even in cases when the frame will end up
// out-of-flow, we can't use it here. But we _can_ say that the frame will
// for sure end up in-flow if it's not floated or absolutely positioned.
item->mIsBlock =
!isInline && !display->IsAbsolutelyPositioned() && !display->IsFloating();
item->mIsBlock = !isInline &&
!display->IsAbsolutelyPositioned() &&
!display->IsFloatingStyle();
}
if (item->mIsAllInline) {
@ -10427,7 +10433,7 @@ nsCSSFrameConstructor::CreateLetterFrame(nsIFrame* aBlockFrame,
// Create the right type of first-letter frame
const nsStyleDisplay* display = sc->GetStyleDisplay();
if (display->IsFloating()) {
if (display->IsFloating(aParentFrame)) {
// Make a floating first-letter frame
CreateFloatingLetterFrame(state, aBlockFrame, aTextContent, textFrame,
blockContent, aParentFrame, sc, aResult);

View File

@ -421,7 +421,7 @@ nsLayoutUtils::GetChildListNameFor(nsIFrame* aChildFrame)
return nsIFrame::kPopupList;
#endif // MOZ_XUL
} else {
NS_ASSERTION(aChildFrame->GetStyleDisplay()->IsFloating(),
NS_ASSERTION(aChildFrame->IsFloating(),
"not a floated frame");
id = nsIFrame::kFloatList;
}
@ -457,7 +457,7 @@ nsLayoutUtils::GetChildListNameFor(nsIFrame* aChildFrame)
found = parent->GetChildList(nsIFrame::kOverflowList)
.ContainsFrame(aChildFrame);
}
else if (aChildFrame->GetStyleDisplay()->IsFloating()) {
else if (aChildFrame->IsFloating()) {
found = parent->GetChildList(nsIFrame::kOverflowOutOfFlowList)
.ContainsFrame(aChildFrame);
}
@ -535,7 +535,7 @@ nsLayoutUtils::GetFloatFromPlaceholder(nsIFrame* aFrame) {
if (aFrame->GetStateBits() & PLACEHOLDER_FOR_FLOAT) {
nsIFrame *outOfFlowFrame =
nsPlaceholderFrame::GetRealFrameForPlaceholder(aFrame);
NS_ASSERTION(outOfFlowFrame->GetStyleDisplay()->IsFloating(),
NS_ASSERTION(outOfFlowFrame->IsFloating(),
"How did that happen?");
return outOfFlowFrame;
}

View File

@ -17,7 +17,7 @@ NS_NewLegendFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
{
#ifdef DEBUG
const nsStyleDisplay* disp = aContext->GetStyleDisplay();
NS_ASSERTION(!disp->IsAbsolutelyPositioned() && !disp->IsFloating(),
NS_ASSERTION(!disp->IsAbsolutelyPositioned() && !disp->IsFloatingStyle(),
"Legends should not be positioned and should not float");
#endif

View File

@ -4956,7 +4956,7 @@ nsBlockFrame::AddFrames(nsFrameList& aFrameList, nsIFrame* aPrevSibling)
"Unexpected aPrevSibling");
NS_ASSERTION(newFrame->GetType() != nsGkAtoms::placeholderFrame ||
(!newFrame->GetStyleDisplay()->IsAbsolutelyPositioned() &&
!newFrame->GetStyleDisplay()->IsFloating()),
!newFrame->IsFloating()),
"Placeholders should not float or be positioned");
bool isBlock = newFrame->GetStyleDisplay()->IsBlockOutside();
@ -5643,7 +5643,7 @@ nsBlockFrame::StealFrame(nsPresContext* aPresContext,
NS_PRECONDITION(aPresContext && aChild, "null pointer");
if ((aChild->GetStateBits() & NS_FRAME_OUT_OF_FLOW) &&
aChild->GetStyleDisplay()->IsFloating()) {
aChild->IsFloating()) {
bool removed = mFloats.RemoveFrameIfPresent(aChild);
if (!removed) {
nsFrameList* list = GetPushedFloats();

View File

@ -446,7 +446,7 @@ IsFontSizeInflationContainer(nsIFrame* aFrame,
nsIContent *content = aFrame->GetContent();
bool isInline = (aStyleDisplay->mDisplay == NS_STYLE_DISPLAY_INLINE ||
(aStyleDisplay->IsFloating() &&
(aFrame->IsFloating() &&
aFrame->GetType() == nsGkAtoms::letterFrame) ||
// Given multiple frames for the same node, only the
// outer one should be considered a container.
@ -522,7 +522,7 @@ nsFrame::Init(nsIContent* aContent,
AddStateBits(NS_FRAME_FONT_INFLATION_CONTAINER);
if (!GetParent() ||
// I'd use NS_FRAME_OUT_OF_FLOW, but it's not set yet.
disp->IsFloating() || disp->IsAbsolutelyPositioned()) {
disp->IsFloating(this) || disp->IsAbsolutelyPositioned()) {
AddStateBits(NS_FRAME_FONT_INFLATION_FLOW_ROOT);
}
}
@ -2105,7 +2105,7 @@ nsIFrame::BuildDisplayListForChild(nsDisplayListBuilder* aBuilder,
|| nsSVGIntegrationUtils::UsingEffectsForFrame(child);
bool isPositioned = !isSVG && disp->IsPositioned();
if (isVisuallyAtomic || isPositioned || (!isSVG && disp->IsFloating()) ||
if (isVisuallyAtomic || isPositioned || (!isSVG && disp->IsFloating(child)) ||
((disp->mClipFlags & NS_STYLE_CLIP_RECT) &&
IsSVGContentWithCSSClip(child)) ||
(aFlags & DISPLAY_CHILD_FORCE_STACKING_CONTEXT)) {
@ -2246,7 +2246,7 @@ nsIFrame::BuildDisplayListForChild(nsDisplayListBuilder* aBuilder,
}
}
}
} else if (!isSVG && disp->IsFloating()) {
} else if (!isSVG && disp->IsFloating(child)) {
if (!list.IsEmpty()) {
rv = aLists.Floats()->AppendNewToTop(new (aBuilder)
nsDisplayWrapList(aBuilder, child, &list));
@ -9365,7 +9365,7 @@ nsHTMLReflowState::DisplayInitFrameTypeExit(nsIFrame* aFrame,
printf(" prev-in-flow");
if (disp->IsAbsolutelyPositioned())
printf(" abspos");
if (disp->IsFloating())
if (aFrame->IsFloating())
printf(" float");
// This array must exactly match the NS_STYLE_DISPLAY constants.

View File

@ -1516,7 +1516,7 @@ NS_NewHTMLFramesetFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
{
#ifdef DEBUG
const nsStyleDisplay* disp = aContext->GetStyleDisplay();
NS_ASSERTION(!disp->IsAbsolutelyPositioned() && !disp->IsFloating(),
NS_ASSERTION(!disp->IsAbsolutelyPositioned() && !disp->IsFloatingStyle(),
"Framesets should not be positioned and should not float");
#endif

View File

@ -644,8 +644,8 @@ nsHTMLReflowState::InitFrameType(nsIAtom* aFrameType)
NS_ASSERTION(frame->GetStyleDisplay()->IsAbsolutelyPositioned() ==
disp->IsAbsolutelyPositioned(),
"Unexpected position style");
NS_ASSERTION(frame->GetStyleDisplay()->IsFloating() ==
disp->IsFloating(), "Unexpected float style");
NS_ASSERTION(frame->GetStyleDisplay()->IsFloatingStyle() ==
disp->IsFloatingStyle(), "Unexpected float style");
if (frame->GetStateBits() & NS_FRAME_OUT_OF_FLOW) {
if (disp->IsAbsolutelyPositioned()) {
frameType = NS_CSS_FRAME_TYPE_ABSOLUTE;
@ -654,7 +654,7 @@ nsHTMLReflowState::InitFrameType(nsIAtom* aFrameType)
if (frame->GetPrevInFlow())
frameType = NS_CSS_FRAME_TYPE_BLOCK;
}
else if (disp->IsFloating()) {
else if (disp->IsFloating(frame)) {
frameType = NS_CSS_FRAME_TYPE_FLOATING;
} else {
NS_ASSERTION(disp->mDisplay == NS_STYLE_DISPLAY_POPUP,

View File

@ -292,6 +292,10 @@ public:
const nsStylePadding* mStylePadding;
const nsStyleText* mStyleText;
bool IsFloating() const {
return mStyleDisplay->IsFloating(frame);
}
// a frame (e.g. nsTableCellFrame) which may need to generate a special
// reflow for percent height calculations
nsIPercentHeightObserver* mPercentHeightObserver;

View File

@ -2503,7 +2503,9 @@ public:
*/
bool IsPseudoStackingContextFromStyle() {
const nsStyleDisplay* disp = GetStyleDisplay();
return disp->mOpacity != 1.0f || disp->IsPositioned() || disp->IsFloating();
return disp->mOpacity != 1.0f ||
disp->IsPositioned() ||
disp->IsFloating(this);
}
virtual bool HonorPrintBackgroundSettings() { return true; }
@ -2838,6 +2840,8 @@ NS_PTR_TO_INT32(frame->Properties().Get(nsIFrame::ParagraphDepthProperty()))
};
bool IsVisibleConsideringAncestors(PRUint32 aFlags = 0) const;
inline bool IsFloating() const;
/**
* Returns the vertical-align value to be used for layout, if it is one
* of the enumerated values. If this is an SVG text frame, it returns a value
@ -3160,4 +3164,13 @@ FrameLinkEnumerator(const nsFrameList& aList, nsIFrame* aPrevFrame)
mPrev = aPrevFrame;
mFrame = aPrevFrame ? aPrevFrame->GetNextSibling() : aList.FirstChild();
}
#include "nsStyleStructInlines.h"
bool
nsIFrame::IsFloating() const
{
return GetStyleDisplay()->IsFloating(this);
}
#endif /* nsIFrame_h___ */

View File

@ -977,8 +977,7 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame,
// return now.
bool optionalBreakAfterFits;
NS_ASSERTION(isText ||
reflowStateHolder.ref().mStyleDisplay->mFloats ==
NS_STYLE_FLOAT_NONE,
!reflowStateHolder.ref().IsFloating(),
"How'd we get a floated inline frame? "
"The frame ctor should've dealt with this.");
// Direction is inherited, so using the psd direction is fine.
@ -1051,7 +1050,7 @@ void
nsLineLayout::ApplyStartMargin(PerFrameData* pfd,
nsHTMLReflowState& aReflowState)
{
NS_ASSERTION(aReflowState.mStyleDisplay->mFloats == NS_STYLE_FLOAT_NONE,
NS_ASSERTION(!aReflowState.IsFloating(),
"How'd we get a floated inline frame? "
"The frame ctor should've dealt with this.");

View File

@ -82,7 +82,7 @@ nsPlaceholderFrame::AddInlineMinWidth(nsRenderingContext *aRenderingContext,
// false.
// ...but push floats onto the list
if (mOutOfFlowFrame->GetStyleDisplay()->IsFloating())
if (mOutOfFlowFrame->IsFloating())
aData->floats.AppendElement(mOutOfFlowFrame);
}
@ -97,7 +97,7 @@ nsPlaceholderFrame::AddInlinePrefWidth(nsRenderingContext *aRenderingContext,
// false.
// ...but push floats onto the list
if (mOutOfFlowFrame->GetStyleDisplay()->IsFloating())
if (mOutOfFlowFrame->IsFloating())
aData->floats.AppendElement(mOutOfFlowFrame);
}

View File

@ -1154,7 +1154,7 @@ BuildTextRuns(gfxContext* aContext, nsTextFrame* aForFrame,
NS_ASSERTION(!aForFrame ||
(aLineContainer == FindLineContainer(aForFrame) ||
(aLineContainer->GetType() == nsGkAtoms::letterFrame &&
aLineContainer->GetStyleDisplay()->IsFloating())),
aLineContainer->IsFloating())),
"Wrong line container hint");
}
@ -4619,7 +4619,8 @@ nsTextFrame::GetTextDecorations(nsPresContext* aPresContext,
} else {
// In standards/almost-standards mode, if we're on an
// absolutely-positioned element or a floating element, we're done.
if (disp->IsFloating() || disp->IsAbsolutelyPositioned()) {
if (f->IsFloating() ||
(disp->IsAbsolutelyPositioned() && !f->IsSVGText())) {
break;
}
}
@ -7180,7 +7181,7 @@ bool
nsTextFrame::IsFloatingFirstLetterChild() const
{
nsIFrame* frame = GetParent();
return frame && frame->GetStyleDisplay()->IsFloating() &&
return frame && frame->IsFloating() &&
frame->GetType() == nsGkAtoms::letterFrame;
}

View File

@ -1638,7 +1638,7 @@ struct nsStyleDisplay {
return IsDisplayTypeInlineOutside(mOriginalDisplay);
}
bool IsFloating() const {
bool IsFloatingStyle() const {
return NS_STYLE_FLOAT_NONE != mFloats;
}
@ -1664,6 +1664,9 @@ struct nsStyleDisplay {
mTransformStyle == NS_STYLE_TRANSFORM_STYLE_PRESERVE_3D ||
mBackfaceVisibility == NS_STYLE_BACKFACE_VISIBILITY_HIDDEN;
}
// These are defined in nsStyleStructInlines.h.
inline bool IsFloating(const nsIFrame* aFrame) const;
};
struct nsStyleTable {

View File

@ -11,6 +11,7 @@
#ifndef nsStyleStructInlines_h_
#define nsStyleStructInlines_h_
#include "nsIFrame.h"
#include "nsStyleStruct.h"
#include "imgIRequest.h"
#include "imgIContainer.h"
@ -54,4 +55,10 @@ nsStyleBorder::GetSubImage(PRUint8 aIndex) const
return subImage;
}
bool
nsStyleDisplay::IsFloating(const nsIFrame* aFrame) const
{
return IsFloatingStyle() && !aFrame->IsSVGText();
}
#endif /* !defined(nsStyleStructInlines_h_) */

View File

@ -892,7 +892,7 @@ nsTableRowFrame::ReflowChildren(nsPresContext* aPresContext,
// if we are in a floated table, our position is not yet established, so we cannot reposition our views
// the containing block will do this for us after positioning the table
if (!aTableFrame.GetStyleDisplay()->IsFloating()) {
if (!aTableFrame.IsFloating()) {
// Because we may have moved the frame we need to make sure any views are
// positioned properly. We have to do this, because any one of our parent
// frames could have moved and we have no way of knowing...