Bug 944200 part 2 - [css-ui] Store the line's float edges for text-overflow analysis if needed. r=dholbert
MozReview-Commit-ID: KqENMs07yrM
--- a/layout/generic/nsBlockFrame.cpp
+++ b/layout/generic/nsBlockFrame.cpp
@@ -2827,16 +2827,36 @@ nsBlockFrame::ReflowLine(BlockReflowInpu
aLine->ClearHadFloatPushed();
// Now that we know what kind of line we have, reflow it
if (aLine->IsBlock()) {
ReflowBlockFrame(aState, aLine, aKeepReflowGoing);
} else {
aLine->SetLineWrapped(false);
ReflowInlineFrames(aState, aLine, aKeepReflowGoing);
+
+ // Store the line's float edges for text-overflow analysis if needed.
+ aLine->ClearFloatEdges();
+ if (aState.mFlags.mCanHaveTextOverflow) {
+ WritingMode wm = aLine->mWritingMode;
+ nsFlowAreaRect r = aState.GetFloatAvailableSpaceForBSize(aLine->BStart(),
+ aLine->BSize(),
+ nullptr);
+ if (r.mHasFloats) {
+ LogicalRect so =
+ aLine->GetOverflowArea(eScrollableOverflow, wm, aLine->mContainerSize);
+ nscoord s = r.mRect.IStart(wm);
+ nscoord e = r.mRect.IEnd(wm);
+ if (so.IEnd(wm) > e || so.IStart(wm) < s) {
+ // This line is overlapping a float - store the edges marking the area
+ // between the floats for text-overflow analysis.
+ aLine->SetFloatEdges(s, e);
+ }
+ }
+ }
}
}
nsIFrame*
nsBlockFrame::PullFrame(BlockReflowInput& aState,
LineIterator aLine)
{
// First check our remaining lines.
--- a/layout/generic/nsLineBox.cpp
+++ b/layout/generic/nsLineBox.cpp
@@ -540,16 +540,37 @@ nsLineBox::RemoveFloat(nsIFrame* aFrame)
MaybeFreeData();
return true;
}
}
return false;
}
void
+nsLineBox::SetFloatEdges(nscoord aStart, nscoord aEnd)
+{
+ MOZ_ASSERT(IsInline(), "block line can't have float edges");
+ if (!mInlineData) {
+ mInlineData = new ExtraInlineData(GetPhysicalBounds());
+ }
+ mInlineData->mFloatEdgeIStart = aStart;
+ mInlineData->mFloatEdgeIEnd = aEnd;
+}
+
+void
+nsLineBox::ClearFloatEdges()
+{
+ MOZ_ASSERT(IsInline(), "block line can't have float edges");
+ if (mInlineData) {
+ mInlineData->mFloatEdgeIStart = NS_INTRINSIC_WIDTH_UNKNOWN;
+ mInlineData->mFloatEdgeIEnd = NS_INTRINSIC_WIDTH_UNKNOWN;
+ }
+}
+
+void
nsLineBox::SetOverflowAreas(const nsOverflowAreas& aOverflowAreas)
{
NS_FOR_FRAME_OVERFLOW_TYPES(otype) {
NS_ASSERTION(aOverflowAreas.Overflow(otype).width >= 0,
"illegal width for combined area");
NS_ASSERTION(aOverflowAreas.Overflow(otype).height >= 0,
"illegal height for combined area");
}
--- a/layout/generic/nsLineBox.h
+++ b/layout/generic/nsLineBox.h
@@ -690,21 +690,38 @@ public:
: ExtraData(aBounds),
mCarriedOutBEndMargin()
{
}
nsCollapsingMargin mCarriedOutBEndMargin;
};
struct ExtraInlineData : public ExtraData {
- explicit ExtraInlineData(const nsRect& aBounds) : ExtraData(aBounds) {
- }
+ explicit ExtraInlineData(const nsRect& aBounds)
+ : ExtraData(aBounds)
+ , mFloatEdgeIStart(nscoord_MIN)
+ , mFloatEdgeIEnd(nscoord_MIN)
+ {}
+ nscoord mFloatEdgeIStart;
+ nscoord mFloatEdgeIEnd;
nsFloatCacheList mFloats;
};
+ bool GetFloatEdges(nscoord* aStart, nscoord* aEnd) const {
+ MOZ_ASSERT(IsInline(), "block line can't have float edges");
+ if (mInlineData && mInlineData->mFloatEdgeIStart != nscoord_MIN) {
+ *aStart = mInlineData->mFloatEdgeIStart;
+ *aEnd = mInlineData->mFloatEdgeIEnd;
+ return true;
+ }
+ return false;
+ }
+ void SetFloatEdges(nscoord aStart, nscoord aEnd);
+ void ClearFloatEdges();
+
protected:
nscoord mAscent; // see |SetAscent| / |GetAscent|
static_assert(sizeof(FlagBits) <= sizeof(uint32_t),
"size of FlagBits should not be larger than size of uint32_t");
union {
uint32_t mAllFlags;
FlagBits mFlags;
};