2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/* rendering object for CSS display:inline objects */
|
|
|
|
|
|
|
|
#include "nsInlineFrame.h"
|
2013-02-01 08:01:47 -08:00
|
|
|
#include "nsLineLayout.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsBlockFrame.h"
|
2009-08-31 11:25:35 -07:00
|
|
|
#include "nsPlaceholderFrame.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsGkAtoms.h"
|
|
|
|
#include "nsStyleContext.h"
|
|
|
|
#include "nsPresContext.h"
|
2011-04-07 18:04:40 -07:00
|
|
|
#include "nsRenderingContext.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsCSSAnonBoxes.h"
|
|
|
|
#include "nsAutoPtr.h"
|
2013-07-20 12:14:25 -07:00
|
|
|
#include "RestyleManager.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsDisplayList.h"
|
2012-10-26 06:32:10 -07:00
|
|
|
#include "mozilla/Likely.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
#undef NOISY_PUSHING
|
|
|
|
#endif
|
|
|
|
|
2012-09-28 14:53:44 -07:00
|
|
|
using namespace mozilla;
|
2013-04-01 08:26:02 -07:00
|
|
|
using namespace mozilla::layout;
|
2012-09-28 14:53:44 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// Basic nsInlineFrame methods
|
|
|
|
|
2014-05-24 15:20:40 -07:00
|
|
|
nsInlineFrame*
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_NewInlineFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
|
|
|
{
|
|
|
|
return new (aPresShell) nsInlineFrame(aContext);
|
|
|
|
}
|
|
|
|
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsInlineFrame)
|
|
|
|
|
2009-01-12 11:20:59 -08:00
|
|
|
NS_QUERYFRAME_HEAD(nsInlineFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsInlineFrame)
|
2011-12-27 12:18:48 -08:00
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-01-05 15:31:14 -08:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-02-17 23:47:48 -08:00
|
|
|
nsresult
|
2007-03-22 10:30:00 -07:00
|
|
|
nsInlineFrame::GetFrameName(nsAString& aResult) const
|
|
|
|
{
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("Inline"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nsIAtom*
|
|
|
|
nsInlineFrame::GetType() const
|
|
|
|
{
|
|
|
|
return nsGkAtoms::inlineFrame;
|
|
|
|
}
|
|
|
|
|
2013-02-10 22:22:20 -08:00
|
|
|
void
|
|
|
|
nsInlineFrame::InvalidateFrame(uint32_t aDisplayItemKey)
|
|
|
|
{
|
|
|
|
if (IsSVGText()) {
|
|
|
|
nsIFrame* svgTextFrame =
|
|
|
|
nsLayoutUtils::GetClosestFrameOfType(GetParent(),
|
2013-12-20 08:38:51 -08:00
|
|
|
nsGkAtoms::svgTextFrame);
|
2013-02-10 22:22:20 -08:00
|
|
|
svgTextFrame->InvalidateFrame();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
nsInlineFrameBase::InvalidateFrame(aDisplayItemKey);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsInlineFrame::InvalidateFrameWithRect(const nsRect& aRect, uint32_t aDisplayItemKey)
|
|
|
|
{
|
|
|
|
if (IsSVGText()) {
|
|
|
|
nsIFrame* svgTextFrame =
|
|
|
|
nsLayoutUtils::GetClosestFrameOfType(GetParent(),
|
2013-12-20 08:38:51 -08:00
|
|
|
nsGkAtoms::svgTextFrame);
|
2013-02-10 22:22:20 -08:00
|
|
|
svgTextFrame->InvalidateFrame();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
nsInlineFrameBase::InvalidateFrameWithRect(aRect, aDisplayItemKey);
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
static inline bool
|
2010-08-31 09:05:12 -07:00
|
|
|
IsMarginZero(const nsStyleCoord &aCoord)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-08-31 09:05:12 -07:00
|
|
|
return aCoord.GetUnit() == eStyleUnit_Auto ||
|
2010-09-09 08:21:46 -07:00
|
|
|
nsLayoutUtils::IsMarginZero(aCoord);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
/* virtual */ bool
|
2007-03-22 10:30:00 -07:00
|
|
|
nsInlineFrame::IsSelfEmpty()
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
// I used to think inline frames worked this way, but it seems they
|
|
|
|
// don't. At least not in our codebase.
|
|
|
|
if (GetPresContext()->CompatibilityMode() == eCompatibility_FullStandards) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
#endif
|
2013-02-16 13:51:02 -08:00
|
|
|
const nsStyleMargin* margin = StyleMargin();
|
|
|
|
const nsStyleBorder* border = StyleBorder();
|
|
|
|
const nsStylePadding* padding = StylePadding();
|
2007-03-22 10:30:00 -07:00
|
|
|
// XXX Top and bottom removed, since they shouldn't affect things, but this
|
|
|
|
// doesn't really match with nsLineLayout.cpp's setting of
|
|
|
|
// ZeroEffectiveSpanBox, anymore, so what should this really be?
|
2011-09-28 23:19:26 -07:00
|
|
|
bool haveRight =
|
2012-05-30 22:19:49 -07:00
|
|
|
border->GetComputedBorderWidth(NS_SIDE_RIGHT) != 0 ||
|
2010-08-31 09:05:12 -07:00
|
|
|
!nsLayoutUtils::IsPaddingZero(padding->mPadding.GetRight()) ||
|
2010-08-31 09:05:12 -07:00
|
|
|
!IsMarginZero(margin->mMargin.GetRight());
|
2011-09-28 23:19:26 -07:00
|
|
|
bool haveLeft =
|
2012-05-30 22:19:49 -07:00
|
|
|
border->GetComputedBorderWidth(NS_SIDE_LEFT) != 0 ||
|
2010-08-31 09:05:12 -07:00
|
|
|
!nsLayoutUtils::IsPaddingZero(padding->mPadding.GetLeft()) ||
|
2010-08-31 09:05:12 -07:00
|
|
|
!IsMarginZero(margin->mMargin.GetLeft());
|
2009-09-18 11:00:21 -07:00
|
|
|
if (haveLeft || haveRight) {
|
2014-05-05 10:55:54 -07:00
|
|
|
// We skip this block and return false for box-decoration-break:clone since
|
|
|
|
// in that case all the continuations will have the border/padding/margin.
|
|
|
|
if ((GetStateBits() & NS_FRAME_PART_OF_IBSPLIT) &&
|
|
|
|
StyleBorder()->mBoxDecorationBreak ==
|
|
|
|
NS_STYLE_BOX_DECORATION_BREAK_SLICE) {
|
2011-09-28 23:19:26 -07:00
|
|
|
bool haveStart, haveEnd;
|
2013-02-16 13:51:02 -08:00
|
|
|
if (NS_STYLE_DIRECTION_LTR == StyleVisibility()->mDirection) {
|
2009-09-18 11:00:21 -07:00
|
|
|
haveStart = haveLeft;
|
|
|
|
haveEnd = haveRight;
|
|
|
|
} else {
|
|
|
|
haveStart = haveRight;
|
|
|
|
haveEnd = haveLeft;
|
|
|
|
}
|
2014-02-06 17:45:33 -08:00
|
|
|
// For ib-split frames, ignore things we know we'll skip in GetSkipSides.
|
|
|
|
// XXXbz should we be doing this for non-ib-split frames too, in a more
|
2009-09-18 11:00:21 -07:00
|
|
|
// general way?
|
|
|
|
|
|
|
|
// Get the first continuation eagerly, as a performance optimization, to
|
|
|
|
// avoid having to get it twice..
|
2013-09-25 04:42:34 -07:00
|
|
|
nsIFrame* firstCont = FirstContinuation();
|
2009-09-18 11:00:21 -07:00
|
|
|
return
|
2013-09-30 14:26:04 -07:00
|
|
|
(!haveStart || firstCont->FrameIsNonFirstInIBSplit()) &&
|
|
|
|
(!haveEnd || firstCont->FrameIsNonLastInIBSplit());
|
2009-09-18 11:00:21 -07:00
|
|
|
}
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2007-03-22 10:30:00 -07:00
|
|
|
nsInlineFrame::IsEmpty()
|
|
|
|
{
|
|
|
|
if (!IsSelfEmpty()) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
for (nsIFrame *kid = mFrames.FirstChild(); kid; kid = kid->GetNextSibling()) {
|
|
|
|
if (!kid->IsEmpty())
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2014-03-13 07:14:37 -07:00
|
|
|
nsIFrame::FrameSearchResult
|
2012-08-22 08:56:38 -07:00
|
|
|
nsInlineFrame::PeekOffsetCharacter(bool aForward, int32_t* aOffset,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aRespectClusters)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
// Override the implementation in nsFrame, to skip empty inline frames
|
|
|
|
NS_ASSERTION (aOffset && *aOffset <= 1, "aOffset out of range");
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t startOffset = *aOffset;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (startOffset < 0)
|
|
|
|
startOffset = 1;
|
|
|
|
if (aForward == (startOffset == 0)) {
|
|
|
|
// We're before the frame and moving forward, or after it and moving backwards:
|
|
|
|
// skip to the other side, but keep going.
|
|
|
|
*aOffset = 1 - startOffset;
|
|
|
|
}
|
2014-03-13 07:14:37 -07:00
|
|
|
return CONTINUE;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-02-14 03:12:27 -08:00
|
|
|
void
|
2007-03-22 10:30:00 -07:00
|
|
|
nsInlineFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
|
|
|
{
|
2013-02-14 03:08:08 -08:00
|
|
|
BuildDisplayListForInline(aBuilder, aDirtyRect, aLists);
|
2011-12-27 12:18:48 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// The sole purpose of this is to trigger display of the selection
|
|
|
|
// window for Named Anchors, which don't have any children and
|
|
|
|
// normally don't have any size, but in Editor we use CSS to display
|
|
|
|
// an image to represent this "hidden" element.
|
|
|
|
if (!mFrames.FirstChild()) {
|
2013-02-14 03:08:08 -08:00
|
|
|
DisplaySelectionOverlay(aBuilder, aLists.Content());
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// Reflow methods
|
|
|
|
|
|
|
|
/* virtual */ void
|
2011-04-07 18:04:40 -07:00
|
|
|
nsInlineFrame::AddInlineMinWidth(nsRenderingContext *aRenderingContext,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIFrame::InlineMinWidthData *aData)
|
|
|
|
{
|
|
|
|
DoInlineIntrinsicWidth(aRenderingContext, aData, nsLayoutUtils::MIN_WIDTH);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ void
|
2011-04-07 18:04:40 -07:00
|
|
|
nsInlineFrame::AddInlinePrefWidth(nsRenderingContext *aRenderingContext,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIFrame::InlinePrefWidthData *aData)
|
|
|
|
{
|
|
|
|
DoInlineIntrinsicWidth(aRenderingContext, aData, nsLayoutUtils::PREF_WIDTH);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nsSize
|
2011-04-07 18:04:40 -07:00
|
|
|
nsInlineFrame::ComputeSize(nsRenderingContext *aRenderingContext,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsSize aCBSize, nscoord aAvailableWidth,
|
|
|
|
nsSize aMargin, nsSize aBorder, nsSize aPadding,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aFlags)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
// Inlines and text don't compute size before reflow.
|
|
|
|
return nsSize(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
|
|
|
|
}
|
|
|
|
|
2007-10-12 01:30:54 -07:00
|
|
|
nsRect
|
|
|
|
nsInlineFrame::ComputeTightBounds(gfxContext* aContext) const
|
|
|
|
{
|
|
|
|
// be conservative
|
2013-02-15 21:38:33 -08:00
|
|
|
if (StyleContext()->HasTextDecorationLines()) {
|
2010-10-06 21:25:46 -07:00
|
|
|
return GetVisualOverflowRect();
|
2011-04-22 22:16:41 -07:00
|
|
|
}
|
2007-10-12 01:30:54 -07:00
|
|
|
return ComputeSimpleTightBounds(aContext);
|
|
|
|
}
|
|
|
|
|
2007-04-20 17:42:58 -07:00
|
|
|
void
|
|
|
|
nsInlineFrame::ReparentFloatsForInlineChild(nsIFrame* aOurLineContainer,
|
|
|
|
nsIFrame* aFrame,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aReparentSiblings)
|
2007-04-20 17:42:58 -07:00
|
|
|
{
|
2009-07-28 05:51:09 -07:00
|
|
|
// XXXbz this would be better if it took a nsFrameList or a frame
|
|
|
|
// list slice....
|
2007-04-20 17:42:58 -07:00
|
|
|
NS_ASSERTION(aOurLineContainer->GetNextContinuation() ||
|
|
|
|
aOurLineContainer->GetPrevContinuation(),
|
|
|
|
"Don't call this when we have no continuation, it's a waste");
|
2007-07-18 21:32:08 -07:00
|
|
|
if (!aFrame) {
|
|
|
|
NS_ASSERTION(aReparentSiblings, "Why did we get called?");
|
|
|
|
return;
|
|
|
|
}
|
2007-04-20 17:42:58 -07:00
|
|
|
|
|
|
|
nsIFrame* ancestor = aFrame;
|
|
|
|
do {
|
|
|
|
ancestor = ancestor->GetParent();
|
|
|
|
if (!ancestor)
|
|
|
|
return;
|
|
|
|
} while (!ancestor->IsFloatContainingBlock());
|
|
|
|
|
|
|
|
if (ancestor == aOurLineContainer)
|
|
|
|
return;
|
|
|
|
|
2008-07-13 15:10:23 -07:00
|
|
|
nsBlockFrame* ourBlock = nsLayoutUtils::GetAsBlock(aOurLineContainer);
|
|
|
|
NS_ASSERTION(ourBlock, "Not a block, but broke vertically?");
|
|
|
|
nsBlockFrame* frameBlock = nsLayoutUtils::GetAsBlock(ancestor);
|
|
|
|
NS_ASSERTION(frameBlock, "ancestor not a block");
|
2007-04-20 17:42:58 -07:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
while (true) {
|
2013-02-27 15:05:45 -08:00
|
|
|
ourBlock->ReparentFloats(aFrame, frameBlock, false);
|
2007-04-20 17:42:58 -07:00
|
|
|
|
|
|
|
if (!aReparentSiblings)
|
|
|
|
return;
|
|
|
|
nsIFrame* next = aFrame->GetNextSibling();
|
|
|
|
if (!next)
|
|
|
|
return;
|
|
|
|
if (next->GetParent() == aFrame->GetParent()) {
|
|
|
|
aFrame = next;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// This is paranoid and will hardly ever get hit ... but we can't actually
|
|
|
|
// trust that the frames in the sibling chain all have the same parent,
|
|
|
|
// because lazy reparenting may be going on. If we find a different
|
|
|
|
// parent we need to redo our analysis.
|
|
|
|
ReparentFloatsForInlineChild(aOurLineContainer, next, aReparentSiblings);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-22 15:42:45 -08:00
|
|
|
static void
|
2010-04-01 23:07:43 -07:00
|
|
|
ReparentChildListStyle(nsPresContext* aPresContext,
|
2009-12-22 15:42:45 -08:00
|
|
|
const nsFrameList::Slice& aFrames,
|
|
|
|
nsIFrame* aParentFrame)
|
|
|
|
{
|
2013-07-20 12:14:25 -07:00
|
|
|
RestyleManager* restyleManager = aPresContext->RestyleManager();
|
2009-12-22 15:42:45 -08:00
|
|
|
|
|
|
|
for (nsFrameList::Enumerator e(aFrames); !e.AtEnd(); e.Next()) {
|
|
|
|
NS_ASSERTION(e.get()->GetParent() == aParentFrame, "Bogus parentage");
|
2013-07-20 12:14:25 -07:00
|
|
|
restyleManager->ReparentStyleContext(e.get());
|
2014-04-07 22:13:28 -07:00
|
|
|
nsLayoutUtils::MarkDescendantsDirty(e.get());
|
2009-12-22 15:42:45 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-12 17:47:52 -07:00
|
|
|
void
|
2007-03-22 10:30:00 -07:00
|
|
|
nsInlineFrame::Reflow(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsInlineFrame");
|
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aMetrics, aStatus);
|
2012-07-30 07:20:58 -07:00
|
|
|
if (nullptr == aReflowState.mLineLayout) {
|
2014-05-12 17:47:52 -07:00
|
|
|
NS_ERROR("must have non-null aReflowState.mLineLayout");
|
|
|
|
return;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2012-09-07 17:33:58 -07:00
|
|
|
if (IsFrameTreeTooDeep(aReflowState, aMetrics, aStatus)) {
|
2014-05-12 17:47:52 -07:00
|
|
|
return;
|
2012-09-07 17:33:58 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool lazilySetParentPointer = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-04-22 18:45:26 -07:00
|
|
|
nsIFrame* lineContainer = aReflowState.mLineLayout->LineContainerFrame();
|
2007-04-20 17:42:58 -07:00
|
|
|
|
|
|
|
// Check for an overflow list with our prev-in-flow
|
2007-03-22 10:30:00 -07:00
|
|
|
nsInlineFrame* prevInFlow = (nsInlineFrame*)GetPrevInFlow();
|
2013-04-01 08:26:02 -07:00
|
|
|
if (prevInFlow) {
|
|
|
|
AutoFrameListPtr prevOverflowFrames(aPresContext,
|
|
|
|
prevInFlow->StealOverflowFrames());
|
2007-03-22 10:30:00 -07:00
|
|
|
if (prevOverflowFrames) {
|
|
|
|
// When pushing and pulling frames we need to check for whether any
|
|
|
|
// views need to be reparented.
|
2014-02-06 14:07:47 -08:00
|
|
|
nsContainerFrame::ReparentFrameViewList(*prevOverflowFrames, prevInFlow,
|
|
|
|
this);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-02-07 00:34:27 -08:00
|
|
|
// Check if we should do the lazilySetParentPointer optimization.
|
|
|
|
// Only do it in simple cases where we're being reflowed for the
|
|
|
|
// first time, nothing (e.g. bidi resolution) has already given
|
|
|
|
// us children, and there's no next-in-flow, so all our frames
|
|
|
|
// will be taken from prevOverflowFrames.
|
|
|
|
if ((GetStateBits() & NS_FRAME_FIRST_REFLOW) && mFrames.IsEmpty() &&
|
|
|
|
!GetNextInFlow()) {
|
2009-07-28 05:51:09 -07:00
|
|
|
// If our child list is empty, just put the new frames into it.
|
2007-03-22 10:30:00 -07:00
|
|
|
// Note that we don't set the parent pointer for the new frames. Instead wait
|
|
|
|
// to do this until we actually reflow the frame. If the overflow list contains
|
|
|
|
// thousands of frames this is a big performance issue (see bug #5588)
|
2009-07-28 05:53:20 -07:00
|
|
|
mFrames.SetFrames(*prevOverflowFrames);
|
2011-10-17 07:59:28 -07:00
|
|
|
lazilySetParentPointer = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
} else {
|
2007-04-20 17:42:58 -07:00
|
|
|
// Assign all floats to our block if necessary
|
|
|
|
if (lineContainer && lineContainer->GetPrevContinuation()) {
|
2009-07-28 05:51:09 -07:00
|
|
|
ReparentFloatsForInlineChild(lineContainer,
|
|
|
|
prevOverflowFrames->FirstChild(),
|
2011-10-17 07:59:28 -07:00
|
|
|
true);
|
2007-04-20 17:42:58 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
// Insert the new frames at the beginning of the child list
|
|
|
|
// and set their parent pointer
|
2009-12-22 15:42:45 -08:00
|
|
|
const nsFrameList::Slice& newFrames =
|
2012-07-30 07:20:58 -07:00
|
|
|
mFrames.InsertFrames(this, nullptr, *prevOverflowFrames);
|
2009-12-22 15:42:45 -08:00
|
|
|
// If our prev in flow was under the first continuation of a first-line
|
|
|
|
// frame then we need to reparent the style contexts to remove the
|
|
|
|
// the special first-line styling. In the lazilySetParentPointer case
|
|
|
|
// we reparent the style contexts when we set their parents in
|
|
|
|
// nsInlineFrame::ReflowFrames and nsInlineFrame::ReflowInlineFrame.
|
|
|
|
if (aReflowState.mLineLayout->GetInFirstLine()) {
|
2010-04-01 23:07:43 -07:00
|
|
|
ReparentChildListStyle(aPresContext, newFrames, this);
|
2009-12-22 15:42:45 -08:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// It's also possible that we have an overflow list for ourselves
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (GetStateBits() & NS_FRAME_FIRST_REFLOW) {
|
|
|
|
// If it's our initial reflow, then we should not have an overflow list.
|
|
|
|
// However, add an assertion in case we get reflowed more than once with
|
|
|
|
// the initial reflow reason
|
2009-07-28 05:51:09 -07:00
|
|
|
nsFrameList* overflowFrames = GetOverflowFrames();
|
|
|
|
NS_ASSERTION(!overflowFrames || overflowFrames->IsEmpty(),
|
|
|
|
"overflow list is not empty for initial reflow");
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (!(GetStateBits() & NS_FRAME_FIRST_REFLOW)) {
|
2013-12-17 05:30:24 -08:00
|
|
|
DrainFlags flags =
|
|
|
|
lazilySetParentPointer ? eDontReparentFrames : DrainFlags(0);
|
|
|
|
if (aReflowState.mLineLayout->GetInFirstLine()) {
|
|
|
|
flags = DrainFlags(flags | eInFirstLine);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2013-12-17 05:30:24 -08:00
|
|
|
DrainSelfOverflowListInternal(flags, lineContainer);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set our own reflow state (additional state above and beyond
|
|
|
|
// aReflowState)
|
|
|
|
InlineReflowState irs;
|
2012-07-30 07:20:58 -07:00
|
|
|
irs.mPrevFrame = nullptr;
|
2007-04-20 17:42:58 -07:00
|
|
|
irs.mLineContainer = lineContainer;
|
2009-10-26 18:43:56 -07:00
|
|
|
irs.mLineLayout = aReflowState.mLineLayout;
|
2007-03-22 10:30:00 -07:00
|
|
|
irs.mNextInFlow = (nsInlineFrame*) GetNextInFlow();
|
|
|
|
irs.mSetParentPointer = lazilySetParentPointer;
|
|
|
|
|
|
|
|
if (mFrames.IsEmpty()) {
|
|
|
|
// Try to pull over one frame before starting so that we know
|
|
|
|
// whether we have an anonymous block or not.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool complete;
|
2007-03-22 10:30:00 -07:00
|
|
|
(void) PullOneFrame(aPresContext, irs, &complete);
|
|
|
|
}
|
|
|
|
|
2014-05-12 17:47:52 -07:00
|
|
|
ReflowFrames(aPresContext, aReflowState, irs, aMetrics, aStatus);
|
2011-04-29 16:02:33 -07:00
|
|
|
|
|
|
|
ReflowAbsoluteFrames(aPresContext, aMetrics, aReflowState, aStatus);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Note: the line layout code will properly compute our
|
2009-04-05 17:31:50 -07:00
|
|
|
// overflow-rect state for us.
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aMetrics);
|
|
|
|
}
|
|
|
|
|
2013-12-17 05:30:24 -08:00
|
|
|
bool
|
|
|
|
nsInlineFrame::DrainSelfOverflowListInternal(DrainFlags aFlags,
|
|
|
|
nsIFrame* aLineContainer)
|
|
|
|
{
|
|
|
|
AutoFrameListPtr overflowFrames(PresContext(), StealOverflowFrames());
|
|
|
|
if (overflowFrames) {
|
|
|
|
NS_ASSERTION(mFrames.NotEmpty(), "overflow list w/o frames");
|
|
|
|
// The frames on our own overflowlist may have been pushed by a
|
|
|
|
// previous lazilySetParentPointer Reflow so we need to ensure the
|
|
|
|
// correct parent pointer. This is sometimes skipped by Reflow.
|
|
|
|
if (!(aFlags & eDontReparentFrames)) {
|
|
|
|
nsIFrame* firstChild = overflowFrames->FirstChild();
|
|
|
|
if (aLineContainer && aLineContainer->GetPrevContinuation()) {
|
|
|
|
ReparentFloatsForInlineChild(aLineContainer, firstChild, true);
|
|
|
|
}
|
|
|
|
const bool inFirstLine = (aFlags & eInFirstLine);
|
|
|
|
RestyleManager* restyleManager = PresContext()->RestyleManager();
|
|
|
|
for (nsIFrame* f = firstChild; f; f = f->GetNextSibling()) {
|
|
|
|
f->SetParent(this);
|
|
|
|
if (inFirstLine) {
|
|
|
|
restyleManager->ReparentStyleContext(f);
|
2014-04-07 22:13:28 -07:00
|
|
|
nsLayoutUtils::MarkDescendantsDirty(f);
|
2013-12-17 05:30:24 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool result = !overflowFrames->IsEmpty();
|
|
|
|
mFrames.AppendFrames(nullptr, *overflowFrames);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ bool
|
|
|
|
nsInlineFrame::DrainSelfOverflowList()
|
|
|
|
{
|
|
|
|
nsIFrame* lineContainer = nsLayoutUtils::FindNearestBlockAncestor(this);
|
|
|
|
// Add the eInFirstLine flag if we have a ::first-line ancestor frame.
|
|
|
|
// No need to look further than the nearest line container though.
|
|
|
|
DrainFlags flags = DrainFlags(0);
|
|
|
|
for (nsIFrame* p = GetParent(); p != lineContainer; p = p->GetParent()) {
|
|
|
|
if (p->GetType() == nsGkAtoms::lineFrame) {
|
|
|
|
flags = DrainFlags(flags | eInFirstLine);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return DrainSelfOverflowListInternal(flags, lineContainer);
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
/* virtual */ bool
|
2007-03-22 10:30:00 -07:00
|
|
|
nsInlineFrame::CanContinueTextRun() const
|
|
|
|
{
|
|
|
|
// We can continue a text run through an inline frame
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2009-07-24 06:32:32 -07:00
|
|
|
/* virtual */ void
|
|
|
|
nsInlineFrame::PullOverflowsFromPrevInFlow()
|
|
|
|
{
|
|
|
|
nsInlineFrame* prevInFlow = static_cast<nsInlineFrame*>(GetPrevInFlow());
|
|
|
|
if (prevInFlow) {
|
2013-04-01 08:26:02 -07:00
|
|
|
nsPresContext* presContext = PresContext();
|
|
|
|
AutoFrameListPtr prevOverflowFrames(presContext,
|
|
|
|
prevInFlow->StealOverflowFrames());
|
2009-07-24 06:32:32 -07:00
|
|
|
if (prevOverflowFrames) {
|
|
|
|
// Assume that our prev-in-flow has the same line container that we do.
|
2014-02-06 14:07:47 -08:00
|
|
|
nsContainerFrame::ReparentFrameViewList(*prevOverflowFrames, prevInFlow,
|
|
|
|
this);
|
2012-07-30 07:20:58 -07:00
|
|
|
mFrames.InsertFrames(this, nullptr, *prevOverflowFrames);
|
2009-07-24 06:32:32 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-12 17:47:52 -07:00
|
|
|
void
|
2007-03-22 10:30:00 -07:00
|
|
|
nsInlineFrame::ReflowFrames(nsPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
InlineReflowState& irs,
|
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
|
|
|
|
nsLineLayout* lineLayout = aReflowState.mLineLayout;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool inFirstLine = aReflowState.mLineLayout->GetInFirstLine();
|
2013-07-20 12:14:25 -07:00
|
|
|
RestyleManager* restyleManager = aPresContext->RestyleManager();
|
2014-06-05 02:39:36 -07:00
|
|
|
WritingMode frameWM = aReflowState.GetWritingMode();
|
|
|
|
WritingMode lineWM = aReflowState.mLineLayout->mRootSpan->mWritingMode;
|
|
|
|
LogicalMargin framePadding = aReflowState.ComputedLogicalBorderPadding();
|
2014-03-11 13:23:50 -07:00
|
|
|
nscoord startEdge = 0;
|
2014-05-05 10:55:54 -07:00
|
|
|
const bool boxDecorationBreakClone =
|
|
|
|
MOZ_UNLIKELY(StyleBorder()->mBoxDecorationBreak ==
|
|
|
|
NS_STYLE_BOX_DECORATION_BREAK_CLONE);
|
2009-05-11 19:04:58 -07:00
|
|
|
// Don't offset by our start borderpadding if we have a prev continuation or
|
2014-05-05 10:55:54 -07:00
|
|
|
// if we're in a part of an {ib} split other than the first one. For
|
|
|
|
// box-decoration-break:clone we always offset our start since all
|
|
|
|
// continuations have border/padding.
|
|
|
|
if ((!GetPrevContinuation() && !FrameIsNonFirstInIBSplit()) ||
|
|
|
|
boxDecorationBreakClone) {
|
2014-06-05 02:39:36 -07:00
|
|
|
startEdge = framePadding.IStart(frameWM);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2014-03-11 13:23:50 -07:00
|
|
|
nscoord availableISize = aReflowState.AvailableISize();
|
|
|
|
NS_ASSERTION(availableISize != NS_UNCONSTRAINEDSIZE,
|
2007-12-12 13:51:00 -08:00
|
|
|
"should no longer use available widths");
|
2014-03-11 13:23:50 -07:00
|
|
|
// Subtract off inline axis border+padding from availableISize
|
|
|
|
availableISize -= startEdge;
|
2014-06-05 02:39:36 -07:00
|
|
|
availableISize -= framePadding.IEnd(frameWM);
|
2014-03-11 13:23:50 -07:00
|
|
|
lineLayout->BeginSpan(this, &aReflowState, startEdge,
|
|
|
|
startEdge + availableISize, &mBaseline);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-02-06 17:13:34 -08:00
|
|
|
// First reflow our principal children.
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIFrame* frame = mFrames.FirstChild();
|
2011-09-28 23:19:26 -07:00
|
|
|
bool done = false;
|
2013-02-06 17:13:34 -08:00
|
|
|
while (frame) {
|
|
|
|
// Check if we should lazily set the child frame's parent pointer.
|
2007-03-22 10:30:00 -07:00
|
|
|
if (irs.mSetParentPointer) {
|
2011-09-28 23:19:26 -07:00
|
|
|
bool havePrevBlock =
|
2007-04-20 17:42:58 -07:00
|
|
|
irs.mLineContainer && irs.mLineContainer->GetPrevContinuation();
|
2012-09-07 17:33:58 -07:00
|
|
|
nsIFrame* child = frame;
|
|
|
|
do {
|
|
|
|
// If our block is the first in flow, then any floats under the pulled
|
|
|
|
// frame must already belong to our block.
|
2007-04-20 17:42:58 -07:00
|
|
|
if (havePrevBlock) {
|
2012-09-07 17:33:58 -07:00
|
|
|
// This has to happen before we update frame's parent; we need to
|
|
|
|
// know frame's ancestry under its old block.
|
|
|
|
// The blockChildren.ContainsFrame check performed by
|
|
|
|
// ReparentFloatsForInlineChild here may be slow, but we can't
|
|
|
|
// easily avoid it because we don't know where 'frame' originally
|
|
|
|
// came from. If we really really have to optimize this we could
|
|
|
|
// cache whether frame->GetParent() is under its containing blocks
|
|
|
|
// overflowList or not.
|
|
|
|
ReparentFloatsForInlineChild(irs.mLineContainer, child, false);
|
2007-04-20 17:42:58 -07:00
|
|
|
}
|
2012-09-07 17:33:58 -07:00
|
|
|
child->SetParent(this);
|
2009-12-22 15:42:45 -08:00
|
|
|
if (inFirstLine) {
|
2013-07-20 12:14:25 -07:00
|
|
|
restyleManager->ReparentStyleContext(child);
|
2014-04-07 22:13:28 -07:00
|
|
|
nsLayoutUtils::MarkDescendantsDirty(child);
|
2009-12-22 15:42:45 -08:00
|
|
|
}
|
2012-09-07 17:33:58 -07:00
|
|
|
// We also need to do the same for |frame|'s next-in-flows that are in
|
|
|
|
// the sibling list. Otherwise, if we reflow |frame| and it's complete
|
|
|
|
// we'll crash when trying to delete its next-in-flow.
|
|
|
|
// This scenario doesn't happen often, but it can happen.
|
|
|
|
nsIFrame* nextSibling = child->GetNextSibling();
|
|
|
|
child = child->GetNextInFlow();
|
2012-10-26 06:32:10 -07:00
|
|
|
if (MOZ_UNLIKELY(child)) {
|
2012-09-07 17:33:58 -07:00
|
|
|
while (child != nextSibling && nextSibling) {
|
|
|
|
nextSibling = nextSibling->GetNextSibling();
|
|
|
|
}
|
|
|
|
if (!nextSibling) {
|
|
|
|
child = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(!child || mFrames.ContainsFrame(child));
|
|
|
|
} while (child);
|
2008-12-07 10:21:40 -08:00
|
|
|
|
|
|
|
// Fix the parent pointer for ::first-letter child frame next-in-flows,
|
|
|
|
// so nsFirstLetterFrame::Reflow can destroy them safely (bug 401042).
|
|
|
|
nsIFrame* realFrame = nsPlaceholderFrame::GetRealFrameFor(frame);
|
|
|
|
if (realFrame->GetType() == nsGkAtoms::letterFrame) {
|
2011-08-24 13:54:30 -07:00
|
|
|
nsIFrame* child = realFrame->GetFirstPrincipalChild();
|
2008-12-07 10:21:40 -08:00
|
|
|
if (child) {
|
|
|
|
NS_ASSERTION(child->GetType() == nsGkAtoms::textFrame,
|
|
|
|
"unexpected frame type");
|
|
|
|
nsIFrame* nextInFlow = child->GetNextInFlow();
|
|
|
|
for ( ; nextInFlow; nextInFlow = nextInFlow->GetNextInFlow()) {
|
|
|
|
NS_ASSERTION(nextInFlow->GetType() == nsGkAtoms::textFrame,
|
|
|
|
"unexpected frame type");
|
|
|
|
if (mFrames.ContainsFrame(nextInFlow)) {
|
|
|
|
nextInFlow->SetParent(this);
|
2009-12-22 15:42:45 -08:00
|
|
|
if (inFirstLine) {
|
2013-07-20 12:14:25 -07:00
|
|
|
restyleManager->ReparentStyleContext(nextInFlow);
|
2014-04-07 22:13:28 -07:00
|
|
|
nsLayoutUtils::MarkDescendantsDirty(nextInFlow);
|
2009-12-22 15:42:45 -08:00
|
|
|
}
|
2008-12-07 10:21:40 -08:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
#ifdef DEBUG
|
|
|
|
// Once we find a next-in-flow that isn't ours none of the
|
|
|
|
// remaining next-in-flows should be either.
|
|
|
|
for ( ; nextInFlow; nextInFlow = nextInFlow->GetNextInFlow()) {
|
|
|
|
NS_ASSERTION(!mFrames.ContainsFrame(nextInFlow),
|
|
|
|
"unexpected letter frame flow");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
2012-09-07 17:33:58 -07:00
|
|
|
MOZ_ASSERT(frame->GetParent() == this);
|
|
|
|
|
|
|
|
if (!done) {
|
2013-02-06 17:13:34 -08:00
|
|
|
bool reflowingFirstLetter = lineLayout->GetFirstLetterStyleOK();
|
2014-05-12 17:47:52 -07:00
|
|
|
ReflowInlineFrame(aPresContext, aReflowState, irs, frame, aStatus);
|
|
|
|
done = NS_INLINE_IS_BREAK(aStatus) ||
|
2012-09-07 17:33:58 -07:00
|
|
|
(!reflowingFirstLetter && NS_FRAME_IS_NOT_COMPLETE(aStatus));
|
|
|
|
if (done) {
|
|
|
|
if (!irs.mSetParentPointer) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// Keep reparenting the remaining siblings, but don't reflow them.
|
|
|
|
nsFrameList* pushedFrames = GetOverflowFrames();
|
|
|
|
if (pushedFrames && pushedFrames->FirstChild() == frame) {
|
|
|
|
// Don't bother if |frame| was pushed to our overflow list.
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
irs.mPrevFrame = frame;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
frame = frame->GetNextSibling();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Attempt to pull frames from our next-in-flow until we can't
|
2012-09-07 17:33:58 -07:00
|
|
|
if (!done && GetNextInFlow()) {
|
|
|
|
while (true) {
|
2011-09-28 23:19:26 -07:00
|
|
|
bool reflowingFirstLetter = lineLayout->GetFirstLetterStyleOK();
|
|
|
|
bool isComplete;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!frame) { // Could be non-null if we pulled a first-letter frame and
|
|
|
|
// it created a continuation, since we don't push those.
|
|
|
|
frame = PullOneFrame(aPresContext, irs, &isComplete);
|
|
|
|
}
|
|
|
|
#ifdef NOISY_PUSHING
|
|
|
|
printf("%p pulled up %p\n", this, frame);
|
|
|
|
#endif
|
2012-07-30 07:20:58 -07:00
|
|
|
if (nullptr == frame) {
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!isComplete) {
|
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2014-05-12 17:47:52 -07:00
|
|
|
ReflowInlineFrame(aPresContext, aReflowState, irs, frame, aStatus);
|
|
|
|
if (NS_INLINE_IS_BREAK(aStatus) ||
|
2007-03-22 10:30:00 -07:00
|
|
|
(!reflowingFirstLetter && NS_FRAME_IS_NOT_COMPLETE(aStatus))) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
irs.mPrevFrame = frame;
|
|
|
|
frame = frame->GetNextSibling();
|
|
|
|
}
|
|
|
|
}
|
2012-09-07 17:33:58 -07:00
|
|
|
|
|
|
|
NS_ASSERTION(!NS_FRAME_IS_COMPLETE(aStatus) || !GetOverflowFrames(),
|
|
|
|
"We can't be complete AND have overflow frames!");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// If after reflowing our children they take up no area then make
|
|
|
|
// sure that we don't either.
|
|
|
|
//
|
|
|
|
// Note: CSS demands that empty inline elements still affect the
|
|
|
|
// line-height calculations. However, continuations of an inline
|
|
|
|
// that are empty we force to empty so that things like collapsed
|
|
|
|
// whitespace in an inline element don't affect the line-height.
|
2014-06-05 02:39:36 -07:00
|
|
|
aMetrics.ISize(lineWM) = lineLayout->EndSpan(this);
|
2007-05-05 10:06:04 -07:00
|
|
|
|
2009-05-11 19:04:58 -07:00
|
|
|
// Compute final width.
|
|
|
|
|
2014-06-05 02:39:36 -07:00
|
|
|
// XXX Note that that the padding start and end are in the frame's
|
|
|
|
// writing mode, but the metrics' inline-size is in the line's
|
|
|
|
// writing mode. This makes sense if the line and frame are both
|
|
|
|
// vertical or both horizontal, but what should happen with
|
|
|
|
// orthogonal inlines?
|
|
|
|
|
2009-05-11 19:04:58 -07:00
|
|
|
// Make sure to not include our start border and padding if we have a prev
|
2009-09-18 11:00:21 -07:00
|
|
|
// continuation or if we're in a part of an {ib} split other than the first
|
2014-05-05 10:55:54 -07:00
|
|
|
// one. For box-decoration-break:clone we always include our start border
|
|
|
|
// and padding since all continuations have them.
|
|
|
|
if ((!GetPrevContinuation() && !FrameIsNonFirstInIBSplit()) ||
|
|
|
|
boxDecorationBreakClone) {
|
2014-06-05 02:39:36 -07:00
|
|
|
aMetrics.ISize(lineWM) += framePadding.IStart(frameWM);
|
2007-05-05 10:06:04 -07:00
|
|
|
}
|
2009-05-11 19:04:58 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We want to only apply the end border and padding if we're the last
|
2009-09-18 11:00:21 -07:00
|
|
|
* continuation and either not in an {ib} split or the last part of it. To
|
|
|
|
* be the last continuation we have to be complete (so that we won't get a
|
|
|
|
* next-in-flow) and have no non-fluid continuations on our continuation
|
2014-05-05 10:55:54 -07:00
|
|
|
* chain. For box-decoration-break:clone we always apply the end border and
|
|
|
|
* padding since all continuations have them.
|
2009-05-11 19:04:58 -07:00
|
|
|
*/
|
2014-05-05 10:55:54 -07:00
|
|
|
if ((NS_FRAME_IS_COMPLETE(aStatus) &&
|
|
|
|
!LastInFlow()->GetNextContinuation() &&
|
|
|
|
!FrameIsNonLastInIBSplit()) ||
|
|
|
|
boxDecorationBreakClone) {
|
2014-06-05 02:39:36 -07:00
|
|
|
aMetrics.ISize(lineWM) += framePadding.IEnd(frameWM);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-08-14 10:08:04 -07:00
|
|
|
nsRefPtr<nsFontMetrics> fm;
|
2012-05-20 22:18:28 -07:00
|
|
|
float inflation = nsLayoutUtils::FontSizeInflationFor(this);
|
2011-11-23 18:48:23 -08:00
|
|
|
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm), inflation);
|
2011-08-14 10:08:04 -07:00
|
|
|
aReflowState.rendContext->SetFont(fm);
|
2007-05-05 10:06:04 -07:00
|
|
|
|
|
|
|
if (fm) {
|
|
|
|
// Compute final height of the frame.
|
|
|
|
//
|
|
|
|
// Do things the standard css2 way -- though it's hard to find it
|
|
|
|
// in the css2 spec! It's actually found in the css1 spec section
|
|
|
|
// 4.4 (you will have to read between the lines to really see
|
|
|
|
// it).
|
|
|
|
//
|
|
|
|
// The height of our box is the sum of our font size plus the top
|
|
|
|
// and bottom border and padding. The height of children do not
|
|
|
|
// affect our height.
|
2014-06-11 02:45:31 -07:00
|
|
|
aMetrics.SetBlockStartAscent(fm->MaxAscent());
|
2013-12-27 09:59:52 -08:00
|
|
|
aMetrics.Height() = fm->MaxHeight();
|
2007-05-05 10:06:04 -07:00
|
|
|
} else {
|
|
|
|
NS_WARNING("Cannot get font metrics - defaulting sizes to 0");
|
2014-06-11 02:45:31 -07:00
|
|
|
aMetrics.SetBlockStartAscent(aMetrics.Height() = 0);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2014-06-11 02:45:31 -07:00
|
|
|
aMetrics.SetBlockStartAscent(aMetrics.BlockStartAscent() +
|
|
|
|
framePadding.BStart(frameWM));
|
2013-12-27 09:59:52 -08:00
|
|
|
aMetrics.Height() += aReflowState.ComputedPhysicalBorderPadding().top +
|
2013-12-27 09:59:21 -08:00
|
|
|
aReflowState.ComputedPhysicalBorderPadding().bottom;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// For now our overflow area is zero. The real value will be
|
2008-02-16 07:31:27 -08:00
|
|
|
// computed in |nsLineLayout::RelativePositionFrames|.
|
2010-10-06 21:25:46 -07:00
|
|
|
aMetrics.mOverflowAreas.Clear();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifdef NOISY_FINAL_SIZE
|
|
|
|
ListTag(stdout);
|
|
|
|
printf(": metrics=%d,%d ascent=%d\n",
|
2013-12-27 09:59:52 -08:00
|
|
|
aMetrics.Width(), aMetrics.Height(), aMetrics.TopAscent());
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-05-12 17:47:52 -07:00
|
|
|
void
|
2007-03-22 10:30:00 -07:00
|
|
|
nsInlineFrame::ReflowInlineFrame(nsPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
InlineReflowState& irs,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
nsLineLayout* lineLayout = aReflowState.mLineLayout;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool reflowingFirstLetter = lineLayout->GetFirstLetterStyleOK();
|
|
|
|
bool pushedFrame;
|
2014-05-12 17:47:52 -07:00
|
|
|
lineLayout->ReflowFrame(aFrame, aStatus, nullptr, pushedFrame);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-06-29 07:32:03 -07:00
|
|
|
if (NS_INLINE_IS_BREAK_BEFORE(aStatus)) {
|
|
|
|
if (aFrame != mFrames.FirstChild()) {
|
|
|
|
// Change break-before status into break-after since we have
|
|
|
|
// already placed at least one child frame. This preserves the
|
|
|
|
// break-type so that it can be propagated upward.
|
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE |
|
|
|
|
NS_INLINE_BREAK | NS_INLINE_BREAK_AFTER |
|
|
|
|
(aStatus & NS_INLINE_BREAK_TYPE_MASK);
|
|
|
|
PushFrames(aPresContext, aFrame, irs.mPrevFrame, irs);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
else {
|
2010-06-29 07:32:03 -07:00
|
|
|
// Preserve reflow status when breaking-before our first child
|
|
|
|
// and propagate it upward without modification.
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2014-05-12 17:47:52 -07:00
|
|
|
return;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2010-06-29 07:32:03 -07:00
|
|
|
|
|
|
|
// Create a next-in-flow if needed.
|
|
|
|
if (!NS_FRAME_IS_FULLY_COMPLETE(aStatus)) {
|
|
|
|
nsIFrame* newFrame;
|
2014-05-12 17:47:52 -07:00
|
|
|
nsresult rv = CreateNextInFlow(aFrame, newFrame);
|
2010-06-29 07:32:03 -07:00
|
|
|
if (NS_FAILED(rv)) {
|
2014-05-12 17:47:52 -07:00
|
|
|
return;
|
2010-06-29 07:32:03 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_INLINE_IS_BREAK_AFTER(aStatus)) {
|
|
|
|
nsIFrame* nextFrame = aFrame->GetNextSibling();
|
|
|
|
if (nextFrame) {
|
|
|
|
NS_FRAME_SET_INCOMPLETE(aStatus);
|
|
|
|
PushFrames(aPresContext, nextFrame, aFrame, irs);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
else {
|
2010-06-29 07:32:03 -07:00
|
|
|
// We must return an incomplete status if there are more child
|
|
|
|
// frames remaining in a next-in-flow that follows this frame.
|
|
|
|
nsInlineFrame* nextInFlow = static_cast<nsInlineFrame*>(GetNextInFlow());
|
|
|
|
while (nextInFlow) {
|
|
|
|
if (nextInFlow->mFrames.NotEmpty()) {
|
|
|
|
NS_FRAME_SET_INCOMPLETE(aStatus);
|
|
|
|
break;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2010-06-29 07:32:03 -07:00
|
|
|
nextInFlow = static_cast<nsInlineFrame*>(nextInFlow->GetNextInFlow());
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
2014-05-12 17:47:52 -07:00
|
|
|
return;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2010-06-29 07:32:03 -07:00
|
|
|
|
|
|
|
if (!NS_FRAME_IS_FULLY_COMPLETE(aStatus) && !reflowingFirstLetter) {
|
|
|
|
nsIFrame* nextFrame = aFrame->GetNextSibling();
|
|
|
|
if (nextFrame) {
|
|
|
|
PushFrames(aPresContext, nextFrame, aFrame, irs);
|
|
|
|
}
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame*
|
|
|
|
nsInlineFrame::PullOneFrame(nsPresContext* aPresContext,
|
|
|
|
InlineReflowState& irs,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool* aIsComplete)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-09-28 23:19:26 -07:00
|
|
|
bool isComplete = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
nsIFrame* frame = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsInlineFrame* nextInFlow = irs.mNextInFlow;
|
2013-04-01 08:26:02 -07:00
|
|
|
while (nextInFlow) {
|
2007-04-20 17:42:58 -07:00
|
|
|
frame = nextInFlow->mFrames.FirstChild();
|
2010-01-27 20:12:37 -08:00
|
|
|
if (!frame) {
|
2012-09-07 17:33:58 -07:00
|
|
|
// The nextInFlow's principal list has no frames, try its overflow list.
|
|
|
|
nsFrameList* overflowFrames = nextInFlow->GetOverflowFrames();
|
2010-01-27 20:12:37 -08:00
|
|
|
if (overflowFrames) {
|
2013-04-01 08:26:02 -07:00
|
|
|
frame = overflowFrames->RemoveFirstChild();
|
|
|
|
if (overflowFrames->IsEmpty()) {
|
2012-09-07 17:33:58 -07:00
|
|
|
// We're stealing the only frame - delete the overflow list.
|
2014-02-06 14:07:47 -08:00
|
|
|
nextInFlow->DestroyOverflowList();
|
2012-09-07 17:33:58 -07:00
|
|
|
} else {
|
|
|
|
// We leave the remaining frames on the overflow list (rather than
|
|
|
|
// putting them on nextInFlow's principal list) so we don't have to
|
|
|
|
// set up the parent for them.
|
|
|
|
}
|
|
|
|
// ReparentFloatsForInlineChild needs it to be on a child list -
|
|
|
|
// we remove it again below.
|
|
|
|
nextInFlow->mFrames.SetFrames(frame);
|
2010-01-27 20:12:37 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-01 08:26:02 -07:00
|
|
|
if (frame) {
|
2007-04-20 17:42:58 -07:00
|
|
|
// If our block has no next continuation, then any floats belonging to
|
|
|
|
// the pulled frame must belong to our block already. This check ensures
|
|
|
|
// we do no extra work in the common non-vertical-breaking case.
|
|
|
|
if (irs.mLineContainer && irs.mLineContainer->GetNextContinuation()) {
|
|
|
|
// The blockChildren.ContainsFrame check performed by
|
|
|
|
// ReparentFloatsForInlineChild will be fast because frame's ancestor
|
|
|
|
// will be the first child of its containing block.
|
2011-10-17 07:59:28 -07:00
|
|
|
ReparentFloatsForInlineChild(irs.mLineContainer, frame, false);
|
2007-04-20 17:42:58 -07:00
|
|
|
}
|
|
|
|
nextInFlow->mFrames.RemoveFirstChild();
|
2012-09-07 17:33:58 -07:00
|
|
|
// nsFirstLineFrame::PullOneFrame calls ReparentStyleContext.
|
2009-12-18 01:02:26 -08:00
|
|
|
|
2007-04-20 17:42:58 -07:00
|
|
|
mFrames.InsertFrame(this, irs.mPrevFrame, frame);
|
2011-10-17 07:59:28 -07:00
|
|
|
isComplete = false;
|
2009-10-26 18:43:56 -07:00
|
|
|
if (irs.mLineLayout) {
|
|
|
|
irs.mLineLayout->SetDirtyNextLine();
|
|
|
|
}
|
2014-02-06 14:07:47 -08:00
|
|
|
nsContainerFrame::ReparentFrameView(frame, nextInFlow, this);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
}
|
2013-04-01 08:26:02 -07:00
|
|
|
nextInFlow = static_cast<nsInlineFrame*>(nextInFlow->GetNextInFlow());
|
2007-03-22 10:30:00 -07:00
|
|
|
irs.mNextInFlow = nextInFlow;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aIsComplete = isComplete;
|
|
|
|
return frame;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsInlineFrame::PushFrames(nsPresContext* aPresContext,
|
|
|
|
nsIFrame* aFromChild,
|
2009-10-26 18:43:56 -07:00
|
|
|
nsIFrame* aPrevSibling,
|
|
|
|
InlineReflowState& aState)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-09-18 04:09:35 -07:00
|
|
|
NS_PRECONDITION(aFromChild, "null pointer");
|
|
|
|
NS_PRECONDITION(aPrevSibling, "pushing first child");
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_PRECONDITION(aPrevSibling->GetNextSibling() == aFromChild, "bad prev sibling");
|
|
|
|
|
|
|
|
#ifdef NOISY_PUSHING
|
2009-09-18 04:09:35 -07:00
|
|
|
printf("%p pushing aFromChild %p, disconnecting from prev sib %p\n",
|
|
|
|
this, aFromChild, aPrevSibling);
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// Add the frames to our overflow list (let our next in flow drain
|
|
|
|
// our overflow list when it is ready)
|
2014-02-06 14:07:47 -08:00
|
|
|
SetOverflowFrames(mFrames.RemoveFramesAfter(aPrevSibling));
|
2009-10-26 18:43:56 -07:00
|
|
|
if (aState.mLineLayout) {
|
|
|
|
aState.mLineLayout->SetDirtyNextLine();
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-08-09 00:09:40 -07:00
|
|
|
int
|
2014-03-13 00:39:33 -07:00
|
|
|
nsInlineFrame::GetLogicalSkipSides(const nsHTMLReflowState* aReflowState) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2014-05-05 10:55:54 -07:00
|
|
|
if (MOZ_UNLIKELY(StyleBorder()->mBoxDecorationBreak ==
|
|
|
|
NS_STYLE_BOX_DECORATION_BREAK_CLONE)) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-08-09 00:09:40 -07:00
|
|
|
int skip = 0;
|
2014-03-13 00:39:33 -07:00
|
|
|
if (!IsFirst()) {
|
2007-03-22 10:30:00 -07:00
|
|
|
nsInlineFrame* prev = (nsInlineFrame*) GetPrevContinuation();
|
|
|
|
if ((GetStateBits() & NS_INLINE_FRAME_BIDI_VISUAL_STATE_IS_SET) ||
|
|
|
|
(prev && (prev->mRect.height || prev->mRect.width))) {
|
2014-03-13 00:39:33 -07:00
|
|
|
// Prev continuation is not empty therefore we don't render our start
|
2007-03-22 10:30:00 -07:00
|
|
|
// border edge.
|
2014-03-13 00:39:33 -07:00
|
|
|
skip |= LOGICAL_SIDE_I_START;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
else {
|
2014-03-13 00:39:33 -07:00
|
|
|
// If the prev continuation is empty, then go ahead and let our start
|
2007-03-22 10:30:00 -07:00
|
|
|
// edge border render.
|
|
|
|
}
|
|
|
|
}
|
2014-03-13 00:39:33 -07:00
|
|
|
if (!IsLast()) {
|
2007-03-22 10:30:00 -07:00
|
|
|
nsInlineFrame* next = (nsInlineFrame*) GetNextContinuation();
|
|
|
|
if ((GetStateBits() & NS_INLINE_FRAME_BIDI_VISUAL_STATE_IS_SET) ||
|
|
|
|
(next && (next->mRect.height || next->mRect.width))) {
|
2014-03-13 00:39:33 -07:00
|
|
|
// Next continuation is not empty therefore we don't render our end
|
2007-03-22 10:30:00 -07:00
|
|
|
// border edge.
|
2014-03-13 00:39:33 -07:00
|
|
|
skip |= LOGICAL_SIDE_I_END;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
else {
|
2014-03-13 00:39:33 -07:00
|
|
|
// If the next continuation is empty, then go ahead and let our end
|
2007-03-22 10:30:00 -07:00
|
|
|
// edge border render.
|
|
|
|
}
|
|
|
|
}
|
2009-05-11 19:04:58 -07:00
|
|
|
|
2014-02-06 17:45:28 -08:00
|
|
|
if (GetStateBits() & NS_FRAME_PART_OF_IBSPLIT) {
|
2009-09-18 11:00:21 -07:00
|
|
|
// All but the last part of an {ib} split should skip the "end" side (as
|
|
|
|
// determined by this frame's direction) and all but the first part of such
|
|
|
|
// a split should skip the "start" side. But figuring out which part of
|
|
|
|
// the split we are involves getting our first continuation, which might be
|
2009-05-11 19:04:58 -07:00
|
|
|
// expensive. So don't bother if we already have the relevant bits set.
|
2014-03-13 00:39:33 -07:00
|
|
|
if (skip != LOGICAL_SIDES_I_BOTH) {
|
2009-05-11 19:04:58 -07:00
|
|
|
// We're missing one of the skip bits, so check whether we need to set it.
|
2009-09-18 11:00:21 -07:00
|
|
|
// Only get the first continuation once, as an optimization.
|
2013-09-25 04:42:34 -07:00
|
|
|
nsIFrame* firstContinuation = FirstContinuation();
|
2013-09-30 14:26:04 -07:00
|
|
|
if (firstContinuation->FrameIsNonLastInIBSplit()) {
|
2014-03-13 00:39:33 -07:00
|
|
|
skip |= LOGICAL_SIDE_I_END;
|
2009-09-18 11:00:21 -07:00
|
|
|
}
|
2013-09-30 14:26:04 -07:00
|
|
|
if (firstContinuation->FrameIsNonFirstInIBSplit()) {
|
2014-03-13 00:39:33 -07:00
|
|
|
skip |= LOGICAL_SIDE_I_START;
|
2009-05-11 19:04:58 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
return skip;
|
|
|
|
}
|
|
|
|
|
2010-08-31 11:54:44 -07:00
|
|
|
nscoord
|
2014-06-17 05:19:38 -07:00
|
|
|
nsInlineFrame::GetLogicalBaseline(mozilla::WritingMode aWritingMode) const
|
2010-08-31 11:54:44 -07:00
|
|
|
{
|
2011-08-03 11:30:58 -07:00
|
|
|
return mBaseline;
|
2011-03-28 17:17:16 -07:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef ACCESSIBILITY
|
2012-09-28 14:53:44 -07:00
|
|
|
a11y::AccType
|
|
|
|
nsInlineFrame::AccessibleType()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
// Broken image accessibles are created here, because layout
|
|
|
|
// replaces the image or image control frame with an inline frame
|
|
|
|
nsIAtom *tagAtom = mContent->Tag();
|
2012-09-28 14:53:44 -07:00
|
|
|
if (tagAtom == nsGkAtoms::input) // Broken <input type=image ... />
|
2012-12-17 17:25:52 -08:00
|
|
|
return a11y::eHTMLButtonType;
|
2012-09-28 14:53:44 -07:00
|
|
|
if (tagAtom == nsGkAtoms::img) // Create accessible for broken <img>
|
2013-06-12 02:13:34 -07:00
|
|
|
return a11y::eHyperTextType;
|
2012-09-28 14:53:44 -07:00
|
|
|
|
2012-12-12 02:04:12 -08:00
|
|
|
return a11y::eNoType;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// nsLineFrame implementation
|
|
|
|
|
2014-05-24 15:20:39 -07:00
|
|
|
nsFirstLineFrame*
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_NewFirstLineFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
|
|
|
{
|
|
|
|
return new (aPresShell) nsFirstLineFrame(aContext);
|
|
|
|
}
|
|
|
|
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsFirstLineFrame)
|
|
|
|
|
2013-04-26 01:49:07 -07:00
|
|
|
void
|
2014-05-24 15:20:40 -07:00
|
|
|
nsFirstLineFrame::Init(nsIContent* aContent,
|
|
|
|
nsContainerFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
2013-04-26 01:49:07 -07:00
|
|
|
{
|
|
|
|
nsInlineFrame::Init(aContent, aParent, aPrevInFlow);
|
|
|
|
if (!aPrevInFlow) {
|
|
|
|
MOZ_ASSERT(StyleContext()->GetPseudo() == nsCSSPseudoElements::firstLine);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This frame is a continuation - fixup the style context if aPrevInFlow
|
|
|
|
// is the first-in-flow (the only one with a ::first-line pseudo).
|
|
|
|
if (aPrevInFlow->StyleContext()->GetPseudo() == nsCSSPseudoElements::firstLine) {
|
2013-09-25 04:42:34 -07:00
|
|
|
MOZ_ASSERT(FirstInFlow() == aPrevInFlow);
|
2013-04-26 01:49:07 -07:00
|
|
|
// Create a new style context that is a child of the parent
|
|
|
|
// style context thus removing the ::first-line style. This way
|
|
|
|
// we behave as if an anonymous (unstyled) span was the child
|
|
|
|
// of the parent frame.
|
|
|
|
nsStyleContext* parentContext = aParent->StyleContext();
|
|
|
|
nsRefPtr<nsStyleContext> newSC = PresContext()->StyleSet()->
|
|
|
|
ResolveAnonymousBoxStyle(nsCSSAnonBoxes::mozLineFrame, parentContext);
|
|
|
|
SetStyleContext(newSC);
|
|
|
|
} else {
|
2013-09-25 04:42:34 -07:00
|
|
|
MOZ_ASSERT(FirstInFlow() != aPrevInFlow);
|
2013-04-26 01:49:07 -07:00
|
|
|
MOZ_ASSERT(aPrevInFlow->StyleContext()->GetPseudo() ==
|
|
|
|
nsCSSAnonBoxes::mozLineFrame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-05 15:31:14 -08:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-02-17 23:47:48 -08:00
|
|
|
nsresult
|
2007-03-22 10:30:00 -07:00
|
|
|
nsFirstLineFrame::GetFrameName(nsAString& aResult) const
|
|
|
|
{
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("Line"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nsIAtom*
|
|
|
|
nsFirstLineFrame::GetType() const
|
|
|
|
{
|
|
|
|
return nsGkAtoms::lineFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame*
|
2007-04-20 17:42:58 -07:00
|
|
|
nsFirstLineFrame::PullOneFrame(nsPresContext* aPresContext, InlineReflowState& irs,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool* aIsComplete)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsIFrame* frame = nsInlineFrame::PullOneFrame(aPresContext, irs, aIsComplete);
|
|
|
|
if (frame && !GetPrevInFlow()) {
|
|
|
|
// We are a first-line frame. Fixup the child frames
|
|
|
|
// style-context that we just pulled.
|
|
|
|
NS_ASSERTION(frame->GetParent() == this, "Incorrect parent?");
|
2013-07-20 12:14:25 -07:00
|
|
|
aPresContext->RestyleManager()->ReparentStyleContext(frame);
|
2014-04-07 22:13:28 -07:00
|
|
|
nsLayoutUtils::MarkDescendantsDirty(frame);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
return frame;
|
|
|
|
}
|
|
|
|
|
2014-05-12 17:47:52 -07:00
|
|
|
void
|
2007-03-22 10:30:00 -07:00
|
|
|
nsFirstLineFrame::Reflow(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
if (nullptr == aReflowState.mLineLayout) {
|
2014-05-12 17:47:52 -07:00
|
|
|
return; // XXX does this happen? why?
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-04-22 18:45:26 -07:00
|
|
|
nsIFrame* lineContainer = aReflowState.mLineLayout->LineContainerFrame();
|
2007-04-20 17:42:58 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Check for an overflow list with our prev-in-flow
|
|
|
|
nsFirstLineFrame* prevInFlow = (nsFirstLineFrame*)GetPrevInFlow();
|
2013-04-01 08:26:02 -07:00
|
|
|
if (prevInFlow) {
|
|
|
|
AutoFrameListPtr prevOverflowFrames(aPresContext,
|
|
|
|
prevInFlow->StealOverflowFrames());
|
2007-03-22 10:30:00 -07:00
|
|
|
if (prevOverflowFrames) {
|
2007-04-20 17:42:58 -07:00
|
|
|
// Assign all floats to our block if necessary
|
|
|
|
if (lineContainer && lineContainer->GetPrevContinuation()) {
|
2009-07-28 05:51:09 -07:00
|
|
|
ReparentFloatsForInlineChild(lineContainer,
|
|
|
|
prevOverflowFrames->FirstChild(),
|
2011-10-17 07:59:28 -07:00
|
|
|
true);
|
2007-04-20 17:42:58 -07:00
|
|
|
}
|
2009-07-28 05:51:09 -07:00
|
|
|
const nsFrameList::Slice& newFrames =
|
2012-07-30 07:20:58 -07:00
|
|
|
mFrames.InsertFrames(this, nullptr, *prevOverflowFrames);
|
2010-04-01 23:07:43 -07:00
|
|
|
ReparentChildListStyle(aPresContext, newFrames, this);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-17 05:30:24 -08:00
|
|
|
// It's also possible that we have an overflow list for ourselves.
|
|
|
|
DrainSelfOverflowList();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Set our own reflow state (additional state above and beyond
|
|
|
|
// aReflowState)
|
|
|
|
InlineReflowState irs;
|
2012-07-30 07:20:58 -07:00
|
|
|
irs.mPrevFrame = nullptr;
|
2007-04-20 17:42:58 -07:00
|
|
|
irs.mLineContainer = lineContainer;
|
2009-12-15 12:08:59 -08:00
|
|
|
irs.mLineLayout = aReflowState.mLineLayout;
|
2007-03-22 10:30:00 -07:00
|
|
|
irs.mNextInFlow = (nsInlineFrame*) GetNextInFlow();
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool wasEmpty = mFrames.IsEmpty();
|
2007-03-22 10:30:00 -07:00
|
|
|
if (wasEmpty) {
|
|
|
|
// Try to pull over one frame before starting so that we know
|
|
|
|
// whether we have an anonymous block or not.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool complete;
|
2007-03-22 10:30:00 -07:00
|
|
|
PullOneFrame(aPresContext, irs, &complete);
|
|
|
|
}
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
if (nullptr == GetPrevInFlow()) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// XXX This is pretty sick, but what we do here is to pull-up, in
|
|
|
|
// advance, all of the next-in-flows children. We re-resolve their
|
|
|
|
// style while we are at at it so that when we reflow they have
|
|
|
|
// the right style.
|
|
|
|
//
|
|
|
|
// All of this is so that text-runs reflow properly.
|
|
|
|
irs.mPrevFrame = mFrames.LastChild();
|
|
|
|
for (;;) {
|
2011-09-28 23:19:26 -07:00
|
|
|
bool complete;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIFrame* frame = PullOneFrame(aPresContext, irs, &complete);
|
|
|
|
if (!frame) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
irs.mPrevFrame = frame;
|
|
|
|
}
|
2012-07-30 07:20:58 -07:00
|
|
|
irs.mPrevFrame = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_ASSERTION(!aReflowState.mLineLayout->GetInFirstLine(),
|
|
|
|
"Nested first-line frames? BOGUS");
|
2011-10-17 07:59:28 -07:00
|
|
|
aReflowState.mLineLayout->SetInFirstLine(true);
|
2014-05-12 17:47:52 -07:00
|
|
|
ReflowFrames(aPresContext, aReflowState, irs, aMetrics, aStatus);
|
2011-10-17 07:59:28 -07:00
|
|
|
aReflowState.mLineLayout->SetInFirstLine(false);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-04-29 16:02:33 -07:00
|
|
|
ReflowAbsoluteFrames(aPresContext, aMetrics, aReflowState, aStatus);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Note: the line layout code will properly compute our overflow state for us
|
|
|
|
}
|
|
|
|
|
2009-07-24 06:32:32 -07:00
|
|
|
/* virtual */ void
|
|
|
|
nsFirstLineFrame::PullOverflowsFromPrevInFlow()
|
|
|
|
{
|
|
|
|
nsFirstLineFrame* prevInFlow = static_cast<nsFirstLineFrame*>(GetPrevInFlow());
|
|
|
|
if (prevInFlow) {
|
2013-04-01 08:26:02 -07:00
|
|
|
nsPresContext* presContext = PresContext();
|
|
|
|
AutoFrameListPtr prevOverflowFrames(presContext,
|
|
|
|
prevInFlow->StealOverflowFrames());
|
2009-07-24 06:32:32 -07:00
|
|
|
if (prevOverflowFrames) {
|
|
|
|
// Assume that our prev-in-flow has the same line container that we do.
|
2009-07-28 05:51:09 -07:00
|
|
|
const nsFrameList::Slice& newFrames =
|
2012-07-30 07:20:58 -07:00
|
|
|
mFrames.InsertFrames(this, nullptr, *prevOverflowFrames);
|
2013-04-01 08:26:02 -07:00
|
|
|
ReparentChildListStyle(presContext, newFrames, this);
|
2009-07-24 06:32:32 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-17 05:30:24 -08:00
|
|
|
/* virtual */ bool
|
|
|
|
nsFirstLineFrame::DrainSelfOverflowList()
|
|
|
|
{
|
|
|
|
AutoFrameListPtr overflowFrames(PresContext(), StealOverflowFrames());
|
|
|
|
if (overflowFrames) {
|
|
|
|
NS_ASSERTION(mFrames.NotEmpty(), "overflow list w/o frames");
|
|
|
|
|
|
|
|
bool result = !overflowFrames->IsEmpty();
|
|
|
|
const nsFrameList::Slice& newFrames =
|
|
|
|
mFrames.AppendFrames(nullptr, *overflowFrames);
|
|
|
|
ReparentChildListStyle(PresContext(), newFrames, this);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|