2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00: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/. */
|
2006-03-29 18:29:03 +00:00
|
|
|
|
|
|
|
/* rendering object for CSS display:inline objects */
|
|
|
|
|
1999-04-20 00:25:12 +00:00
|
|
|
#include "nsInlineFrame.h"
|
2013-02-01 16:01:47 +00:00
|
|
|
#include "nsLineLayout.h"
|
2002-09-24 22:13:20 +00:00
|
|
|
#include "nsBlockFrame.h"
|
2009-08-31 18:25:35 +00:00
|
|
|
#include "nsPlaceholderFrame.h"
|
2007-01-30 00:06:41 +00:00
|
|
|
#include "nsGkAtoms.h"
|
2003-02-22 00:32:13 +00:00
|
|
|
#include "nsStyleContext.h"
|
2004-07-31 23:15:21 +00:00
|
|
|
#include "nsPresContext.h"
|
2011-04-08 01:04:40 +00:00
|
|
|
#include "nsRenderingContext.h"
|
2002-11-17 15:37:56 +00:00
|
|
|
#include "nsCSSAnonBoxes.h"
|
2003-02-22 00:32:13 +00:00
|
|
|
#include "nsAutoPtr.h"
|
2013-07-20 19:14:25 +00:00
|
|
|
#include "RestyleManager.h"
|
2006-04-27 02:45:03 +00:00
|
|
|
#include "nsDisplayList.h"
|
2012-10-26 13:32:10 +00:00
|
|
|
#include "mozilla/Likely.h"
|
1999-03-05 04:25:57 +00:00
|
|
|
|
2000-03-22 23:19:10 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
#undef NOISY_PUSHING
|
|
|
|
#endif
|
1999-02-02 17:32:09 +00:00
|
|
|
|
2012-09-28 21:53:44 +00:00
|
|
|
using namespace mozilla;
|
2013-04-01 15:26:02 +00:00
|
|
|
using namespace mozilla::layout;
|
2012-09-28 21:53:44 +00:00
|
|
|
|
2000-03-22 23:19:10 +00:00
|
|
|
|
1999-04-19 19:10:15 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
1999-02-01 17:27:56 +00:00
|
|
|
// Basic nsInlineFrame methods
|
1998-09-23 02:25:26 +00:00
|
|
|
|
2005-11-04 02:38:33 +00:00
|
|
|
nsIFrame*
|
2006-03-26 21:30:36 +00:00
|
|
|
NS_NewInlineFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
1998-09-12 04:46:35 +00:00
|
|
|
{
|
2006-03-26 21:30:36 +00:00
|
|
|
return new (aPresShell) nsInlineFrame(aContext);
|
1998-09-12 04:46:35 +00:00
|
|
|
}
|
|
|
|
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsInlineFrame)
|
|
|
|
|
2009-01-12 19:20:59 +00:00
|
|
|
NS_QUERYFRAME_HEAD(nsInlineFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsInlineFrame)
|
2011-12-27 20:18:48 +00:00
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
|
1998-06-27 22:56:09 +00:00
|
|
|
|
2014-01-05 23:31:14 +00:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-02-18 07:47:48 +00:00
|
|
|
nsresult
|
2001-11-14 01:33:42 +00:00
|
|
|
nsInlineFrame::GetFrameName(nsAString& aResult) const
|
1999-11-01 15:24:57 +00:00
|
|
|
{
|
2001-11-14 01:33:42 +00:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("Inline"), aResult);
|
1999-11-01 15:24:57 +00:00
|
|
|
}
|
1999-11-01 22:12:45 +00:00
|
|
|
#endif
|
1998-06-27 22:56:09 +00:00
|
|
|
|
2003-10-31 20:19:18 +00:00
|
|
|
nsIAtom*
|
|
|
|
nsInlineFrame::GetType() const
|
1999-11-01 15:24:57 +00:00
|
|
|
{
|
2006-12-26 17:47:52 +00:00
|
|
|
return nsGkAtoms::inlineFrame;
|
1998-06-18 16:25:41 +00:00
|
|
|
}
|
|
|
|
|
2013-02-11 06:22:20 +00:00
|
|
|
void
|
|
|
|
nsInlineFrame::InvalidateFrame(uint32_t aDisplayItemKey)
|
|
|
|
{
|
|
|
|
if (IsSVGText()) {
|
|
|
|
nsIFrame* svgTextFrame =
|
|
|
|
nsLayoutUtils::GetClosestFrameOfType(GetParent(),
|
2013-12-20 16:38:51 +00:00
|
|
|
nsGkAtoms::svgTextFrame);
|
2013-02-11 06:22:20 +00: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 16:38:51 +00:00
|
|
|
nsGkAtoms::svgTextFrame);
|
2013-02-11 06:22:20 +00:00
|
|
|
svgTextFrame->InvalidateFrame();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
nsInlineFrameBase::InvalidateFrameWithRect(aRect, aDisplayItemKey);
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
static inline bool
|
2010-08-31 16:05:12 +00:00
|
|
|
IsMarginZero(const nsStyleCoord &aCoord)
|
2001-10-25 01:08:40 +00:00
|
|
|
{
|
2010-08-31 16:05:12 +00:00
|
|
|
return aCoord.GetUnit() == eStyleUnit_Auto ||
|
2010-09-09 15:21:46 +00:00
|
|
|
nsLayoutUtils::IsMarginZero(aCoord);
|
2001-10-25 01:08:40 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
/* virtual */ bool
|
2004-11-15 05:01:11 +00:00
|
|
|
nsInlineFrame::IsSelfEmpty()
|
2001-10-25 01:08:40 +00:00
|
|
|
{
|
2002-11-28 19:29:28 +00:00
|
|
|
#if 0
|
|
|
|
// I used to think inline frames worked this way, but it seems they
|
|
|
|
// don't. At least not in our codebase.
|
2003-12-24 21:51:50 +00:00
|
|
|
if (GetPresContext()->CompatibilityMode() == eCompatibility_FullStandards) {
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2001-10-25 01:08:40 +00:00
|
|
|
}
|
2002-11-28 19:29:28 +00:00
|
|
|
#endif
|
2013-02-16 21:51:02 +00:00
|
|
|
const nsStyleMargin* margin = StyleMargin();
|
|
|
|
const nsStyleBorder* border = StyleBorder();
|
|
|
|
const nsStylePadding* padding = StylePadding();
|
2002-11-28 19:29:28 +00: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-29 06:19:26 +00:00
|
|
|
bool haveRight =
|
2012-05-31 05:19:49 +00:00
|
|
|
border->GetComputedBorderWidth(NS_SIDE_RIGHT) != 0 ||
|
2010-08-31 16:05:12 +00:00
|
|
|
!nsLayoutUtils::IsPaddingZero(padding->mPadding.GetRight()) ||
|
2010-08-31 16:05:12 +00:00
|
|
|
!IsMarginZero(margin->mMargin.GetRight());
|
2011-09-29 06:19:26 +00:00
|
|
|
bool haveLeft =
|
2012-05-31 05:19:49 +00:00
|
|
|
border->GetComputedBorderWidth(NS_SIDE_LEFT) != 0 ||
|
2010-08-31 16:05:12 +00:00
|
|
|
!nsLayoutUtils::IsPaddingZero(padding->mPadding.GetLeft()) ||
|
2010-08-31 16:05:12 +00:00
|
|
|
!IsMarginZero(margin->mMargin.GetLeft());
|
2009-09-18 18:00:21 +00:00
|
|
|
if (haveLeft || haveRight) {
|
2014-04-17 15:09:18 +00:00
|
|
|
if (GetStateBits() & NS_FRAME_PART_OF_IBSPLIT) {
|
2011-09-29 06:19:26 +00:00
|
|
|
bool haveStart, haveEnd;
|
2013-02-16 21:51:02 +00:00
|
|
|
if (NS_STYLE_DIRECTION_LTR == StyleVisibility()->mDirection) {
|
2009-09-18 18:00:21 +00:00
|
|
|
haveStart = haveLeft;
|
|
|
|
haveEnd = haveRight;
|
|
|
|
} else {
|
|
|
|
haveStart = haveRight;
|
|
|
|
haveEnd = haveLeft;
|
|
|
|
}
|
2014-02-07 01:45:33 +00: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 18:00:21 +00:00
|
|
|
// general way?
|
|
|
|
|
|
|
|
// Get the first continuation eagerly, as a performance optimization, to
|
|
|
|
// avoid having to get it twice..
|
2013-09-25 11:42:34 +00:00
|
|
|
nsIFrame* firstCont = FirstContinuation();
|
2009-09-18 18:00:21 +00:00
|
|
|
return
|
2013-09-30 21:26:04 +00:00
|
|
|
(!haveStart || firstCont->FrameIsNonFirstInIBSplit()) &&
|
|
|
|
(!haveEnd || firstCont->FrameIsNonLastInIBSplit());
|
2009-09-18 18:00:21 +00:00
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2001-10-25 01:08:40 +00:00
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2004-11-14 20:22:58 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2004-11-14 20:22:58 +00:00
|
|
|
nsInlineFrame::IsEmpty()
|
|
|
|
{
|
2004-11-15 05:01:11 +00:00
|
|
|
if (!IsSelfEmpty()) {
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2004-11-14 20:22:58 +00:00
|
|
|
}
|
2001-10-25 01:08:40 +00:00
|
|
|
|
2003-06-30 10:46:59 +00:00
|
|
|
for (nsIFrame *kid = mFrames.FirstChild(); kid; kid = kid->GetNextSibling()) {
|
2003-11-10 23:36:06 +00:00
|
|
|
if (!kid->IsEmpty())
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2001-10-25 01:08:40 +00:00
|
|
|
}
|
2004-11-14 20:22:58 +00:00
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2001-10-25 01:08:40 +00:00
|
|
|
}
|
|
|
|
|
2014-03-13 14:14:37 +00:00
|
|
|
nsIFrame::FrameSearchResult
|
2012-08-22 15:56:38 +00:00
|
|
|
nsInlineFrame::PeekOffsetCharacter(bool aForward, int32_t* aOffset,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aRespectClusters)
|
2006-09-11 20:43:01 +00:00
|
|
|
{
|
|
|
|
// Override the implementation in nsFrame, to skip empty inline frames
|
|
|
|
NS_ASSERTION (aOffset && *aOffset <= 1, "aOffset out of range");
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t startOffset = *aOffset;
|
2006-09-11 20:43:01 +00: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 14:14:37 +00:00
|
|
|
return CONTINUE;
|
2006-09-11 20:43:01 +00:00
|
|
|
}
|
|
|
|
|
2013-02-14 11:12:27 +00:00
|
|
|
void
|
2006-01-26 02:29:17 +00:00
|
|
|
nsInlineFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
2002-12-11 04:00:18 +00:00
|
|
|
{
|
2013-02-14 11:08:08 +00:00
|
|
|
BuildDisplayListForInline(aBuilder, aDirtyRect, aLists);
|
2011-12-27 20:18:48 +00:00
|
|
|
|
2002-12-11 04:00:18 +00: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 11:08:08 +00:00
|
|
|
DisplaySelectionOverlay(aBuilder, aLists.Content());
|
2002-12-11 04:00:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-02-01 17:27:56 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// Reflow methods
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
/* virtual */ void
|
2011-04-08 01:04:40 +00:00
|
|
|
nsInlineFrame::AddInlineMinWidth(nsRenderingContext *aRenderingContext,
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsIFrame::InlineMinWidthData *aData)
|
|
|
|
{
|
|
|
|
DoInlineIntrinsicWidth(aRenderingContext, aData, nsLayoutUtils::MIN_WIDTH);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ void
|
2011-04-08 01:04:40 +00:00
|
|
|
nsInlineFrame::AddInlinePrefWidth(nsRenderingContext *aRenderingContext,
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsIFrame::InlinePrefWidthData *aData)
|
|
|
|
{
|
|
|
|
DoInlineIntrinsicWidth(aRenderingContext, aData, nsLayoutUtils::PREF_WIDTH);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nsSize
|
2011-04-08 01:04:40 +00:00
|
|
|
nsInlineFrame::ComputeSize(nsRenderingContext *aRenderingContext,
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsSize aCBSize, nscoord aAvailableWidth,
|
|
|
|
nsSize aMargin, nsSize aBorder, nsSize aPadding,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t aFlags)
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
{
|
|
|
|
// Inlines and text don't compute size before reflow.
|
|
|
|
return nsSize(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
|
|
|
|
}
|
|
|
|
|
2007-10-12 08:30:54 +00:00
|
|
|
nsRect
|
|
|
|
nsInlineFrame::ComputeTightBounds(gfxContext* aContext) const
|
|
|
|
{
|
|
|
|
// be conservative
|
2013-02-16 05:38:33 +00:00
|
|
|
if (StyleContext()->HasTextDecorationLines()) {
|
2010-10-07 04:25:46 +00:00
|
|
|
return GetVisualOverflowRect();
|
2011-04-23 05:16:41 +00:00
|
|
|
}
|
2007-10-12 08:30:54 +00:00
|
|
|
return ComputeSimpleTightBounds(aContext);
|
|
|
|
}
|
|
|
|
|
2007-04-21 00:42:58 +00:00
|
|
|
void
|
|
|
|
nsInlineFrame::ReparentFloatsForInlineChild(nsIFrame* aOurLineContainer,
|
|
|
|
nsIFrame* aFrame,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aReparentSiblings)
|
2007-04-21 00:42:58 +00:00
|
|
|
{
|
2009-07-28 12:51:09 +00:00
|
|
|
// XXXbz this would be better if it took a nsFrameList or a frame
|
|
|
|
// list slice....
|
2007-04-21 00:42:58 +00:00
|
|
|
NS_ASSERTION(aOurLineContainer->GetNextContinuation() ||
|
|
|
|
aOurLineContainer->GetPrevContinuation(),
|
|
|
|
"Don't call this when we have no continuation, it's a waste");
|
2007-07-19 04:32:08 +00:00
|
|
|
if (!aFrame) {
|
|
|
|
NS_ASSERTION(aReparentSiblings, "Why did we get called?");
|
|
|
|
return;
|
|
|
|
}
|
2007-04-21 00:42:58 +00:00
|
|
|
|
|
|
|
nsIFrame* ancestor = aFrame;
|
|
|
|
do {
|
|
|
|
ancestor = ancestor->GetParent();
|
|
|
|
if (!ancestor)
|
|
|
|
return;
|
|
|
|
} while (!ancestor->IsFloatContainingBlock());
|
|
|
|
|
|
|
|
if (ancestor == aOurLineContainer)
|
|
|
|
return;
|
|
|
|
|
2008-07-13 22:10:23 +00: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-21 00:42:58 +00:00
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
while (true) {
|
2013-02-27 23:05:45 +00:00
|
|
|
ourBlock->ReparentFloats(aFrame, frameBlock, false);
|
2007-04-21 00:42:58 +00: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 23:42:45 +00:00
|
|
|
static void
|
2010-04-02 06:07:43 +00:00
|
|
|
ReparentChildListStyle(nsPresContext* aPresContext,
|
2009-12-22 23:42:45 +00:00
|
|
|
const nsFrameList::Slice& aFrames,
|
|
|
|
nsIFrame* aParentFrame)
|
|
|
|
{
|
2013-07-20 19:14:25 +00:00
|
|
|
RestyleManager* restyleManager = aPresContext->RestyleManager();
|
2009-12-22 23:42:45 +00:00
|
|
|
|
|
|
|
for (nsFrameList::Enumerator e(aFrames); !e.AtEnd(); e.Next()) {
|
|
|
|
NS_ASSERTION(e.get()->GetParent() == aParentFrame, "Bogus parentage");
|
2013-07-20 19:14:25 +00:00
|
|
|
restyleManager->ReparentStyleContext(e.get());
|
2014-04-08 05:13:28 +00:00
|
|
|
nsLayoutUtils::MarkDescendantsDirty(e.get());
|
2009-12-22 23:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-18 07:47:48 +00:00
|
|
|
nsresult
|
2004-07-31 23:15:21 +00:00
|
|
|
nsInlineFrame::Reflow(nsPresContext* aPresContext,
|
1999-02-01 17:27:56 +00:00
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsInlineFrame");
|
2001-11-14 13:40:03 +00:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aMetrics, aStatus);
|
2012-07-30 14:20:58 +00:00
|
|
|
if (nullptr == aReflowState.mLineLayout) {
|
1999-03-18 21:03:25 +00:00
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
2012-09-08 00:33:58 +00:00
|
|
|
if (IsFrameTreeTooDeep(aReflowState, aMetrics, aStatus)) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-03-12 03:14:11 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool lazilySetParentPointer = false;
|
2000-03-12 03:14:11 +00:00
|
|
|
|
2013-04-23 01:45:26 +00:00
|
|
|
nsIFrame* lineContainer = aReflowState.mLineLayout->LineContainerFrame();
|
2007-04-21 00:42:58 +00:00
|
|
|
|
|
|
|
// Check for an overflow list with our prev-in-flow
|
2006-02-21 21:33:47 +00:00
|
|
|
nsInlineFrame* prevInFlow = (nsInlineFrame*)GetPrevInFlow();
|
2013-04-01 15:26:02 +00:00
|
|
|
if (prevInFlow) {
|
|
|
|
AutoFrameListPtr prevOverflowFrames(aPresContext,
|
|
|
|
prevInFlow->StealOverflowFrames());
|
2000-03-12 03:14:11 +00:00
|
|
|
if (prevOverflowFrames) {
|
|
|
|
// When pushing and pulling frames we need to check for whether any
|
|
|
|
// views need to be reparented.
|
2014-02-06 22:07:47 +00:00
|
|
|
nsContainerFrame::ReparentFrameViewList(*prevOverflowFrames, prevInFlow,
|
|
|
|
this);
|
2000-03-12 03:14:11 +00:00
|
|
|
|
2009-02-07 08:34:27 +00: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 12:51:09 +00:00
|
|
|
// If our child list is empty, just put the new frames into it.
|
2000-03-12 03:14:11 +00: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 12:53:20 +00:00
|
|
|
mFrames.SetFrames(*prevOverflowFrames);
|
2011-10-17 14:59:28 +00:00
|
|
|
lazilySetParentPointer = true;
|
2000-03-12 03:14:11 +00:00
|
|
|
} else {
|
2007-04-21 00:42:58 +00:00
|
|
|
// Assign all floats to our block if necessary
|
|
|
|
if (lineContainer && lineContainer->GetPrevContinuation()) {
|
2009-07-28 12:51:09 +00:00
|
|
|
ReparentFloatsForInlineChild(lineContainer,
|
|
|
|
prevOverflowFrames->FirstChild(),
|
2011-10-17 14:59:28 +00:00
|
|
|
true);
|
2007-04-21 00:42:58 +00:00
|
|
|
}
|
2000-03-12 03:14:11 +00:00
|
|
|
// Insert the new frames at the beginning of the child list
|
|
|
|
// and set their parent pointer
|
2009-12-22 23:42:45 +00:00
|
|
|
const nsFrameList::Slice& newFrames =
|
2012-07-30 14:20:58 +00:00
|
|
|
mFrames.InsertFrames(this, nullptr, *prevOverflowFrames);
|
2009-12-22 23:42:45 +00: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-02 06:07:43 +00:00
|
|
|
ReparentChildListStyle(aPresContext, newFrames, this);
|
2009-12-22 23:42:45 +00:00
|
|
|
}
|
2000-03-12 03:14:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// It's also possible that we have an overflow list for ourselves
|
2000-03-22 04:06:37 +00:00
|
|
|
#ifdef DEBUG
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
if (GetStateBits() & NS_FRAME_FIRST_REFLOW) {
|
2000-03-22 04:06:37 +00:00
|
|
|
// 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 12:51:09 +00:00
|
|
|
nsFrameList* overflowFrames = GetOverflowFrames();
|
|
|
|
NS_ASSERTION(!overflowFrames || overflowFrames->IsEmpty(),
|
|
|
|
"overflow list is not empty for initial reflow");
|
2000-03-22 04:06:37 +00:00
|
|
|
}
|
|
|
|
#endif
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
if (!(GetStateBits() & NS_FRAME_FIRST_REFLOW)) {
|
2013-12-17 13:30:24 +00:00
|
|
|
DrainFlags flags =
|
|
|
|
lazilySetParentPointer ? eDontReparentFrames : DrainFlags(0);
|
|
|
|
if (aReflowState.mLineLayout->GetInFirstLine()) {
|
|
|
|
flags = DrainFlags(flags | eInFirstLine);
|
2000-03-12 03:14:11 +00:00
|
|
|
}
|
2013-12-17 13:30:24 +00:00
|
|
|
DrainSelfOverflowListInternal(flags, lineContainer);
|
2000-03-12 03:14:11 +00:00
|
|
|
}
|
1999-02-01 17:27:56 +00:00
|
|
|
|
1999-03-05 04:25:57 +00:00
|
|
|
// Set our own reflow state (additional state above and beyond
|
|
|
|
// aReflowState)
|
|
|
|
InlineReflowState irs;
|
2012-07-30 14:20:58 +00:00
|
|
|
irs.mPrevFrame = nullptr;
|
2007-04-21 00:42:58 +00:00
|
|
|
irs.mLineContainer = lineContainer;
|
2009-10-27 01:43:56 +00:00
|
|
|
irs.mLineLayout = aReflowState.mLineLayout;
|
2006-02-21 21:33:47 +00:00
|
|
|
irs.mNextInFlow = (nsInlineFrame*) GetNextInFlow();
|
2000-03-12 03:14:11 +00:00
|
|
|
irs.mSetParentPointer = lazilySetParentPointer;
|
1999-02-01 17:27:56 +00:00
|
|
|
|
|
|
|
nsresult rv;
|
|
|
|
if (mFrames.IsEmpty()) {
|
1999-04-20 00:25:12 +00:00
|
|
|
// Try to pull over one frame before starting so that we know
|
|
|
|
// whether we have an anonymous block or not.
|
2011-09-29 06:19:26 +00:00
|
|
|
bool complete;
|
1999-11-24 06:03:41 +00:00
|
|
|
(void) PullOneFrame(aPresContext, irs, &complete);
|
1999-02-01 17:27:56 +00:00
|
|
|
}
|
|
|
|
|
1999-11-24 06:03:41 +00:00
|
|
|
rv = ReflowFrames(aPresContext, aReflowState, irs, aMetrics, aStatus);
|
2011-04-29 23:02:33 +00:00
|
|
|
|
|
|
|
ReflowAbsoluteFrames(aPresContext, aMetrics, aReflowState, aStatus);
|
|
|
|
|
1999-11-01 15:24:57 +00:00
|
|
|
// Note: the line layout code will properly compute our
|
2009-04-06 00:31:50 +00:00
|
|
|
// overflow-rect state for us.
|
1999-02-01 17:27:56 +00:00
|
|
|
|
2002-05-28 22:50:43 +00:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aMetrics);
|
1999-02-01 17:27:56 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2013-12-17 13:30:24 +00: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-08 05:13:28 +00:00
|
|
|
nsLayoutUtils::MarkDescendantsDirty(f);
|
2013-12-17 13:30:24 +00: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-29 06:19:26 +00:00
|
|
|
/* virtual */ bool
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsInlineFrame::CanContinueTextRun() const
|
2000-07-28 22:29:28 +00:00
|
|
|
{
|
|
|
|
// We can continue a text run through an inline frame
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2000-01-12 21:52:58 +00:00
|
|
|
}
|
|
|
|
|
2009-07-24 13:32:32 +00:00
|
|
|
/* virtual */ void
|
|
|
|
nsInlineFrame::PullOverflowsFromPrevInFlow()
|
|
|
|
{
|
|
|
|
nsInlineFrame* prevInFlow = static_cast<nsInlineFrame*>(GetPrevInFlow());
|
|
|
|
if (prevInFlow) {
|
2013-04-01 15:26:02 +00:00
|
|
|
nsPresContext* presContext = PresContext();
|
|
|
|
AutoFrameListPtr prevOverflowFrames(presContext,
|
|
|
|
prevInFlow->StealOverflowFrames());
|
2009-07-24 13:32:32 +00:00
|
|
|
if (prevOverflowFrames) {
|
|
|
|
// Assume that our prev-in-flow has the same line container that we do.
|
2014-02-06 22:07:47 +00:00
|
|
|
nsContainerFrame::ReparentFrameViewList(*prevOverflowFrames, prevInFlow,
|
|
|
|
this);
|
2012-07-30 14:20:58 +00:00
|
|
|
mFrames.InsertFrames(this, nullptr, *prevOverflowFrames);
|
2009-07-24 13:32:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-02-01 17:27:56 +00:00
|
|
|
nsresult
|
2004-07-31 23:15:21 +00:00
|
|
|
nsInlineFrame::ReflowFrames(nsPresContext* aPresContext,
|
1999-11-01 15:24:57 +00:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
InlineReflowState& irs,
|
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-10-27 16:52:10 +00:00
|
|
|
{
|
1999-02-01 17:27:56 +00:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
|
1999-07-20 03:51:46 +00:00
|
|
|
nsLineLayout* lineLayout = aReflowState.mLineLayout;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool inFirstLine = aReflowState.mLineLayout->GetInFirstLine();
|
2013-07-20 19:14:25 +00:00
|
|
|
RestyleManager* restyleManager = aPresContext->RestyleManager();
|
2014-03-11 20:23:50 +00:00
|
|
|
WritingMode wm = aReflowState.GetWritingMode();
|
|
|
|
nscoord startEdge = 0;
|
2009-05-12 02:04:58 +00:00
|
|
|
// Don't offset by our start borderpadding if we have a prev continuation or
|
2014-04-17 15:09:18 +00:00
|
|
|
// if we're in a part of an {ib} split other than the first one.
|
|
|
|
if (!GetPrevContinuation() && !FrameIsNonFirstInIBSplit()) {
|
2014-03-11 20:23:50 +00:00
|
|
|
startEdge = aReflowState.ComputedLogicalBorderPadding().IStart(wm);
|
1999-03-18 21:03:25 +00:00
|
|
|
}
|
2014-03-11 20:23:50 +00:00
|
|
|
nscoord availableISize = aReflowState.AvailableISize();
|
|
|
|
NS_ASSERTION(availableISize != NS_UNCONSTRAINEDSIZE,
|
2007-12-12 21:51:00 +00:00
|
|
|
"should no longer use available widths");
|
2014-03-11 20:23:50 +00:00
|
|
|
// Subtract off inline axis border+padding from availableISize
|
|
|
|
availableISize -= startEdge;
|
|
|
|
availableISize -= aReflowState.ComputedLogicalBorderPadding().IEnd(wm);
|
|
|
|
lineLayout->BeginSpan(this, &aReflowState, startEdge,
|
|
|
|
startEdge + availableISize, &mBaseline);
|
1999-02-01 17:27:56 +00:00
|
|
|
|
2013-02-07 01:13:34 +00:00
|
|
|
// First reflow our principal children.
|
1999-02-01 17:27:56 +00:00
|
|
|
nsIFrame* frame = mFrames.FirstChild();
|
2011-09-29 06:19:26 +00:00
|
|
|
bool done = false;
|
2013-02-07 01:13:34 +00:00
|
|
|
while (frame) {
|
|
|
|
// Check if we should lazily set the child frame's parent pointer.
|
2000-03-12 03:14:11 +00:00
|
|
|
if (irs.mSetParentPointer) {
|
2011-09-29 06:19:26 +00:00
|
|
|
bool havePrevBlock =
|
2007-04-21 00:42:58 +00:00
|
|
|
irs.mLineContainer && irs.mLineContainer->GetPrevContinuation();
|
2012-09-08 00:33:58 +00: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-21 00:42:58 +00:00
|
|
|
if (havePrevBlock) {
|
2012-09-08 00:33:58 +00: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-21 00:42:58 +00:00
|
|
|
}
|
2012-09-08 00:33:58 +00:00
|
|
|
child->SetParent(this);
|
2009-12-22 23:42:45 +00:00
|
|
|
if (inFirstLine) {
|
2013-07-20 19:14:25 +00:00
|
|
|
restyleManager->ReparentStyleContext(child);
|
2014-04-08 05:13:28 +00:00
|
|
|
nsLayoutUtils::MarkDescendantsDirty(child);
|
2009-12-22 23:42:45 +00:00
|
|
|
}
|
2012-09-08 00:33:58 +00: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 13:32:10 +00:00
|
|
|
if (MOZ_UNLIKELY(child)) {
|
2012-09-08 00:33:58 +00:00
|
|
|
while (child != nextSibling && nextSibling) {
|
|
|
|
nextSibling = nextSibling->GetNextSibling();
|
|
|
|
}
|
|
|
|
if (!nextSibling) {
|
|
|
|
child = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(!child || mFrames.ContainsFrame(child));
|
|
|
|
} while (child);
|
2008-12-07 18:21:40 +00: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 20:54:30 +00:00
|
|
|
nsIFrame* child = realFrame->GetFirstPrincipalChild();
|
2008-12-07 18:21:40 +00: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 23:42:45 +00:00
|
|
|
if (inFirstLine) {
|
2013-07-20 19:14:25 +00:00
|
|
|
restyleManager->ReparentStyleContext(nextInFlow);
|
2014-04-08 05:13:28 +00:00
|
|
|
nsLayoutUtils::MarkDescendantsDirty(nextInFlow);
|
2009-12-22 23:42:45 +00:00
|
|
|
}
|
2008-12-07 18:21:40 +00: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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-03-22 04:06:37 +00:00
|
|
|
}
|
2000-03-12 03:14:11 +00:00
|
|
|
}
|
2012-09-08 00:33:58 +00:00
|
|
|
MOZ_ASSERT(frame->GetParent() == this);
|
|
|
|
|
|
|
|
if (!done) {
|
2013-02-07 01:13:34 +00:00
|
|
|
bool reflowingFirstLetter = lineLayout->GetFirstLetterStyleOK();
|
2012-09-08 00:33:58 +00:00
|
|
|
rv = ReflowInlineFrame(aPresContext, aReflowState, irs, frame, aStatus);
|
|
|
|
done = NS_FAILED(rv) ||
|
|
|
|
NS_INLINE_IS_BREAK(aStatus) ||
|
|
|
|
(!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;
|
|
|
|
}
|
1999-04-27 22:12:37 +00:00
|
|
|
}
|
2003-06-30 10:46:59 +00:00
|
|
|
frame = frame->GetNextSibling();
|
1999-02-01 17:27:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Attempt to pull frames from our next-in-flow until we can't
|
2012-09-08 00:33:58 +00:00
|
|
|
if (!done && GetNextInFlow()) {
|
|
|
|
while (true) {
|
2011-09-29 06:19:26 +00:00
|
|
|
bool reflowingFirstLetter = lineLayout->GetFirstLetterStyleOK();
|
|
|
|
bool isComplete;
|
2007-03-05 00:15:46 +00: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);
|
|
|
|
}
|
2000-03-22 23:19:10 +00:00
|
|
|
#ifdef NOISY_PUSHING
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("%p pulled up %p\n", this, frame);
|
2000-03-22 23:19:10 +00:00
|
|
|
#endif
|
2012-07-30 14:20:58 +00:00
|
|
|
if (nullptr == frame) {
|
1999-02-01 17:27:56 +00:00
|
|
|
if (!isComplete) {
|
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
1998-12-05 16:04:46 +00:00
|
|
|
}
|
1999-02-01 17:27:56 +00:00
|
|
|
break;
|
|
|
|
}
|
1999-03-05 04:25:57 +00:00
|
|
|
rv = ReflowInlineFrame(aPresContext, aReflowState, irs, frame, aStatus);
|
2012-09-08 00:33:58 +00:00
|
|
|
if (NS_FAILED(rv) ||
|
|
|
|
NS_INLINE_IS_BREAK(aStatus) ||
|
2002-07-15 14:46:01 +00:00
|
|
|
(!reflowingFirstLetter && NS_FRAME_IS_NOT_COMPLETE(aStatus))) {
|
|
|
|
break;
|
1999-04-27 22:12:37 +00:00
|
|
|
}
|
1999-03-05 04:25:57 +00:00
|
|
|
irs.mPrevFrame = frame;
|
2007-03-05 00:15:46 +00:00
|
|
|
frame = frame->GetNextSibling();
|
1998-10-27 16:52:10 +00:00
|
|
|
}
|
|
|
|
}
|
2012-09-08 00:33:58 +00:00
|
|
|
|
|
|
|
NS_ASSERTION(!NS_FRAME_IS_COMPLETE(aStatus) || !GetOverflowFrames(),
|
|
|
|
"We can't be complete AND have overflow frames!");
|
1999-02-01 17:27:56 +00:00
|
|
|
|
1999-03-18 21:03:25 +00:00
|
|
|
// If after reflowing our children they take up no area then make
|
|
|
|
// sure that we don't either.
|
1999-04-20 00:25:12 +00:00
|
|
|
//
|
|
|
|
// 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-03-11 20:23:50 +00:00
|
|
|
aMetrics.ISize() = lineLayout->EndSpan(this);
|
2007-05-05 17:06:04 +00:00
|
|
|
|
2009-05-12 02:04:58 +00:00
|
|
|
// Compute final width.
|
|
|
|
|
|
|
|
// Make sure to not include our start border and padding if we have a prev
|
2009-09-18 18:00:21 +00:00
|
|
|
// continuation or if we're in a part of an {ib} split other than the first
|
2014-04-17 15:09:18 +00:00
|
|
|
// one.
|
|
|
|
if (!GetPrevContinuation() && !FrameIsNonFirstInIBSplit()) {
|
2014-03-11 20:23:50 +00:00
|
|
|
aMetrics.ISize() += aReflowState.ComputedLogicalBorderPadding().IStart(wm);
|
2007-05-05 17:06:04 +00:00
|
|
|
}
|
2009-05-12 02:04:58 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We want to only apply the end border and padding if we're the last
|
2009-09-18 18:00:21 +00: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-04-17 15:09:18 +00:00
|
|
|
* chain.
|
2009-05-12 02:04:58 +00:00
|
|
|
*/
|
2014-04-17 15:09:18 +00:00
|
|
|
if (NS_FRAME_IS_COMPLETE(aStatus) &&
|
|
|
|
!LastInFlow()->GetNextContinuation() &&
|
|
|
|
!FrameIsNonLastInIBSplit()) {
|
2014-03-11 20:23:50 +00:00
|
|
|
aMetrics.Width() += aReflowState.ComputedLogicalBorderPadding().IEnd(wm);
|
1999-03-18 21:03:25 +00:00
|
|
|
}
|
|
|
|
|
2011-08-14 17:08:04 +00:00
|
|
|
nsRefPtr<nsFontMetrics> fm;
|
2012-05-21 05:18:28 +00:00
|
|
|
float inflation = nsLayoutUtils::FontSizeInflationFor(this);
|
2011-11-24 02:48:23 +00:00
|
|
|
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm), inflation);
|
2011-08-14 17:08:04 +00:00
|
|
|
aReflowState.rendContext->SetFont(fm);
|
2007-05-05 17:06:04 +00: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.
|
2013-12-27 17:59:52 +00:00
|
|
|
aMetrics.SetTopAscent(fm->MaxAscent());
|
|
|
|
aMetrics.Height() = fm->MaxHeight();
|
2007-05-05 17:06:04 +00:00
|
|
|
} else {
|
|
|
|
NS_WARNING("Cannot get font metrics - defaulting sizes to 0");
|
2013-12-27 17:59:52 +00:00
|
|
|
aMetrics.SetTopAscent(aMetrics.Height() = 0);
|
1999-02-01 17:27:56 +00:00
|
|
|
}
|
2013-12-27 17:59:52 +00:00
|
|
|
aMetrics.SetTopAscent(aMetrics.TopAscent() + aReflowState.ComputedPhysicalBorderPadding().top);
|
|
|
|
aMetrics.Height() += aReflowState.ComputedPhysicalBorderPadding().top +
|
2013-12-27 17:59:21 +00:00
|
|
|
aReflowState.ComputedPhysicalBorderPadding().bottom;
|
1999-03-18 21:03:25 +00:00
|
|
|
|
1999-12-06 15:49:53 +00:00
|
|
|
// For now our overflow area is zero. The real value will be
|
2008-02-16 15:31:27 +00:00
|
|
|
// computed in |nsLineLayout::RelativePositionFrames|.
|
2010-10-07 04:25:46 +00:00
|
|
|
aMetrics.mOverflowAreas.Clear();
|
1999-03-18 21:03:25 +00:00
|
|
|
|
|
|
|
#ifdef NOISY_FINAL_SIZE
|
|
|
|
ListTag(stdout);
|
2007-01-23 04:06:56 +00:00
|
|
|
printf(": metrics=%d,%d ascent=%d\n",
|
2013-12-27 17:59:52 +00:00
|
|
|
aMetrics.Width(), aMetrics.Height(), aMetrics.TopAscent());
|
1999-03-18 21:03:25 +00:00
|
|
|
#endif
|
1999-02-01 17:27:56 +00:00
|
|
|
|
|
|
|
return rv;
|
1998-10-27 16:52:10 +00:00
|
|
|
}
|
|
|
|
|
1999-02-01 17:27:56 +00:00
|
|
|
nsresult
|
2004-07-31 23:15:21 +00:00
|
|
|
nsInlineFrame::ReflowInlineFrame(nsPresContext* aPresContext,
|
1999-03-05 04:25:57 +00:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
InlineReflowState& irs,
|
1999-02-01 17:27:56 +00:00
|
|
|
nsIFrame* aFrame,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-09-19 04:29:36 +00:00
|
|
|
{
|
1999-07-20 03:51:46 +00:00
|
|
|
nsLineLayout* lineLayout = aReflowState.mLineLayout;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool reflowingFirstLetter = lineLayout->GetFirstLetterStyleOK();
|
|
|
|
bool pushedFrame;
|
2006-10-19 01:47:47 +00:00
|
|
|
nsresult rv =
|
2012-07-30 14:20:58 +00:00
|
|
|
lineLayout->ReflowFrame(aFrame, aStatus, nullptr, pushedFrame);
|
2006-10-19 01:47:47 +00:00
|
|
|
|
1999-02-01 17:27:56 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
2010-06-29 14:32:03 +00: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);
|
1999-02-01 17:27:56 +00:00
|
|
|
}
|
|
|
|
else {
|
2010-06-29 14:32:03 +00:00
|
|
|
// Preserve reflow status when breaking-before our first child
|
|
|
|
// and propagate it upward without modification.
|
1999-02-01 17:27:56 +00:00
|
|
|
}
|
2010-06-29 14:32:03 +00:00
|
|
|
return NS_OK;
|
1999-02-01 17:27:56 +00:00
|
|
|
}
|
2010-06-29 14:32:03 +00:00
|
|
|
|
|
|
|
// Create a next-in-flow if needed.
|
|
|
|
if (!NS_FRAME_IS_FULLY_COMPLETE(aStatus)) {
|
|
|
|
nsIFrame* newFrame;
|
2014-02-06 22:07:47 +00:00
|
|
|
rv = CreateNextInFlow(aFrame, newFrame);
|
2010-06-29 14:32:03 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_INLINE_IS_BREAK_AFTER(aStatus)) {
|
|
|
|
nsIFrame* nextFrame = aFrame->GetNextSibling();
|
|
|
|
if (nextFrame) {
|
|
|
|
NS_FRAME_SET_INCOMPLETE(aStatus);
|
|
|
|
PushFrames(aPresContext, nextFrame, aFrame, irs);
|
1999-02-01 17:27:56 +00:00
|
|
|
}
|
2002-09-24 22:13:20 +00:00
|
|
|
else {
|
2010-06-29 14:32:03 +00: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;
|
2002-09-24 22:13:20 +00:00
|
|
|
}
|
2010-06-29 14:32:03 +00:00
|
|
|
nextInFlow = static_cast<nsInlineFrame*>(nextInFlow->GetNextInFlow());
|
1999-04-27 22:12:37 +00:00
|
|
|
}
|
1999-02-01 17:27:56 +00:00
|
|
|
}
|
2010-06-29 14:32:03 +00:00
|
|
|
return NS_OK;
|
1999-02-01 17:27:56 +00:00
|
|
|
}
|
2010-06-29 14:32:03 +00:00
|
|
|
|
|
|
|
if (!NS_FRAME_IS_FULLY_COMPLETE(aStatus) && !reflowingFirstLetter) {
|
|
|
|
nsIFrame* nextFrame = aFrame->GetNextSibling();
|
|
|
|
if (nextFrame) {
|
|
|
|
PushFrames(aPresContext, nextFrame, aFrame, irs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
1999-02-01 17:27:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame*
|
2004-07-31 23:15:21 +00:00
|
|
|
nsInlineFrame::PullOneFrame(nsPresContext* aPresContext,
|
1999-11-01 15:24:57 +00:00
|
|
|
InlineReflowState& irs,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool* aIsComplete)
|
1999-02-01 17:27:56 +00:00
|
|
|
{
|
2011-09-29 06:19:26 +00:00
|
|
|
bool isComplete = true;
|
1999-02-01 17:27:56 +00:00
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
nsIFrame* frame = nullptr;
|
1999-03-05 04:25:57 +00:00
|
|
|
nsInlineFrame* nextInFlow = irs.mNextInFlow;
|
2013-04-01 15:26:02 +00:00
|
|
|
while (nextInFlow) {
|
2007-04-21 00:42:58 +00:00
|
|
|
frame = nextInFlow->mFrames.FirstChild();
|
2010-01-28 04:12:37 +00:00
|
|
|
if (!frame) {
|
2012-09-08 00:33:58 +00:00
|
|
|
// The nextInFlow's principal list has no frames, try its overflow list.
|
|
|
|
nsFrameList* overflowFrames = nextInFlow->GetOverflowFrames();
|
2010-01-28 04:12:37 +00:00
|
|
|
if (overflowFrames) {
|
2013-04-01 15:26:02 +00:00
|
|
|
frame = overflowFrames->RemoveFirstChild();
|
|
|
|
if (overflowFrames->IsEmpty()) {
|
2012-09-08 00:33:58 +00:00
|
|
|
// We're stealing the only frame - delete the overflow list.
|
2014-02-06 22:07:47 +00:00
|
|
|
nextInFlow->DestroyOverflowList();
|
2012-09-08 00:33:58 +00: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-28 04:12:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-01 15:26:02 +00:00
|
|
|
if (frame) {
|
2007-04-21 00:42:58 +00: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 14:59:28 +00:00
|
|
|
ReparentFloatsForInlineChild(irs.mLineContainer, frame, false);
|
2007-04-21 00:42:58 +00:00
|
|
|
}
|
|
|
|
nextInFlow->mFrames.RemoveFirstChild();
|
2012-09-08 00:33:58 +00:00
|
|
|
// nsFirstLineFrame::PullOneFrame calls ReparentStyleContext.
|
2009-12-18 09:02:26 +00:00
|
|
|
|
2007-04-21 00:42:58 +00:00
|
|
|
mFrames.InsertFrame(this, irs.mPrevFrame, frame);
|
2011-10-17 14:59:28 +00:00
|
|
|
isComplete = false;
|
2009-10-27 01:43:56 +00:00
|
|
|
if (irs.mLineLayout) {
|
|
|
|
irs.mLineLayout->SetDirtyNextLine();
|
|
|
|
}
|
2014-02-06 22:07:47 +00:00
|
|
|
nsContainerFrame::ReparentFrameView(frame, nextInFlow, this);
|
1999-02-01 17:27:56 +00:00
|
|
|
break;
|
|
|
|
}
|
2013-04-01 15:26:02 +00:00
|
|
|
nextInFlow = static_cast<nsInlineFrame*>(nextInFlow->GetNextInFlow());
|
1999-11-01 15:24:57 +00:00
|
|
|
irs.mNextInFlow = nextInFlow;
|
1999-02-01 17:27:56 +00:00
|
|
|
}
|
|
|
|
|
1999-11-01 15:24:57 +00:00
|
|
|
*aIsComplete = isComplete;
|
|
|
|
return frame;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-07-31 23:15:21 +00:00
|
|
|
nsInlineFrame::PushFrames(nsPresContext* aPresContext,
|
1999-11-01 15:24:57 +00:00
|
|
|
nsIFrame* aFromChild,
|
2009-10-27 01:43:56 +00:00
|
|
|
nsIFrame* aPrevSibling,
|
|
|
|
InlineReflowState& aState)
|
1999-11-01 15:24:57 +00:00
|
|
|
{
|
2009-09-18 11:09:35 +00:00
|
|
|
NS_PRECONDITION(aFromChild, "null pointer");
|
|
|
|
NS_PRECONDITION(aPrevSibling, "pushing first child");
|
2003-06-30 10:46:59 +00:00
|
|
|
NS_PRECONDITION(aPrevSibling->GetNextSibling() == aFromChild, "bad prev sibling");
|
1999-11-01 15:24:57 +00:00
|
|
|
|
2000-03-22 23:19:10 +00:00
|
|
|
#ifdef NOISY_PUSHING
|
2009-09-18 11:09:35 +00:00
|
|
|
printf("%p pushing aFromChild %p, disconnecting from prev sib %p\n",
|
|
|
|
this, aFromChild, aPrevSibling);
|
2000-03-22 23:19:10 +00:00
|
|
|
#endif
|
1999-11-01 15:24:57 +00:00
|
|
|
|
|
|
|
// Add the frames to our overflow list (let our next in flow drain
|
|
|
|
// our overflow list when it is ready)
|
2014-02-06 22:07:47 +00:00
|
|
|
SetOverflowFrames(mFrames.RemoveFramesAfter(aPrevSibling));
|
2009-10-27 01:43:56 +00:00
|
|
|
if (aState.mLineLayout) {
|
|
|
|
aState.mLineLayout->SetDirtyNextLine();
|
|
|
|
}
|
1999-02-01 17:27:56 +00:00
|
|
|
}
|
|
|
|
|
2000-01-12 08:28:24 +00:00
|
|
|
|
1999-02-01 17:27:56 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-08-09 07:09:40 +00:00
|
|
|
int
|
2014-03-13 07:39:33 +00:00
|
|
|
nsInlineFrame::GetLogicalSkipSides(const nsHTMLReflowState* aReflowState) const
|
1998-12-18 22:12:42 +00:00
|
|
|
{
|
2012-08-09 07:09:40 +00:00
|
|
|
int skip = 0;
|
2014-03-13 07:39:33 +00:00
|
|
|
if (!IsFirst()) {
|
2006-02-21 21:33:47 +00:00
|
|
|
nsInlineFrame* prev = (nsInlineFrame*) GetPrevContinuation();
|
2006-06-15 08:16:23 +00:00
|
|
|
if ((GetStateBits() & NS_INLINE_FRAME_BIDI_VISUAL_STATE_IS_SET) ||
|
|
|
|
(prev && (prev->mRect.height || prev->mRect.width))) {
|
2014-03-13 07:39:33 +00:00
|
|
|
// Prev continuation is not empty therefore we don't render our start
|
1999-04-20 00:25:12 +00:00
|
|
|
// border edge.
|
2014-03-13 07:39:33 +00:00
|
|
|
skip |= LOGICAL_SIDE_I_START;
|
1999-04-20 00:25:12 +00:00
|
|
|
}
|
|
|
|
else {
|
2014-03-13 07:39:33 +00:00
|
|
|
// If the prev continuation is empty, then go ahead and let our start
|
1999-04-20 00:25:12 +00:00
|
|
|
// edge border render.
|
|
|
|
}
|
1998-12-18 22:12:42 +00:00
|
|
|
}
|
2014-03-13 07:39:33 +00:00
|
|
|
if (!IsLast()) {
|
2006-02-21 21:33:47 +00:00
|
|
|
nsInlineFrame* next = (nsInlineFrame*) GetNextContinuation();
|
2006-06-15 08:16:23 +00:00
|
|
|
if ((GetStateBits() & NS_INLINE_FRAME_BIDI_VISUAL_STATE_IS_SET) ||
|
|
|
|
(next && (next->mRect.height || next->mRect.width))) {
|
2014-03-13 07:39:33 +00:00
|
|
|
// Next continuation is not empty therefore we don't render our end
|
1999-04-20 00:25:12 +00:00
|
|
|
// border edge.
|
2014-03-13 07:39:33 +00:00
|
|
|
skip |= LOGICAL_SIDE_I_END;
|
1999-04-20 00:25:12 +00:00
|
|
|
}
|
|
|
|
else {
|
2014-03-13 07:39:33 +00:00
|
|
|
// If the next continuation is empty, then go ahead and let our end
|
1999-04-20 00:25:12 +00:00
|
|
|
// edge border render.
|
|
|
|
}
|
1998-12-18 22:12:42 +00:00
|
|
|
}
|
2009-05-12 02:04:58 +00:00
|
|
|
|
2014-02-07 01:45:28 +00:00
|
|
|
if (GetStateBits() & NS_FRAME_PART_OF_IBSPLIT) {
|
2009-09-18 18:00:21 +00: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-12 02:04:58 +00:00
|
|
|
// expensive. So don't bother if we already have the relevant bits set.
|
2014-03-13 07:39:33 +00:00
|
|
|
if (skip != LOGICAL_SIDES_I_BOTH) {
|
2009-05-12 02:04:58 +00:00
|
|
|
// We're missing one of the skip bits, so check whether we need to set it.
|
2009-09-18 18:00:21 +00:00
|
|
|
// Only get the first continuation once, as an optimization.
|
2013-09-25 11:42:34 +00:00
|
|
|
nsIFrame* firstContinuation = FirstContinuation();
|
2013-09-30 21:26:04 +00:00
|
|
|
if (firstContinuation->FrameIsNonLastInIBSplit()) {
|
2014-03-13 07:39:33 +00:00
|
|
|
skip |= LOGICAL_SIDE_I_END;
|
2009-09-18 18:00:21 +00:00
|
|
|
}
|
2013-09-30 21:26:04 +00:00
|
|
|
if (firstContinuation->FrameIsNonFirstInIBSplit()) {
|
2014-03-13 07:39:33 +00:00
|
|
|
skip |= LOGICAL_SIDE_I_START;
|
2009-05-12 02:04:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-18 22:12:42 +00:00
|
|
|
return skip;
|
|
|
|
}
|
1999-04-20 00:25:12 +00:00
|
|
|
|
2010-08-31 18:54:44 +00:00
|
|
|
nscoord
|
|
|
|
nsInlineFrame::GetBaseline() const
|
|
|
|
{
|
2011-08-03 18:30:58 +00:00
|
|
|
return mBaseline;
|
2011-03-29 00:17:16 +00:00
|
|
|
}
|
|
|
|
|
2002-08-10 07:59:44 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2012-09-28 21:53:44 +00:00
|
|
|
a11y::AccType
|
|
|
|
nsInlineFrame::AccessibleType()
|
2002-08-10 07:59:44 +00:00
|
|
|
{
|
|
|
|
// Broken image accessibles are created here, because layout
|
|
|
|
// replaces the image or image control frame with an inline frame
|
2003-11-19 01:20:56 +00:00
|
|
|
nsIAtom *tagAtom = mContent->Tag();
|
2012-09-28 21:53:44 +00:00
|
|
|
if (tagAtom == nsGkAtoms::input) // Broken <input type=image ... />
|
2012-12-18 01:25:52 +00:00
|
|
|
return a11y::eHTMLButtonType;
|
2012-09-28 21:53:44 +00:00
|
|
|
if (tagAtom == nsGkAtoms::img) // Create accessible for broken <img>
|
2013-06-12 09:13:34 +00:00
|
|
|
return a11y::eHyperTextType;
|
2012-09-28 21:53:44 +00:00
|
|
|
|
2012-12-12 10:04:12 +00:00
|
|
|
return a11y::eNoType;
|
2002-08-10 07:59:44 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1999-04-20 00:25:12 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// nsLineFrame implementation
|
|
|
|
|
2005-11-04 02:38:33 +00:00
|
|
|
nsIFrame*
|
2006-03-26 21:30:36 +00:00
|
|
|
NS_NewFirstLineFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
1999-04-20 00:25:12 +00:00
|
|
|
{
|
2006-03-26 21:30:36 +00:00
|
|
|
return new (aPresShell) nsFirstLineFrame(aContext);
|
1999-04-20 00:25:12 +00:00
|
|
|
}
|
|
|
|
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsFirstLineFrame)
|
|
|
|
|
2013-04-26 08:49:07 +00:00
|
|
|
void
|
|
|
|
nsFirstLineFrame::Init(nsIContent* aContent, nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
|
|
|
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 11:42:34 +00:00
|
|
|
MOZ_ASSERT(FirstInFlow() == aPrevInFlow);
|
2013-04-26 08:49:07 +00: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 11:42:34 +00:00
|
|
|
MOZ_ASSERT(FirstInFlow() != aPrevInFlow);
|
2013-04-26 08:49:07 +00:00
|
|
|
MOZ_ASSERT(aPrevInFlow->StyleContext()->GetPseudo() ==
|
|
|
|
nsCSSAnonBoxes::mozLineFrame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-05 23:31:14 +00:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-02-18 07:47:48 +00:00
|
|
|
nsresult
|
2001-11-14 01:33:42 +00:00
|
|
|
nsFirstLineFrame::GetFrameName(nsAString& aResult) const
|
1999-04-20 00:25:12 +00:00
|
|
|
{
|
2001-11-14 01:33:42 +00:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("Line"), aResult);
|
1999-04-20 00:25:12 +00:00
|
|
|
}
|
1999-11-01 22:12:45 +00:00
|
|
|
#endif
|
1999-04-20 00:25:12 +00:00
|
|
|
|
2003-10-31 20:19:18 +00:00
|
|
|
nsIAtom*
|
|
|
|
nsFirstLineFrame::GetType() const
|
1999-04-20 00:25:12 +00:00
|
|
|
{
|
2006-12-26 17:47:52 +00:00
|
|
|
return nsGkAtoms::lineFrame;
|
1999-04-20 00:25:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame*
|
2007-04-21 00:42:58 +00:00
|
|
|
nsFirstLineFrame::PullOneFrame(nsPresContext* aPresContext, InlineReflowState& irs,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool* aIsComplete)
|
1999-04-20 00:25:12 +00:00
|
|
|
{
|
1999-11-01 15:24:57 +00:00
|
|
|
nsIFrame* frame = nsInlineFrame::PullOneFrame(aPresContext, irs, aIsComplete);
|
2006-02-21 21:33:47 +00:00
|
|
|
if (frame && !GetPrevInFlow()) {
|
1999-04-20 00:25:12 +00:00
|
|
|
// We are a first-line frame. Fixup the child frames
|
|
|
|
// style-context that we just pulled.
|
2006-03-16 01:30:38 +00:00
|
|
|
NS_ASSERTION(frame->GetParent() == this, "Incorrect parent?");
|
2013-07-20 19:14:25 +00:00
|
|
|
aPresContext->RestyleManager()->ReparentStyleContext(frame);
|
2014-04-08 05:13:28 +00:00
|
|
|
nsLayoutUtils::MarkDescendantsDirty(frame);
|
1999-04-20 00:25:12 +00:00
|
|
|
}
|
|
|
|
return frame;
|
|
|
|
}
|
|
|
|
|
2014-02-18 07:47:48 +00:00
|
|
|
nsresult
|
2004-07-31 23:15:21 +00:00
|
|
|
nsFirstLineFrame::Reflow(nsPresContext* aPresContext,
|
2000-03-12 03:14:11 +00:00
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1999-04-20 00:25:12 +00:00
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
if (nullptr == aReflowState.mLineLayout) {
|
2000-03-12 03:14:11 +00:00
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
|
2013-04-23 01:45:26 +00:00
|
|
|
nsIFrame* lineContainer = aReflowState.mLineLayout->LineContainerFrame();
|
2007-04-21 00:42:58 +00:00
|
|
|
|
1999-04-20 00:25:12 +00:00
|
|
|
// Check for an overflow list with our prev-in-flow
|
2006-02-21 21:33:47 +00:00
|
|
|
nsFirstLineFrame* prevInFlow = (nsFirstLineFrame*)GetPrevInFlow();
|
2013-04-01 15:26:02 +00:00
|
|
|
if (prevInFlow) {
|
|
|
|
AutoFrameListPtr prevOverflowFrames(aPresContext,
|
|
|
|
prevInFlow->StealOverflowFrames());
|
1999-10-21 05:11:43 +00:00
|
|
|
if (prevOverflowFrames) {
|
2007-04-21 00:42:58 +00:00
|
|
|
// Assign all floats to our block if necessary
|
|
|
|
if (lineContainer && lineContainer->GetPrevContinuation()) {
|
2009-07-28 12:51:09 +00:00
|
|
|
ReparentFloatsForInlineChild(lineContainer,
|
|
|
|
prevOverflowFrames->FirstChild(),
|
2011-10-17 14:59:28 +00:00
|
|
|
true);
|
2007-04-21 00:42:58 +00:00
|
|
|
}
|
2009-07-28 12:51:09 +00:00
|
|
|
const nsFrameList::Slice& newFrames =
|
2012-07-30 14:20:58 +00:00
|
|
|
mFrames.InsertFrames(this, nullptr, *prevOverflowFrames);
|
2010-04-02 06:07:43 +00:00
|
|
|
ReparentChildListStyle(aPresContext, newFrames, this);
|
1999-04-20 00:25:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-17 13:30:24 +00:00
|
|
|
// It's also possible that we have an overflow list for ourselves.
|
|
|
|
DrainSelfOverflowList();
|
1999-04-20 00:25:12 +00:00
|
|
|
|
|
|
|
// Set our own reflow state (additional state above and beyond
|
|
|
|
// aReflowState)
|
|
|
|
InlineReflowState irs;
|
2012-07-30 14:20:58 +00:00
|
|
|
irs.mPrevFrame = nullptr;
|
2007-04-21 00:42:58 +00:00
|
|
|
irs.mLineContainer = lineContainer;
|
2009-12-15 20:08:59 +00:00
|
|
|
irs.mLineLayout = aReflowState.mLineLayout;
|
2006-02-21 21:33:47 +00:00
|
|
|
irs.mNextInFlow = (nsInlineFrame*) GetNextInFlow();
|
1999-04-20 00:25:12 +00:00
|
|
|
|
|
|
|
nsresult rv;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool wasEmpty = mFrames.IsEmpty();
|
1999-04-20 00:25:12 +00: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-29 06:19:26 +00:00
|
|
|
bool complete;
|
1999-11-24 06:03:41 +00:00
|
|
|
PullOneFrame(aPresContext, irs, &complete);
|
1999-04-20 00:25:12 +00:00
|
|
|
}
|
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
if (nullptr == GetPrevInFlow()) {
|
1999-11-01 15:24:57 +00: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-29 06:19:26 +00:00
|
|
|
bool complete;
|
1999-11-24 06:03:41 +00:00
|
|
|
nsIFrame* frame = PullOneFrame(aPresContext, irs, &complete);
|
1999-11-01 15:24:57 +00:00
|
|
|
if (!frame) {
|
|
|
|
break;
|
1999-04-20 00:25:12 +00:00
|
|
|
}
|
1999-11-01 15:24:57 +00:00
|
|
|
irs.mPrevFrame = frame;
|
1999-04-20 00:25:12 +00:00
|
|
|
}
|
2012-07-30 14:20:58 +00:00
|
|
|
irs.mPrevFrame = nullptr;
|
1999-04-20 00:25:12 +00:00
|
|
|
}
|
1999-11-01 15:24:57 +00:00
|
|
|
|
2007-01-18 01:20:09 +00:00
|
|
|
NS_ASSERTION(!aReflowState.mLineLayout->GetInFirstLine(),
|
|
|
|
"Nested first-line frames? BOGUS");
|
2011-10-17 14:59:28 +00:00
|
|
|
aReflowState.mLineLayout->SetInFirstLine(true);
|
1999-11-24 06:03:41 +00:00
|
|
|
rv = ReflowFrames(aPresContext, aReflowState, irs, aMetrics, aStatus);
|
2011-10-17 14:59:28 +00:00
|
|
|
aReflowState.mLineLayout->SetInFirstLine(false);
|
1999-11-01 15:24:57 +00:00
|
|
|
|
2011-04-29 23:02:33 +00:00
|
|
|
ReflowAbsoluteFrames(aPresContext, aMetrics, aReflowState, aStatus);
|
|
|
|
|
2004-08-25 13:03:28 +00:00
|
|
|
// Note: the line layout code will properly compute our overflow state for us
|
1999-11-01 15:24:57 +00:00
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2009-07-24 13:32:32 +00:00
|
|
|
/* virtual */ void
|
|
|
|
nsFirstLineFrame::PullOverflowsFromPrevInFlow()
|
|
|
|
{
|
|
|
|
nsFirstLineFrame* prevInFlow = static_cast<nsFirstLineFrame*>(GetPrevInFlow());
|
|
|
|
if (prevInFlow) {
|
2013-04-01 15:26:02 +00:00
|
|
|
nsPresContext* presContext = PresContext();
|
|
|
|
AutoFrameListPtr prevOverflowFrames(presContext,
|
|
|
|
prevInFlow->StealOverflowFrames());
|
2009-07-24 13:32:32 +00:00
|
|
|
if (prevOverflowFrames) {
|
|
|
|
// Assume that our prev-in-flow has the same line container that we do.
|
2009-07-28 12:51:09 +00:00
|
|
|
const nsFrameList::Slice& newFrames =
|
2012-07-30 14:20:58 +00:00
|
|
|
mFrames.InsertFrames(this, nullptr, *prevOverflowFrames);
|
2013-04-01 15:26:02 +00:00
|
|
|
ReparentChildListStyle(presContext, newFrames, this);
|
2009-07-24 13:32:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-17 13:30:24 +00: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;
|
|
|
|
}
|