2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04: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 22:29:03 +04:00
|
|
|
|
|
|
|
/* rendering object for CSS display:inline objects */
|
|
|
|
|
1999-04-20 04:25:12 +04:00
|
|
|
#include "nsInlineFrame.h"
|
2013-02-01 20:01:47 +04:00
|
|
|
#include "nsLineLayout.h"
|
2002-09-25 02:13:20 +04:00
|
|
|
#include "nsBlockFrame.h"
|
2009-08-31 22:25:35 +04:00
|
|
|
#include "nsPlaceholderFrame.h"
|
2007-01-30 03:06:41 +03:00
|
|
|
#include "nsGkAtoms.h"
|
2003-02-22 03:32:13 +03:00
|
|
|
#include "nsStyleContext.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
2011-04-08 05:04:40 +04:00
|
|
|
#include "nsRenderingContext.h"
|
2002-11-17 18:37:56 +03:00
|
|
|
#include "nsCSSAnonBoxes.h"
|
2017-02-13 06:21:33 +03:00
|
|
|
#include "mozilla/RestyleManager.h"
|
|
|
|
#include "mozilla/RestyleManagerInlines.h"
|
2006-04-27 06:45:03 +04:00
|
|
|
#include "nsDisplayList.h"
|
2012-10-26 17:32:10 +04:00
|
|
|
#include "mozilla/Likely.h"
|
2014-09-08 06:34:20 +04:00
|
|
|
#include "SVGTextFrame.h"
|
2017-03-03 23:45:40 +03:00
|
|
|
#include "nsStyleChangeList.h"
|
2016-02-24 10:01:11 +03:00
|
|
|
#include "mozilla/StyleSetHandle.h"
|
|
|
|
#include "mozilla/StyleSetHandleInlines.h"
|
2017-03-03 23:45:40 +03:00
|
|
|
#include "mozilla/ServoStyleSet.h"
|
1999-03-05 07:25:57 +03:00
|
|
|
|
2000-03-23 02:19:10 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
#undef NOISY_PUSHING
|
|
|
|
#endif
|
1999-02-02 20:32:09 +03:00
|
|
|
|
2012-09-29 01:53:44 +04:00
|
|
|
using namespace mozilla;
|
2013-04-01 19:26:02 +04:00
|
|
|
using namespace mozilla::layout;
|
2012-09-29 01:53:44 +04:00
|
|
|
|
2000-03-23 02:19:10 +03:00
|
|
|
|
1999-04-19 23:10:15 +04:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
1999-02-01 20:27:56 +03:00
|
|
|
// Basic nsInlineFrame methods
|
1998-09-23 06:25:26 +04:00
|
|
|
|
2014-05-25 02:20:40 +04:00
|
|
|
nsInlineFrame*
|
2006-03-27 01:30:36 +04:00
|
|
|
NS_NewInlineFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
1998-09-12 08:46:35 +04:00
|
|
|
{
|
2006-03-27 01:30:36 +04:00
|
|
|
return new (aPresShell) nsInlineFrame(aContext);
|
1998-09-12 08:46:35 +04:00
|
|
|
}
|
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsInlineFrame)
|
|
|
|
|
2009-01-12 22:20:59 +03:00
|
|
|
NS_QUERYFRAME_HEAD(nsInlineFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsInlineFrame)
|
2011-12-28 00:18:48 +04:00
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
|
1998-06-28 02:56:09 +04:00
|
|
|
|
2014-01-06 03:31:14 +04:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-02-18 11:47:48 +04:00
|
|
|
nsresult
|
2001-11-14 04:33:42 +03:00
|
|
|
nsInlineFrame::GetFrameName(nsAString& aResult) const
|
1999-11-01 18:24:57 +03:00
|
|
|
{
|
2001-11-14 04:33:42 +03:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("Inline"), aResult);
|
1999-11-01 18:24:57 +03:00
|
|
|
}
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|
1998-06-28 02:56:09 +04:00
|
|
|
|
2003-10-31 23:19:18 +03:00
|
|
|
nsIAtom*
|
|
|
|
nsInlineFrame::GetType() const
|
1999-11-01 18:24:57 +03:00
|
|
|
{
|
2006-12-26 20:47:52 +03:00
|
|
|
return nsGkAtoms::inlineFrame;
|
1998-06-18 20:25:41 +04:00
|
|
|
}
|
|
|
|
|
2013-02-11 10:22:20 +04:00
|
|
|
void
|
|
|
|
nsInlineFrame::InvalidateFrame(uint32_t aDisplayItemKey)
|
|
|
|
{
|
|
|
|
if (IsSVGText()) {
|
|
|
|
nsIFrame* svgTextFrame =
|
|
|
|
nsLayoutUtils::GetClosestFrameOfType(GetParent(),
|
2013-12-20 20:38:51 +04:00
|
|
|
nsGkAtoms::svgTextFrame);
|
2013-02-11 10:22:20 +04:00
|
|
|
svgTextFrame->InvalidateFrame();
|
|
|
|
return;
|
|
|
|
}
|
2016-04-18 09:22:22 +03:00
|
|
|
nsContainerFrame::InvalidateFrame(aDisplayItemKey);
|
2013-02-11 10:22:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsInlineFrame::InvalidateFrameWithRect(const nsRect& aRect, uint32_t aDisplayItemKey)
|
|
|
|
{
|
|
|
|
if (IsSVGText()) {
|
|
|
|
nsIFrame* svgTextFrame =
|
|
|
|
nsLayoutUtils::GetClosestFrameOfType(GetParent(),
|
2013-12-20 20:38:51 +04:00
|
|
|
nsGkAtoms::svgTextFrame);
|
2013-02-11 10:22:20 +04:00
|
|
|
svgTextFrame->InvalidateFrame();
|
|
|
|
return;
|
|
|
|
}
|
2016-04-18 09:22:22 +03:00
|
|
|
nsContainerFrame::InvalidateFrameWithRect(aRect, aDisplayItemKey);
|
2013-02-11 10:22:20 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static inline bool
|
2010-08-31 20:05:12 +04:00
|
|
|
IsMarginZero(const nsStyleCoord &aCoord)
|
2001-10-25 05:08:40 +04:00
|
|
|
{
|
2010-08-31 20:05:12 +04:00
|
|
|
return aCoord.GetUnit() == eStyleUnit_Auto ||
|
2010-09-09 19:21:46 +04:00
|
|
|
nsLayoutUtils::IsMarginZero(aCoord);
|
2001-10-25 05:08:40 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
/* virtual */ bool
|
2004-11-15 08:01:11 +03:00
|
|
|
nsInlineFrame::IsSelfEmpty()
|
2001-10-25 05:08:40 +04:00
|
|
|
{
|
2002-11-28 22:29:28 +03: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-25 00:51:50 +03:00
|
|
|
if (GetPresContext()->CompatibilityMode() == eCompatibility_FullStandards) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2001-10-25 05:08:40 +04:00
|
|
|
}
|
2002-11-28 22:29:28 +03:00
|
|
|
#endif
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStyleMargin* margin = StyleMargin();
|
|
|
|
const nsStyleBorder* border = StyleBorder();
|
|
|
|
const nsStylePadding* padding = StylePadding();
|
2015-01-17 11:51:37 +03:00
|
|
|
// Block-start and -end ignored, since they shouldn't affect things, but this
|
2002-11-28 22:29:28 +03:00
|
|
|
// doesn't really match with nsLineLayout.cpp's setting of
|
|
|
|
// ZeroEffectiveSpanBox, anymore, so what should this really be?
|
2015-01-17 11:51:37 +03:00
|
|
|
WritingMode wm = GetWritingMode();
|
|
|
|
bool haveStart, haveEnd;
|
|
|
|
// Initially set up haveStart and haveEnd in terms of visual (LTR/TTB)
|
|
|
|
// coordinates; we'll exchange them later if bidi-RTL is in effect to
|
|
|
|
// get logical start and end flags.
|
|
|
|
if (wm.IsVertical()) {
|
|
|
|
haveStart =
|
2016-11-18 13:12:25 +03:00
|
|
|
border->GetComputedBorderWidth(eSideTop) != 0 ||
|
2015-01-17 11:51:37 +03:00
|
|
|
!nsLayoutUtils::IsPaddingZero(padding->mPadding.GetTop()) ||
|
|
|
|
!IsMarginZero(margin->mMargin.GetTop());
|
|
|
|
haveEnd =
|
2016-11-18 13:12:25 +03:00
|
|
|
border->GetComputedBorderWidth(eSideBottom) != 0 ||
|
2015-01-17 11:51:37 +03:00
|
|
|
!nsLayoutUtils::IsPaddingZero(padding->mPadding.GetBottom()) ||
|
|
|
|
!IsMarginZero(margin->mMargin.GetBottom());
|
|
|
|
} else {
|
|
|
|
haveStart =
|
2016-11-18 13:12:25 +03:00
|
|
|
border->GetComputedBorderWidth(eSideLeft) != 0 ||
|
2015-01-17 11:51:37 +03:00
|
|
|
!nsLayoutUtils::IsPaddingZero(padding->mPadding.GetLeft()) ||
|
|
|
|
!IsMarginZero(margin->mMargin.GetLeft());
|
|
|
|
haveEnd =
|
2016-11-18 13:12:25 +03:00
|
|
|
border->GetComputedBorderWidth(eSideRight) != 0 ||
|
2015-01-17 11:51:37 +03:00
|
|
|
!nsLayoutUtils::IsPaddingZero(padding->mPadding.GetRight()) ||
|
|
|
|
!IsMarginZero(margin->mMargin.GetRight());
|
|
|
|
}
|
|
|
|
if (haveStart || haveEnd) {
|
2014-05-05 21:55:54 +04: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) &&
|
2016-08-26 10:14:32 +03:00
|
|
|
StyleBorder()->mBoxDecorationBreak == StyleBoxDecorationBreak::Slice) {
|
2015-01-17 11:51:37 +03:00
|
|
|
// When direction=rtl, we need to consider logical rather than visual
|
|
|
|
// start and end, so swap the flags.
|
|
|
|
if (!wm.IsBidiLTR()) {
|
|
|
|
Swap(haveStart, haveEnd);
|
2009-09-18 22:00:21 +04:00
|
|
|
}
|
2014-02-07 05:45:33 +04: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 22:00:21 +04:00
|
|
|
// general way?
|
|
|
|
|
|
|
|
// Get the first continuation eagerly, as a performance optimization, to
|
|
|
|
// avoid having to get it twice..
|
2013-09-25 15:42:34 +04:00
|
|
|
nsIFrame* firstCont = FirstContinuation();
|
2009-09-18 22:00:21 +04:00
|
|
|
return
|
2013-10-01 01:26:04 +04:00
|
|
|
(!haveStart || firstCont->FrameIsNonFirstInIBSplit()) &&
|
|
|
|
(!haveEnd || firstCont->FrameIsNonLastInIBSplit());
|
2009-09-18 22:00:21 +04:00
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2001-10-25 05:08:40 +04:00
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2004-11-14 23:22:58 +03:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2004-11-14 23:22:58 +03:00
|
|
|
nsInlineFrame::IsEmpty()
|
|
|
|
{
|
2004-11-15 08:01:11 +03:00
|
|
|
if (!IsSelfEmpty()) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2004-11-14 23:22:58 +03:00
|
|
|
}
|
2001-10-25 05:08:40 +04:00
|
|
|
|
2015-06-29 23:02:21 +03:00
|
|
|
for (nsIFrame* kid : mFrames) {
|
2003-11-11 02:36:06 +03:00
|
|
|
if (!kid->IsEmpty())
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2001-10-25 05:08:40 +04:00
|
|
|
}
|
2004-11-14 23:22:58 +03:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2001-10-25 05:08:40 +04:00
|
|
|
}
|
|
|
|
|
2014-03-13 18:14:37 +04:00
|
|
|
nsIFrame::FrameSearchResult
|
2012-08-22 19:56:38 +04:00
|
|
|
nsInlineFrame::PeekOffsetCharacter(bool aForward, int32_t* aOffset,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aRespectClusters)
|
2006-09-12 00:43:01 +04:00
|
|
|
{
|
|
|
|
// Override the implementation in nsFrame, to skip empty inline frames
|
|
|
|
NS_ASSERTION (aOffset && *aOffset <= 1, "aOffset out of range");
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t startOffset = *aOffset;
|
2006-09-12 00:43:01 +04: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 18:14:37 +04:00
|
|
|
return CONTINUE;
|
2006-09-12 00:43:01 +04:00
|
|
|
}
|
|
|
|
|
2014-07-07 20:08:42 +04:00
|
|
|
void
|
|
|
|
nsInlineFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
|
|
|
{
|
|
|
|
nsFrameList* overflowFrames = GetOverflowFrames();
|
|
|
|
if (overflowFrames) {
|
|
|
|
// Fixup the parent pointers for any child frames on the OverflowList.
|
|
|
|
// nsIFrame::DestroyFrom depends on that to find the sticky scroll
|
|
|
|
// container (an ancestor).
|
|
|
|
nsIFrame* lineContainer = nsLayoutUtils::FindNearestBlockAncestor(this);
|
|
|
|
DrainSelfOverflowListInternal(eForDestroy, lineContainer);
|
|
|
|
}
|
|
|
|
nsContainerFrame::DestroyFrom(aDestructRoot);
|
|
|
|
}
|
|
|
|
|
2015-04-16 12:04:19 +03:00
|
|
|
nsresult
|
2016-06-10 03:56:23 +03:00
|
|
|
nsInlineFrame::StealFrame(nsIFrame* aChild)
|
2015-04-16 12:04:19 +03:00
|
|
|
{
|
2016-06-10 03:56:23 +03:00
|
|
|
if (MaybeStealOverflowContainerFrame(aChild)) {
|
|
|
|
return NS_OK;
|
2015-04-16 12:04:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsInlineFrame* parent = this;
|
|
|
|
bool removed = false;
|
|
|
|
do {
|
|
|
|
removed = parent->mFrames.StartRemoveFrame(aChild);
|
|
|
|
if (removed) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We didn't find the child in our principal child list.
|
|
|
|
// Maybe it's on the overflow list?
|
|
|
|
nsFrameList* frameList = parent->GetOverflowFrames();
|
|
|
|
if (frameList) {
|
|
|
|
removed = frameList->ContinueRemoveFrame(aChild);
|
|
|
|
if (frameList->IsEmpty()) {
|
|
|
|
parent->DestroyOverflowList();
|
|
|
|
}
|
|
|
|
if (removed) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Due to our "lazy reparenting" optimization 'aChild' might not actually
|
|
|
|
// be on any of our child lists, but instead in one of our next-in-flows.
|
|
|
|
parent = static_cast<nsInlineFrame*>(parent->GetNextInFlow());
|
|
|
|
} while (parent);
|
|
|
|
|
|
|
|
MOZ_ASSERT(removed, "nsInlineFrame::StealFrame: can't find aChild");
|
|
|
|
return removed ? NS_OK : NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
2013-02-14 15:12:27 +04:00
|
|
|
void
|
2006-01-26 05:29:17 +03:00
|
|
|
nsInlineFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
2002-12-11 07:00:18 +03:00
|
|
|
{
|
2013-02-14 15:08:08 +04:00
|
|
|
BuildDisplayListForInline(aBuilder, aDirtyRect, aLists);
|
2011-12-28 00:18:48 +04:00
|
|
|
|
2002-12-11 07:00:18 +03: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 15:08:08 +04:00
|
|
|
DisplaySelectionOverlay(aBuilder, aLists.Content());
|
2002-12-11 07:00:18 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-02-01 20:27:56 +03: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 08:38:33 +03:00
|
|
|
/* virtual */ void
|
2014-07-24 21:03:25 +04:00
|
|
|
nsInlineFrame::AddInlineMinISize(nsRenderingContext *aRenderingContext,
|
|
|
|
nsIFrame::InlineMinISizeData *aData)
|
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 08:38:33 +03:00
|
|
|
{
|
2014-07-24 21:03:26 +04:00
|
|
|
DoInlineIntrinsicISize(aRenderingContext, aData, nsLayoutUtils::MIN_ISIZE);
|
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 08:38:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ void
|
2014-07-24 21:03:25 +04:00
|
|
|
nsInlineFrame::AddInlinePrefISize(nsRenderingContext *aRenderingContext,
|
|
|
|
nsIFrame::InlinePrefISizeData *aData)
|
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 08:38:33 +03:00
|
|
|
{
|
2014-07-24 21:03:26 +04:00
|
|
|
DoInlineIntrinsicISize(aRenderingContext, aData, nsLayoutUtils::PREF_ISIZE);
|
2016-08-23 02:29:45 +03:00
|
|
|
aData->mLineIsEmpty = false;
|
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 08:38:33 +03:00
|
|
|
}
|
|
|
|
|
2014-08-24 18:34:44 +04:00
|
|
|
/* virtual */
|
|
|
|
LogicalSize
|
2011-04-08 05:04:40 +04:00
|
|
|
nsInlineFrame::ComputeSize(nsRenderingContext *aRenderingContext,
|
2014-08-24 18:34:44 +04:00
|
|
|
WritingMode aWM,
|
|
|
|
const LogicalSize& aCBSize,
|
|
|
|
nscoord aAvailableISize,
|
|
|
|
const LogicalSize& aMargin,
|
|
|
|
const LogicalSize& aBorder,
|
|
|
|
const LogicalSize& aPadding,
|
2014-11-11 14:02:41 +03:00
|
|
|
ComputeSizeFlags 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 08:38:33 +03:00
|
|
|
{
|
|
|
|
// Inlines and text don't compute size before reflow.
|
2014-08-24 18:34:44 +04:00
|
|
|
return LogicalSize(aWM, NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
|
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 08:38:33 +03:00
|
|
|
}
|
|
|
|
|
2007-10-12 12:30:54 +04:00
|
|
|
nsRect
|
2015-12-16 00:56:41 +03:00
|
|
|
nsInlineFrame::ComputeTightBounds(DrawTarget* aDrawTarget) const
|
2007-10-12 12:30:54 +04:00
|
|
|
{
|
|
|
|
// be conservative
|
2013-02-16 09:38:33 +04:00
|
|
|
if (StyleContext()->HasTextDecorationLines()) {
|
2010-10-07 08:25:46 +04:00
|
|
|
return GetVisualOverflowRect();
|
2011-04-23 09:16:41 +04:00
|
|
|
}
|
2015-12-16 00:56:41 +03:00
|
|
|
return ComputeSimpleTightBounds(aDrawTarget);
|
2007-10-12 12:30:54 +04:00
|
|
|
}
|
|
|
|
|
2007-04-21 04:42:58 +04:00
|
|
|
void
|
|
|
|
nsInlineFrame::ReparentFloatsForInlineChild(nsIFrame* aOurLineContainer,
|
|
|
|
nsIFrame* aFrame,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aReparentSiblings)
|
2007-04-21 04:42:58 +04:00
|
|
|
{
|
2009-07-28 16:51:09 +04:00
|
|
|
// XXXbz this would be better if it took a nsFrameList or a frame
|
|
|
|
// list slice....
|
2007-04-21 04:42:58 +04:00
|
|
|
NS_ASSERTION(aOurLineContainer->GetNextContinuation() ||
|
|
|
|
aOurLineContainer->GetPrevContinuation(),
|
|
|
|
"Don't call this when we have no continuation, it's a waste");
|
2007-07-19 08:32:08 +04:00
|
|
|
if (!aFrame) {
|
|
|
|
NS_ASSERTION(aReparentSiblings, "Why did we get called?");
|
|
|
|
return;
|
|
|
|
}
|
2007-04-21 04:42:58 +04:00
|
|
|
|
2016-01-27 08:58:53 +03:00
|
|
|
nsBlockFrame* frameBlock = nsLayoutUtils::GetFloatContainingBlock(aFrame);
|
|
|
|
if (!frameBlock || frameBlock == aOurLineContainer) {
|
2007-04-21 04:42:58 +04:00
|
|
|
return;
|
2016-01-27 08:58:53 +03:00
|
|
|
}
|
2007-04-21 04:42:58 +04:00
|
|
|
|
2008-07-14 02:10:23 +04:00
|
|
|
nsBlockFrame* ourBlock = nsLayoutUtils::GetAsBlock(aOurLineContainer);
|
|
|
|
NS_ASSERTION(ourBlock, "Not a block, but broke vertically?");
|
2007-04-21 04:42:58 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
while (true) {
|
2013-02-28 03:05:45 +04:00
|
|
|
ourBlock->ReparentFloats(aFrame, frameBlock, false);
|
2007-04-21 04:42:58 +04: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-23 02:42:45 +03:00
|
|
|
static void
|
2010-04-02 10:07:43 +04:00
|
|
|
ReparentChildListStyle(nsPresContext* aPresContext,
|
2009-12-23 02:42:45 +03:00
|
|
|
const nsFrameList::Slice& aFrames,
|
|
|
|
nsIFrame* aParentFrame)
|
|
|
|
{
|
2017-02-13 06:21:33 +03:00
|
|
|
RestyleManager* restyleManager = aPresContext->RestyleManager();
|
2009-12-23 02:42:45 +03:00
|
|
|
|
|
|
|
for (nsFrameList::Enumerator e(aFrames); !e.AtEnd(); e.Next()) {
|
|
|
|
NS_ASSERTION(e.get()->GetParent() == aParentFrame, "Bogus parentage");
|
2013-07-20 23:14:25 +04:00
|
|
|
restyleManager->ReparentStyleContext(e.get());
|
2014-04-08 09:13:28 +04:00
|
|
|
nsLayoutUtils::MarkDescendantsDirty(e.get());
|
2009-12-23 02:42:45 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-13 04:47:52 +04:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsInlineFrame::Reflow(nsPresContext* aPresContext,
|
2016-07-21 13:36:38 +03:00
|
|
|
ReflowOutput& aMetrics,
|
2016-07-21 13:36:39 +03:00
|
|
|
const ReflowInput& aReflowInput,
|
1999-02-01 20:27:56 +03:00
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
2015-03-30 01:38:40 +03:00
|
|
|
MarkInReflow();
|
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 08:38:33 +03:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsInlineFrame");
|
2016-07-21 13:36:39 +03:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowInput, aMetrics, aStatus);
|
|
|
|
if (nullptr == aReflowInput.mLineLayout) {
|
|
|
|
NS_ERROR("must have non-null aReflowInput.mLineLayout");
|
2014-05-13 04:47:52 +04:00
|
|
|
return;
|
1999-03-19 00:03:25 +03:00
|
|
|
}
|
2016-07-21 13:36:39 +03:00
|
|
|
if (IsFrameTreeTooDeep(aReflowInput, aMetrics, aStatus)) {
|
2014-05-13 04:47:52 +04:00
|
|
|
return;
|
2012-09-08 04:33:58 +04:00
|
|
|
}
|
2000-03-12 06:14:11 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool lazilySetParentPointer = false;
|
2000-03-12 06:14:11 +03:00
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
nsIFrame* lineContainer = aReflowInput.mLineLayout->LineContainerFrame();
|
2007-04-21 04:42:58 +04:00
|
|
|
|
|
|
|
// Check for an overflow list with our prev-in-flow
|
2006-02-22 00:33:47 +03:00
|
|
|
nsInlineFrame* prevInFlow = (nsInlineFrame*)GetPrevInFlow();
|
2013-04-01 19:26:02 +04:00
|
|
|
if (prevInFlow) {
|
|
|
|
AutoFrameListPtr prevOverflowFrames(aPresContext,
|
|
|
|
prevInFlow->StealOverflowFrames());
|
2000-03-12 06:14:11 +03:00
|
|
|
if (prevOverflowFrames) {
|
|
|
|
// When pushing and pulling frames we need to check for whether any
|
|
|
|
// views need to be reparented.
|
2014-02-07 02:07:47 +04:00
|
|
|
nsContainerFrame::ReparentFrameViewList(*prevOverflowFrames, prevInFlow,
|
|
|
|
this);
|
2000-03-12 06:14:11 +03:00
|
|
|
|
2009-02-07 11:34:27 +03: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 16:51:09 +04:00
|
|
|
// If our child list is empty, just put the new frames into it.
|
2000-03-12 06:14:11 +03: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 16:53:20 +04:00
|
|
|
mFrames.SetFrames(*prevOverflowFrames);
|
2011-10-17 18:59:28 +04:00
|
|
|
lazilySetParentPointer = true;
|
2000-03-12 06:14:11 +03:00
|
|
|
} else {
|
2007-04-21 04:42:58 +04:00
|
|
|
// Assign all floats to our block if necessary
|
|
|
|
if (lineContainer && lineContainer->GetPrevContinuation()) {
|
2009-07-28 16:51:09 +04:00
|
|
|
ReparentFloatsForInlineChild(lineContainer,
|
|
|
|
prevOverflowFrames->FirstChild(),
|
2011-10-17 18:59:28 +04:00
|
|
|
true);
|
2007-04-21 04:42:58 +04:00
|
|
|
}
|
2000-03-12 06:14:11 +03:00
|
|
|
// Insert the new frames at the beginning of the child list
|
|
|
|
// and set their parent pointer
|
2009-12-23 02:42:45 +03:00
|
|
|
const nsFrameList::Slice& newFrames =
|
2012-07-30 18:20:58 +04:00
|
|
|
mFrames.InsertFrames(this, nullptr, *prevOverflowFrames);
|
2009-12-23 02:42:45 +03: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.
|
2016-07-21 13:36:39 +03:00
|
|
|
if (aReflowInput.mLineLayout->GetInFirstLine()) {
|
2010-04-02 10:07:43 +04:00
|
|
|
ReparentChildListStyle(aPresContext, newFrames, this);
|
2009-12-23 02:42:45 +03:00
|
|
|
}
|
2000-03-12 06:14:11 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// It's also possible that we have an overflow list for ourselves
|
2000-03-22 07:06:37 +03: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 08:38:33 +03:00
|
|
|
if (GetStateBits() & NS_FRAME_FIRST_REFLOW) {
|
2000-03-22 07:06:37 +03: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 16:51:09 +04:00
|
|
|
nsFrameList* overflowFrames = GetOverflowFrames();
|
|
|
|
NS_ASSERTION(!overflowFrames || overflowFrames->IsEmpty(),
|
|
|
|
"overflow list is not empty for initial reflow");
|
2000-03-22 07:06:37 +03: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 08:38:33 +03:00
|
|
|
if (!(GetStateBits() & NS_FRAME_FIRST_REFLOW)) {
|
2013-12-17 17:30:24 +04:00
|
|
|
DrainFlags flags =
|
|
|
|
lazilySetParentPointer ? eDontReparentFrames : DrainFlags(0);
|
2016-07-21 13:36:39 +03:00
|
|
|
if (aReflowInput.mLineLayout->GetInFirstLine()) {
|
2013-12-17 17:30:24 +04:00
|
|
|
flags = DrainFlags(flags | eInFirstLine);
|
2000-03-12 06:14:11 +03:00
|
|
|
}
|
2013-12-17 17:30:24 +04:00
|
|
|
DrainSelfOverflowListInternal(flags, lineContainer);
|
2000-03-12 06:14:11 +03:00
|
|
|
}
|
1999-02-01 20:27:56 +03:00
|
|
|
|
1999-03-05 07:25:57 +03:00
|
|
|
// Set our own reflow state (additional state above and beyond
|
2016-07-21 13:36:39 +03:00
|
|
|
// aReflowInput)
|
|
|
|
InlineReflowInput irs;
|
2012-07-30 18:20:58 +04:00
|
|
|
irs.mPrevFrame = nullptr;
|
2007-04-21 04:42:58 +04:00
|
|
|
irs.mLineContainer = lineContainer;
|
2016-07-21 13:36:39 +03:00
|
|
|
irs.mLineLayout = aReflowInput.mLineLayout;
|
2006-02-22 00:33:47 +03:00
|
|
|
irs.mNextInFlow = (nsInlineFrame*) GetNextInFlow();
|
2000-03-12 06:14:11 +03:00
|
|
|
irs.mSetParentPointer = lazilySetParentPointer;
|
1999-02-01 20:27:56 +03:00
|
|
|
|
|
|
|
if (mFrames.IsEmpty()) {
|
1999-04-20 04:25:12 +04:00
|
|
|
// Try to pull over one frame before starting so that we know
|
|
|
|
// whether we have an anonymous block or not.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool complete;
|
1999-11-24 09:03:41 +03:00
|
|
|
(void) PullOneFrame(aPresContext, irs, &complete);
|
1999-02-01 20:27:56 +03:00
|
|
|
}
|
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
ReflowFrames(aPresContext, aReflowInput, irs, aMetrics, aStatus);
|
2011-04-30 03:02:33 +04:00
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
ReflowAbsoluteFrames(aPresContext, aMetrics, aReflowInput, aStatus);
|
2011-04-30 03:02:33 +04:00
|
|
|
|
1999-11-01 18:24:57 +03:00
|
|
|
// Note: the line layout code will properly compute our
|
2009-04-06 04:31:50 +04:00
|
|
|
// overflow-rect state for us.
|
1999-02-01 20:27:56 +03:00
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aMetrics);
|
1999-02-01 20:27:56 +03:00
|
|
|
}
|
|
|
|
|
2014-09-08 06:34:20 +04:00
|
|
|
nsresult
|
|
|
|
nsInlineFrame::AttributeChanged(int32_t aNameSpaceID,
|
|
|
|
nsIAtom* aAttribute,
|
|
|
|
int32_t aModType)
|
|
|
|
{
|
|
|
|
nsresult rv =
|
2016-04-18 09:22:22 +03:00
|
|
|
nsContainerFrame::AttributeChanged(aNameSpaceID, aAttribute, aModType);
|
2014-09-08 06:34:20 +04:00
|
|
|
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IsSVGText()) {
|
|
|
|
SVGTextFrame* f = static_cast<SVGTextFrame*>(
|
|
|
|
nsLayoutUtils::GetClosestFrameOfType(this, nsGkAtoms::svgTextFrame));
|
|
|
|
f->HandleAttributeChangeInDescendant(mContent->AsElement(),
|
|
|
|
aNameSpaceID, aAttribute);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-12-17 17:30:24 +04:00
|
|
|
bool
|
|
|
|
nsInlineFrame::DrainSelfOverflowListInternal(DrainFlags aFlags,
|
|
|
|
nsIFrame* aLineContainer)
|
|
|
|
{
|
|
|
|
AutoFrameListPtr overflowFrames(PresContext(), StealOverflowFrames());
|
|
|
|
if (overflowFrames) {
|
|
|
|
// 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);
|
|
|
|
}
|
2014-07-07 20:08:42 +04:00
|
|
|
const bool doReparentSC =
|
|
|
|
(aFlags & eInFirstLine) && !(aFlags & eForDestroy);
|
2017-02-13 06:21:33 +03:00
|
|
|
RestyleManager* restyleManager = PresContext()->RestyleManager();
|
2013-12-17 17:30:24 +04:00
|
|
|
for (nsIFrame* f = firstChild; f; f = f->GetNextSibling()) {
|
|
|
|
f->SetParent(this);
|
2014-07-07 20:08:42 +04:00
|
|
|
if (doReparentSC) {
|
2013-12-17 17:30:24 +04:00
|
|
|
restyleManager->ReparentStyleContext(f);
|
2014-04-08 09:13:28 +04:00
|
|
|
nsLayoutUtils::MarkDescendantsDirty(f);
|
2013-12-17 17:30:24 +04: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 10:19:26 +04: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 08:38:33 +03:00
|
|
|
nsInlineFrame::CanContinueTextRun() const
|
2000-07-29 02:29:28 +04:00
|
|
|
{
|
|
|
|
// We can continue a text run through an inline frame
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2000-01-13 00:52:58 +03:00
|
|
|
}
|
|
|
|
|
2009-07-24 17:32:32 +04:00
|
|
|
/* virtual */ void
|
|
|
|
nsInlineFrame::PullOverflowsFromPrevInFlow()
|
|
|
|
{
|
|
|
|
nsInlineFrame* prevInFlow = static_cast<nsInlineFrame*>(GetPrevInFlow());
|
|
|
|
if (prevInFlow) {
|
2013-04-01 19:26:02 +04:00
|
|
|
nsPresContext* presContext = PresContext();
|
|
|
|
AutoFrameListPtr prevOverflowFrames(presContext,
|
|
|
|
prevInFlow->StealOverflowFrames());
|
2009-07-24 17:32:32 +04:00
|
|
|
if (prevOverflowFrames) {
|
|
|
|
// Assume that our prev-in-flow has the same line container that we do.
|
2014-02-07 02:07:47 +04:00
|
|
|
nsContainerFrame::ReparentFrameViewList(*prevOverflowFrames, prevInFlow,
|
|
|
|
this);
|
2012-07-30 18:20:58 +04:00
|
|
|
mFrames.InsertFrames(this, nullptr, *prevOverflowFrames);
|
2009-07-24 17:32:32 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-13 04:47:52 +04:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsInlineFrame::ReflowFrames(nsPresContext* aPresContext,
|
2016-07-21 13:36:39 +03:00
|
|
|
const ReflowInput& aReflowInput,
|
|
|
|
InlineReflowInput& irs,
|
2016-07-21 13:36:38 +03:00
|
|
|
ReflowOutput& aMetrics,
|
1999-11-01 18:24:57 +03:00
|
|
|
nsReflowStatus& aStatus)
|
1998-10-27 19:52:10 +03:00
|
|
|
{
|
2017-02-14 12:55:48 +03:00
|
|
|
aStatus.Reset();
|
1999-02-01 20:27:56 +03:00
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
nsLineLayout* lineLayout = aReflowInput.mLineLayout;
|
|
|
|
bool inFirstLine = aReflowInput.mLineLayout->GetInFirstLine();
|
2017-02-13 06:21:33 +03:00
|
|
|
RestyleManager* restyleManager = aPresContext->RestyleManager();
|
2016-07-21 13:36:39 +03:00
|
|
|
WritingMode frameWM = aReflowInput.GetWritingMode();
|
|
|
|
WritingMode lineWM = aReflowInput.mLineLayout->mRootSpan->mWritingMode;
|
|
|
|
LogicalMargin framePadding = aReflowInput.ComputedLogicalBorderPadding();
|
2014-03-12 00:23:50 +04:00
|
|
|
nscoord startEdge = 0;
|
2014-05-05 21:55:54 +04:00
|
|
|
const bool boxDecorationBreakClone =
|
|
|
|
MOZ_UNLIKELY(StyleBorder()->mBoxDecorationBreak ==
|
2016-08-26 10:14:32 +03:00
|
|
|
StyleBoxDecorationBreak::Clone);
|
2009-05-12 06:04:58 +04:00
|
|
|
// Don't offset by our start borderpadding if we have a prev continuation or
|
2014-05-05 21:55:54 +04: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 13:39:36 +04:00
|
|
|
startEdge = framePadding.IStart(frameWM);
|
1999-03-19 00:03:25 +03:00
|
|
|
}
|
2016-07-21 13:36:39 +03:00
|
|
|
nscoord availableISize = aReflowInput.AvailableISize();
|
2014-03-12 00:23:50 +04:00
|
|
|
NS_ASSERTION(availableISize != NS_UNCONSTRAINEDSIZE,
|
2007-12-13 00:51:00 +03:00
|
|
|
"should no longer use available widths");
|
2014-03-12 00:23:50 +04:00
|
|
|
// Subtract off inline axis border+padding from availableISize
|
|
|
|
availableISize -= startEdge;
|
2014-06-05 13:39:36 +04:00
|
|
|
availableISize -= framePadding.IEnd(frameWM);
|
2016-07-21 13:36:39 +03:00
|
|
|
lineLayout->BeginSpan(this, &aReflowInput, startEdge,
|
2014-03-12 00:23:50 +04:00
|
|
|
startEdge + availableISize, &mBaseline);
|
1999-02-01 20:27:56 +03:00
|
|
|
|
2013-02-07 05:13:34 +04:00
|
|
|
// First reflow our principal children.
|
1999-02-01 20:27:56 +03:00
|
|
|
nsIFrame* frame = mFrames.FirstChild();
|
2011-09-29 10:19:26 +04:00
|
|
|
bool done = false;
|
2013-02-07 05:13:34 +04:00
|
|
|
while (frame) {
|
|
|
|
// Check if we should lazily set the child frame's parent pointer.
|
2000-03-12 06:14:11 +03:00
|
|
|
if (irs.mSetParentPointer) {
|
2011-09-29 10:19:26 +04:00
|
|
|
bool havePrevBlock =
|
2007-04-21 04:42:58 +04:00
|
|
|
irs.mLineContainer && irs.mLineContainer->GetPrevContinuation();
|
2012-09-08 04:33:58 +04: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 04:42:58 +04:00
|
|
|
if (havePrevBlock) {
|
2012-09-08 04:33:58 +04: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 04:42:58 +04:00
|
|
|
}
|
2012-09-08 04:33:58 +04:00
|
|
|
child->SetParent(this);
|
2009-12-23 02:42:45 +03:00
|
|
|
if (inFirstLine) {
|
2013-07-20 23:14:25 +04:00
|
|
|
restyleManager->ReparentStyleContext(child);
|
2014-04-08 09:13:28 +04:00
|
|
|
nsLayoutUtils::MarkDescendantsDirty(child);
|
2009-12-23 02:42:45 +03:00
|
|
|
}
|
2012-09-08 04:33:58 +04: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 17:32:10 +04:00
|
|
|
if (MOZ_UNLIKELY(child)) {
|
2012-09-08 04:33:58 +04:00
|
|
|
while (child != nextSibling && nextSibling) {
|
|
|
|
nextSibling = nextSibling->GetNextSibling();
|
|
|
|
}
|
|
|
|
if (!nextSibling) {
|
|
|
|
child = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(!child || mFrames.ContainsFrame(child));
|
|
|
|
} while (child);
|
2008-12-07 21:21:40 +03: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) {
|
2016-01-29 17:42:14 +03:00
|
|
|
nsIFrame* child = realFrame->PrincipalChildList().FirstChild();
|
2008-12-07 21:21:40 +03: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-23 02:42:45 +03:00
|
|
|
if (inFirstLine) {
|
2013-07-20 23:14:25 +04:00
|
|
|
restyleManager->ReparentStyleContext(nextInFlow);
|
2014-04-08 09:13:28 +04:00
|
|
|
nsLayoutUtils::MarkDescendantsDirty(nextInFlow);
|
2009-12-23 02:42:45 +03:00
|
|
|
}
|
2008-12-07 21:21:40 +03: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 07:06:37 +03:00
|
|
|
}
|
2000-03-12 06:14:11 +03:00
|
|
|
}
|
2012-09-08 04:33:58 +04:00
|
|
|
MOZ_ASSERT(frame->GetParent() == this);
|
|
|
|
|
|
|
|
if (!done) {
|
2013-02-07 05:13:34 +04:00
|
|
|
bool reflowingFirstLetter = lineLayout->GetFirstLetterStyleOK();
|
2016-07-21 13:36:39 +03:00
|
|
|
ReflowInlineFrame(aPresContext, aReflowInput, irs, frame, aStatus);
|
2017-02-14 11:33:37 +03:00
|
|
|
done = aStatus.IsInlineBreak() ||
|
2017-02-11 17:17:26 +03:00
|
|
|
(!reflowingFirstLetter && aStatus.IsIncomplete());
|
2012-09-08 04:33:58 +04:00
|
|
|
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-28 02:12:37 +04:00
|
|
|
}
|
2003-06-30 14:46:59 +04:00
|
|
|
frame = frame->GetNextSibling();
|
1999-02-01 20:27:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Attempt to pull frames from our next-in-flow until we can't
|
2012-09-08 04:33:58 +04:00
|
|
|
if (!done && GetNextInFlow()) {
|
|
|
|
while (true) {
|
2011-09-29 10:19:26 +04:00
|
|
|
bool reflowingFirstLetter = lineLayout->GetFirstLetterStyleOK();
|
|
|
|
bool isComplete;
|
2007-03-05 03:15:46 +03: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-23 02:19:10 +03:00
|
|
|
#ifdef NOISY_PUSHING
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("%p pulled up %p\n", this, frame);
|
2000-03-23 02:19:10 +03:00
|
|
|
#endif
|
2012-07-30 18:20:58 +04:00
|
|
|
if (nullptr == frame) {
|
1999-02-01 20:27:56 +03:00
|
|
|
if (!isComplete) {
|
2017-02-14 12:30:56 +03:00
|
|
|
aStatus.Reset();
|
|
|
|
aStatus.SetIncomplete();
|
1998-12-05 19:04:46 +03:00
|
|
|
}
|
1999-02-01 20:27:56 +03:00
|
|
|
break;
|
|
|
|
}
|
2016-07-21 13:36:39 +03:00
|
|
|
ReflowInlineFrame(aPresContext, aReflowInput, irs, frame, aStatus);
|
2017-02-14 11:33:37 +03:00
|
|
|
if (aStatus.IsInlineBreak() ||
|
2017-02-11 17:17:26 +03:00
|
|
|
(!reflowingFirstLetter && aStatus.IsIncomplete())) {
|
2002-07-15 18:46:01 +04:00
|
|
|
break;
|
1999-04-28 02:12:37 +04:00
|
|
|
}
|
1999-03-05 07:25:57 +03:00
|
|
|
irs.mPrevFrame = frame;
|
2007-03-05 03:15:46 +03:00
|
|
|
frame = frame->GetNextSibling();
|
1998-10-27 19:52:10 +03:00
|
|
|
}
|
|
|
|
}
|
2012-09-08 04:33:58 +04:00
|
|
|
|
2017-02-11 17:45:07 +03:00
|
|
|
NS_ASSERTION(!aStatus.IsComplete() || !GetOverflowFrames(),
|
2012-09-08 04:33:58 +04:00
|
|
|
"We can't be complete AND have overflow frames!");
|
1999-02-01 20:27:56 +03:00
|
|
|
|
1999-03-19 00:03:25 +03:00
|
|
|
// If after reflowing our children they take up no area then make
|
|
|
|
// sure that we don't either.
|
1999-04-20 04:25:12 +04: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-06-05 13:39:36 +04:00
|
|
|
aMetrics.ISize(lineWM) = lineLayout->EndSpan(this);
|
2007-05-05 21:06:04 +04:00
|
|
|
|
2009-05-12 06:04:58 +04:00
|
|
|
// Compute final width.
|
|
|
|
|
2014-06-05 13:39:36 +04: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-12 06:04:58 +04:00
|
|
|
// Make sure to not include our start border and padding if we have a prev
|
2009-09-18 22:00:21 +04:00
|
|
|
// continuation or if we're in a part of an {ib} split other than the first
|
2014-05-05 21:55:54 +04: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 13:39:36 +04:00
|
|
|
aMetrics.ISize(lineWM) += framePadding.IStart(frameWM);
|
2007-05-05 21:06:04 +04:00
|
|
|
}
|
2009-05-12 06:04:58 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We want to only apply the end border and padding if we're the last
|
2009-09-18 22:00:21 +04: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 21:55:54 +04:00
|
|
|
* chain. For box-decoration-break:clone we always apply the end border and
|
|
|
|
* padding since all continuations have them.
|
2009-05-12 06:04:58 +04:00
|
|
|
*/
|
2017-02-11 17:45:07 +03:00
|
|
|
if ((aStatus.IsComplete() &&
|
2014-05-05 21:55:54 +04:00
|
|
|
!LastInFlow()->GetNextContinuation() &&
|
|
|
|
!FrameIsNonLastInIBSplit()) ||
|
|
|
|
boxDecorationBreakClone) {
|
2014-06-05 13:39:36 +04:00
|
|
|
aMetrics.ISize(lineWM) += framePadding.IEnd(frameWM);
|
1999-03-19 00:03:25 +03:00
|
|
|
}
|
|
|
|
|
2015-01-15 12:02:11 +03:00
|
|
|
nsLayoutUtils::SetBSizeFromFontMetrics(this, aMetrics,
|
2014-08-15 21:34:20 +04:00
|
|
|
framePadding, lineWM, frameWM);
|
1999-03-19 00:03:25 +03:00
|
|
|
|
1999-12-06 18:49:53 +03:00
|
|
|
// For now our overflow area is zero. The real value will be
|
2008-02-16 18:31:27 +03:00
|
|
|
// computed in |nsLineLayout::RelativePositionFrames|.
|
2010-10-07 08:25:46 +04:00
|
|
|
aMetrics.mOverflowAreas.Clear();
|
1999-03-19 00:03:25 +03:00
|
|
|
|
|
|
|
#ifdef NOISY_FINAL_SIZE
|
|
|
|
ListTag(stdout);
|
2007-01-23 07:06:56 +03:00
|
|
|
printf(": metrics=%d,%d ascent=%d\n",
|
2013-12-27 21:59:52 +04:00
|
|
|
aMetrics.Width(), aMetrics.Height(), aMetrics.TopAscent());
|
1999-03-19 00:03:25 +03:00
|
|
|
#endif
|
1998-10-27 19:52:10 +03:00
|
|
|
}
|
|
|
|
|
2014-05-13 04:47:52 +04:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsInlineFrame::ReflowInlineFrame(nsPresContext* aPresContext,
|
2016-07-21 13:36:39 +03:00
|
|
|
const ReflowInput& aReflowInput,
|
|
|
|
InlineReflowInput& irs,
|
1999-02-01 20:27:56 +03:00
|
|
|
nsIFrame* aFrame,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-09-19 08:29:36 +04:00
|
|
|
{
|
2016-07-21 13:36:39 +03:00
|
|
|
nsLineLayout* lineLayout = aReflowInput.mLineLayout;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool reflowingFirstLetter = lineLayout->GetFirstLetterStyleOK();
|
|
|
|
bool pushedFrame;
|
2014-05-13 04:47:52 +04:00
|
|
|
lineLayout->ReflowFrame(aFrame, aStatus, nullptr, pushedFrame);
|
2017-02-14 11:05:24 +03:00
|
|
|
|
|
|
|
if (aStatus.IsInlineBreakBefore()) {
|
2010-06-29 18:32:03 +04:00
|
|
|
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.
|
2017-02-14 11:05:24 +03:00
|
|
|
StyleClear oldBreakType = aStatus.BreakType();
|
|
|
|
aStatus.Reset();
|
|
|
|
aStatus.SetIncomplete();
|
|
|
|
aStatus.SetInlineLineBreakAfter(oldBreakType);
|
2010-06-29 18:32:03 +04:00
|
|
|
PushFrames(aPresContext, aFrame, irs.mPrevFrame, irs);
|
1999-02-01 20:27:56 +03:00
|
|
|
}
|
|
|
|
else {
|
2010-06-29 18:32:03 +04:00
|
|
|
// Preserve reflow status when breaking-before our first child
|
|
|
|
// and propagate it upward without modification.
|
1999-02-01 20:27:56 +03:00
|
|
|
}
|
2014-05-13 04:47:52 +04:00
|
|
|
return;
|
1999-02-01 20:27:56 +03:00
|
|
|
}
|
2010-06-29 18:32:03 +04:00
|
|
|
|
|
|
|
// Create a next-in-flow if needed.
|
2017-02-11 17:38:48 +03:00
|
|
|
if (!aStatus.IsFullyComplete()) {
|
2014-12-02 09:03:57 +03:00
|
|
|
CreateNextInFlow(aFrame);
|
2010-06-29 18:32:03 +04:00
|
|
|
}
|
|
|
|
|
2017-02-14 11:22:04 +03:00
|
|
|
if (aStatus.IsInlineBreakAfter()) {
|
2010-06-29 18:32:03 +04:00
|
|
|
nsIFrame* nextFrame = aFrame->GetNextSibling();
|
|
|
|
if (nextFrame) {
|
2017-02-11 18:06:17 +03:00
|
|
|
aStatus.SetIncomplete();
|
2010-06-29 18:32:03 +04:00
|
|
|
PushFrames(aPresContext, nextFrame, aFrame, irs);
|
1999-02-01 20:27:56 +03:00
|
|
|
}
|
2002-09-25 02:13:20 +04:00
|
|
|
else {
|
2010-06-29 18:32:03 +04: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()) {
|
2017-02-11 18:06:17 +03:00
|
|
|
aStatus.SetIncomplete();
|
2010-06-29 18:32:03 +04:00
|
|
|
break;
|
2002-09-25 02:13:20 +04:00
|
|
|
}
|
2010-06-29 18:32:03 +04:00
|
|
|
nextInFlow = static_cast<nsInlineFrame*>(nextInFlow->GetNextInFlow());
|
1999-04-28 02:12:37 +04:00
|
|
|
}
|
1999-02-01 20:27:56 +03:00
|
|
|
}
|
2014-05-13 04:47:52 +04:00
|
|
|
return;
|
1999-02-01 20:27:56 +03:00
|
|
|
}
|
2010-06-29 18:32:03 +04:00
|
|
|
|
2017-02-11 17:38:48 +03:00
|
|
|
if (!aStatus.IsFullyComplete() && !reflowingFirstLetter) {
|
2010-06-29 18:32:03 +04:00
|
|
|
nsIFrame* nextFrame = aFrame->GetNextSibling();
|
|
|
|
if (nextFrame) {
|
|
|
|
PushFrames(aPresContext, nextFrame, aFrame, irs);
|
|
|
|
}
|
|
|
|
}
|
1999-02-01 20:27:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame*
|
2004-08-01 03:15:21 +04:00
|
|
|
nsInlineFrame::PullOneFrame(nsPresContext* aPresContext,
|
2016-07-21 13:36:39 +03:00
|
|
|
InlineReflowInput& irs,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool* aIsComplete)
|
1999-02-01 20:27:56 +03:00
|
|
|
{
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isComplete = true;
|
1999-02-01 20:27:56 +03:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
nsIFrame* frame = nullptr;
|
1999-03-05 07:25:57 +03:00
|
|
|
nsInlineFrame* nextInFlow = irs.mNextInFlow;
|
2013-04-01 19:26:02 +04:00
|
|
|
while (nextInFlow) {
|
2007-04-21 04:42:58 +04:00
|
|
|
frame = nextInFlow->mFrames.FirstChild();
|
2010-01-28 07:12:37 +03:00
|
|
|
if (!frame) {
|
2012-09-08 04:33:58 +04:00
|
|
|
// The nextInFlow's principal list has no frames, try its overflow list.
|
|
|
|
nsFrameList* overflowFrames = nextInFlow->GetOverflowFrames();
|
2010-01-28 07:12:37 +03:00
|
|
|
if (overflowFrames) {
|
2013-04-01 19:26:02 +04:00
|
|
|
frame = overflowFrames->RemoveFirstChild();
|
|
|
|
if (overflowFrames->IsEmpty()) {
|
2012-09-08 04:33:58 +04:00
|
|
|
// We're stealing the only frame - delete the overflow list.
|
2014-02-07 02:07:47 +04:00
|
|
|
nextInFlow->DestroyOverflowList();
|
2012-09-08 04:33:58 +04: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 07:12:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-01 19:26:02 +04:00
|
|
|
if (frame) {
|
2007-04-21 04:42:58 +04: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 18:59:28 +04:00
|
|
|
ReparentFloatsForInlineChild(irs.mLineContainer, frame, false);
|
2007-04-21 04:42:58 +04:00
|
|
|
}
|
|
|
|
nextInFlow->mFrames.RemoveFirstChild();
|
2012-09-08 04:33:58 +04:00
|
|
|
// nsFirstLineFrame::PullOneFrame calls ReparentStyleContext.
|
2009-12-18 12:02:26 +03:00
|
|
|
|
2007-04-21 04:42:58 +04:00
|
|
|
mFrames.InsertFrame(this, irs.mPrevFrame, frame);
|
2011-10-17 18:59:28 +04:00
|
|
|
isComplete = false;
|
2009-10-27 04:43:56 +03:00
|
|
|
if (irs.mLineLayout) {
|
|
|
|
irs.mLineLayout->SetDirtyNextLine();
|
|
|
|
}
|
2014-02-07 02:07:47 +04:00
|
|
|
nsContainerFrame::ReparentFrameView(frame, nextInFlow, this);
|
1999-02-01 20:27:56 +03:00
|
|
|
break;
|
|
|
|
}
|
2013-04-01 19:26:02 +04:00
|
|
|
nextInFlow = static_cast<nsInlineFrame*>(nextInFlow->GetNextInFlow());
|
1999-11-01 18:24:57 +03:00
|
|
|
irs.mNextInFlow = nextInFlow;
|
1999-02-01 20:27:56 +03:00
|
|
|
}
|
|
|
|
|
1999-11-01 18:24:57 +03:00
|
|
|
*aIsComplete = isComplete;
|
|
|
|
return frame;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsInlineFrame::PushFrames(nsPresContext* aPresContext,
|
1999-11-01 18:24:57 +03:00
|
|
|
nsIFrame* aFromChild,
|
2009-10-27 04:43:56 +03:00
|
|
|
nsIFrame* aPrevSibling,
|
2016-07-21 13:36:39 +03:00
|
|
|
InlineReflowInput& aState)
|
1999-11-01 18:24:57 +03:00
|
|
|
{
|
2009-09-18 15:09:35 +04:00
|
|
|
NS_PRECONDITION(aFromChild, "null pointer");
|
|
|
|
NS_PRECONDITION(aPrevSibling, "pushing first child");
|
2003-06-30 14:46:59 +04:00
|
|
|
NS_PRECONDITION(aPrevSibling->GetNextSibling() == aFromChild, "bad prev sibling");
|
1999-11-01 18:24:57 +03:00
|
|
|
|
2000-03-23 02:19:10 +03:00
|
|
|
#ifdef NOISY_PUSHING
|
2009-09-18 15:09:35 +04:00
|
|
|
printf("%p pushing aFromChild %p, disconnecting from prev sib %p\n",
|
|
|
|
this, aFromChild, aPrevSibling);
|
2000-03-23 02:19:10 +03:00
|
|
|
#endif
|
1999-11-01 18:24:57 +03:00
|
|
|
|
|
|
|
// Add the frames to our overflow list (let our next in flow drain
|
|
|
|
// our overflow list when it is ready)
|
2014-02-07 02:07:47 +04:00
|
|
|
SetOverflowFrames(mFrames.RemoveFramesAfter(aPrevSibling));
|
2009-10-27 04:43:56 +03:00
|
|
|
if (aState.mLineLayout) {
|
|
|
|
aState.mLineLayout->SetDirtyNextLine();
|
|
|
|
}
|
1999-02-01 20:27:56 +03:00
|
|
|
}
|
|
|
|
|
2000-01-12 11:28:24 +03:00
|
|
|
|
1999-02-01 20:27:56 +03:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
2014-06-28 14:13:13 +04:00
|
|
|
nsIFrame::LogicalSides
|
2016-07-21 13:36:39 +03:00
|
|
|
nsInlineFrame::GetLogicalSkipSides(const ReflowInput* aReflowInput) const
|
1998-12-19 01:12:42 +03:00
|
|
|
{
|
2014-05-05 21:55:54 +04:00
|
|
|
if (MOZ_UNLIKELY(StyleBorder()->mBoxDecorationBreak ==
|
2016-08-26 10:14:32 +03:00
|
|
|
StyleBoxDecorationBreak::Clone)) {
|
2014-06-28 14:13:13 +04:00
|
|
|
return LogicalSides();
|
2014-05-05 21:55:54 +04:00
|
|
|
}
|
|
|
|
|
2014-06-28 14:13:13 +04:00
|
|
|
LogicalSides skip;
|
2014-03-13 11:39:33 +04:00
|
|
|
if (!IsFirst()) {
|
2006-02-22 00:33:47 +03:00
|
|
|
nsInlineFrame* prev = (nsInlineFrame*) GetPrevContinuation();
|
2006-06-15 12:16:23 +04:00
|
|
|
if ((GetStateBits() & NS_INLINE_FRAME_BIDI_VISUAL_STATE_IS_SET) ||
|
|
|
|
(prev && (prev->mRect.height || prev->mRect.width))) {
|
2014-03-13 11:39:33 +04:00
|
|
|
// Prev continuation is not empty therefore we don't render our start
|
1999-04-20 04:25:12 +04:00
|
|
|
// border edge.
|
2014-06-28 14:13:14 +04:00
|
|
|
skip |= eLogicalSideBitsIStart;
|
1999-04-20 04:25:12 +04:00
|
|
|
}
|
|
|
|
else {
|
2014-03-13 11:39:33 +04:00
|
|
|
// If the prev continuation is empty, then go ahead and let our start
|
1999-04-20 04:25:12 +04:00
|
|
|
// edge border render.
|
|
|
|
}
|
1998-12-19 01:12:42 +03:00
|
|
|
}
|
2014-03-13 11:39:33 +04:00
|
|
|
if (!IsLast()) {
|
2006-02-22 00:33:47 +03:00
|
|
|
nsInlineFrame* next = (nsInlineFrame*) GetNextContinuation();
|
2006-06-15 12:16:23 +04:00
|
|
|
if ((GetStateBits() & NS_INLINE_FRAME_BIDI_VISUAL_STATE_IS_SET) ||
|
|
|
|
(next && (next->mRect.height || next->mRect.width))) {
|
2014-03-13 11:39:33 +04:00
|
|
|
// Next continuation is not empty therefore we don't render our end
|
1999-04-20 04:25:12 +04:00
|
|
|
// border edge.
|
2014-06-28 14:13:14 +04:00
|
|
|
skip |= eLogicalSideBitsIEnd;
|
1999-04-20 04:25:12 +04:00
|
|
|
}
|
|
|
|
else {
|
2014-03-13 11:39:33 +04:00
|
|
|
// If the next continuation is empty, then go ahead and let our end
|
1999-04-20 04:25:12 +04:00
|
|
|
// edge border render.
|
|
|
|
}
|
1998-12-19 01:12:42 +03:00
|
|
|
}
|
2009-05-12 06:04:58 +04:00
|
|
|
|
2014-02-07 05:45:28 +04:00
|
|
|
if (GetStateBits() & NS_FRAME_PART_OF_IBSPLIT) {
|
2009-09-18 22:00:21 +04: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 06:04:58 +04:00
|
|
|
// expensive. So don't bother if we already have the relevant bits set.
|
2014-06-28 14:13:14 +04:00
|
|
|
if (skip != LogicalSides(eLogicalSideBitsIBoth)) {
|
2009-05-12 06:04:58 +04:00
|
|
|
// We're missing one of the skip bits, so check whether we need to set it.
|
2009-09-18 22:00:21 +04:00
|
|
|
// Only get the first continuation once, as an optimization.
|
2013-09-25 15:42:34 +04:00
|
|
|
nsIFrame* firstContinuation = FirstContinuation();
|
2013-10-01 01:26:04 +04:00
|
|
|
if (firstContinuation->FrameIsNonLastInIBSplit()) {
|
2014-06-28 14:13:14 +04:00
|
|
|
skip |= eLogicalSideBitsIEnd;
|
2009-09-18 22:00:21 +04:00
|
|
|
}
|
2013-10-01 01:26:04 +04:00
|
|
|
if (firstContinuation->FrameIsNonFirstInIBSplit()) {
|
2014-06-28 14:13:14 +04:00
|
|
|
skip |= eLogicalSideBitsIStart;
|
2009-05-12 06:04:58 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-19 01:12:42 +03:00
|
|
|
return skip;
|
|
|
|
}
|
1999-04-20 04:25:12 +04:00
|
|
|
|
2010-08-31 22:54:44 +04:00
|
|
|
nscoord
|
2014-06-17 16:19:38 +04:00
|
|
|
nsInlineFrame::GetLogicalBaseline(mozilla::WritingMode aWritingMode) const
|
2010-08-31 22:54:44 +04:00
|
|
|
{
|
2011-08-03 22:30:58 +04:00
|
|
|
return mBaseline;
|
2011-03-29 04:17:16 +04:00
|
|
|
}
|
|
|
|
|
2002-08-10 11:59:44 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
2012-09-29 01:53:44 +04:00
|
|
|
a11y::AccType
|
|
|
|
nsInlineFrame::AccessibleType()
|
2002-08-10 11:59:44 +04:00
|
|
|
{
|
|
|
|
// Broken image accessibles are created here, because layout
|
|
|
|
// replaces the image or image control frame with an inline frame
|
2015-03-03 14:09:00 +03:00
|
|
|
if (mContent->IsHTMLElement(nsGkAtoms::input)) // Broken <input type=image ... />
|
2012-12-18 05:25:52 +04:00
|
|
|
return a11y::eHTMLButtonType;
|
2015-03-03 14:09:00 +03:00
|
|
|
if (mContent->IsHTMLElement(nsGkAtoms::img)) // Create accessible for broken <img>
|
2013-06-12 13:13:34 +04:00
|
|
|
return a11y::eHyperTextType;
|
2012-09-29 01:53:44 +04:00
|
|
|
|
2012-12-12 14:04:12 +04:00
|
|
|
return a11y::eNoType;
|
2002-08-10 11:59:44 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-03-03 23:45:40 +03:00
|
|
|
void
|
|
|
|
nsInlineFrame::DoUpdateStyleOfOwnedAnonBoxes(ServoStyleSet& aStyleSet,
|
|
|
|
nsStyleChangeList& aChangeList,
|
|
|
|
nsChangeHint aHintForThisFrame)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(GetStateBits() & NS_FRAME_OWNS_ANON_BOXES,
|
|
|
|
"Why did we get called?");
|
|
|
|
MOZ_ASSERT(GetStateBits() & NS_FRAME_PART_OF_IBSPLIT,
|
|
|
|
"Why did we have the NS_FRAME_OWNS_ANON_BOXES bit set?");
|
|
|
|
// Note: this assert _looks_ expensive, but it's cheap in all the cases when
|
|
|
|
// it passes!
|
|
|
|
MOZ_ASSERT(nsLayoutUtils::FirstContinuationOrIBSplitSibling(this) == this,
|
|
|
|
"Only the primary frame of the inline in a block-inside-inline "
|
|
|
|
"split should have NS_FRAME_OWNS_ANON_BOXES");
|
|
|
|
MOZ_ASSERT(mContent->GetPrimaryFrame() == this,
|
|
|
|
"We should be the primary frame for our element");
|
|
|
|
|
|
|
|
nsPresContext* presContext = PresContext();
|
|
|
|
// Get the FramePropertyTable up front, since we are likely to need it
|
|
|
|
// multiple times. The other option would be to just call
|
|
|
|
// nsIFrame::Properties() every time we need to do a lookup, but that does
|
|
|
|
// more pointer-chasing.
|
|
|
|
FramePropertyTable* propTable = presContext->PropertyTable();
|
|
|
|
nsIFrame* blockFrame = propTable->Get(this, nsIFrame::IBSplitSibling());
|
|
|
|
MOZ_ASSERT(blockFrame, "Why did we have an IB split?");
|
|
|
|
|
|
|
|
nsIAtom* pseudo = blockFrame->StyleContext()->GetPseudo();
|
|
|
|
MOZ_ASSERT(pseudo == nsCSSAnonBoxes::mozAnonymousBlock ||
|
|
|
|
pseudo == nsCSSAnonBoxes::mozAnonymousPositionedBlock,
|
|
|
|
"Unexpected kind of style context");
|
|
|
|
|
|
|
|
// The anonymous block's style inherits from ours, and we already have our new
|
|
|
|
// style context.
|
|
|
|
RefPtr<nsStyleContext> newContext =
|
|
|
|
aStyleSet.ResolveAnonymousBoxStyle(pseudo, StyleContext());
|
|
|
|
|
|
|
|
// We're guaranteed that newContext only differs from the old style context on
|
|
|
|
// the block in things they might inherit from us. And changehint processing
|
|
|
|
// guarantees walking the continuation and ib-sibling chains, so our existing
|
|
|
|
// changehint beign in aChangeList is good enough. So we don't need to touch
|
|
|
|
// aChangeList at all here.
|
|
|
|
|
|
|
|
while (blockFrame) {
|
|
|
|
MOZ_ASSERT(!blockFrame->GetPrevContinuation(),
|
|
|
|
"Must be first continuation");
|
|
|
|
// We _could_ just walk along using GetNextContinuationWithSameStyle here,
|
|
|
|
// but it would involve going back to the first continuation every so often,
|
|
|
|
// which is a bit silly when we can just keep track of our first
|
|
|
|
// continuations.
|
|
|
|
for (nsIFrame* cont = blockFrame; cont; cont = cont->GetNextContinuation()) {
|
|
|
|
cont->SetStyleContext(newContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame* nextInline = propTable->Get(blockFrame, nsIFrame::IBSplitSibling());
|
|
|
|
MOZ_ASSERT(nextInline, "There is always a trailing inline in an IB split");
|
|
|
|
blockFrame = propTable->Get(nextInline, nsIFrame::IBSplitSibling());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-04-20 04:25:12 +04:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// nsLineFrame implementation
|
|
|
|
|
2014-05-25 02:20:39 +04:00
|
|
|
nsFirstLineFrame*
|
2006-03-27 01:30:36 +04:00
|
|
|
NS_NewFirstLineFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
1999-04-20 04:25:12 +04:00
|
|
|
{
|
2006-03-27 01:30:36 +04:00
|
|
|
return new (aPresShell) nsFirstLineFrame(aContext);
|
1999-04-20 04:25:12 +04:00
|
|
|
}
|
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsFirstLineFrame)
|
|
|
|
|
2013-04-26 12:49:07 +04:00
|
|
|
void
|
2014-05-25 02:20:40 +04:00
|
|
|
nsFirstLineFrame::Init(nsIContent* aContent,
|
|
|
|
nsContainerFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
2013-04-26 12:49:07 +04: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 15:42:34 +04:00
|
|
|
MOZ_ASSERT(FirstInFlow() == aPrevInFlow);
|
2013-04-26 12:49:07 +04: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();
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsStyleContext> newSC = PresContext()->StyleSet()->
|
2013-04-26 12:49:07 +04:00
|
|
|
ResolveAnonymousBoxStyle(nsCSSAnonBoxes::mozLineFrame, parentContext);
|
|
|
|
SetStyleContext(newSC);
|
|
|
|
} else {
|
2013-09-25 15:42:34 +04:00
|
|
|
MOZ_ASSERT(FirstInFlow() != aPrevInFlow);
|
2013-04-26 12:49:07 +04:00
|
|
|
MOZ_ASSERT(aPrevInFlow->StyleContext()->GetPseudo() ==
|
|
|
|
nsCSSAnonBoxes::mozLineFrame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-06 03:31:14 +04:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-02-18 11:47:48 +04:00
|
|
|
nsresult
|
2001-11-14 04:33:42 +03:00
|
|
|
nsFirstLineFrame::GetFrameName(nsAString& aResult) const
|
1999-04-20 04:25:12 +04:00
|
|
|
{
|
2001-11-14 04:33:42 +03:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("Line"), aResult);
|
1999-04-20 04:25:12 +04:00
|
|
|
}
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|
1999-04-20 04:25:12 +04:00
|
|
|
|
2003-10-31 23:19:18 +03:00
|
|
|
nsIAtom*
|
|
|
|
nsFirstLineFrame::GetType() const
|
1999-04-20 04:25:12 +04:00
|
|
|
{
|
2006-12-26 20:47:52 +03:00
|
|
|
return nsGkAtoms::lineFrame;
|
1999-04-20 04:25:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame*
|
2016-07-21 13:36:39 +03:00
|
|
|
nsFirstLineFrame::PullOneFrame(nsPresContext* aPresContext, InlineReflowInput& irs,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool* aIsComplete)
|
1999-04-20 04:25:12 +04:00
|
|
|
{
|
1999-11-01 18:24:57 +03:00
|
|
|
nsIFrame* frame = nsInlineFrame::PullOneFrame(aPresContext, irs, aIsComplete);
|
2006-02-22 00:33:47 +03:00
|
|
|
if (frame && !GetPrevInFlow()) {
|
1999-04-20 04:25:12 +04:00
|
|
|
// We are a first-line frame. Fixup the child frames
|
|
|
|
// style-context that we just pulled.
|
2006-03-16 04:30:38 +03:00
|
|
|
NS_ASSERTION(frame->GetParent() == this, "Incorrect parent?");
|
2013-07-20 23:14:25 +04:00
|
|
|
aPresContext->RestyleManager()->ReparentStyleContext(frame);
|
2014-04-08 09:13:28 +04:00
|
|
|
nsLayoutUtils::MarkDescendantsDirty(frame);
|
1999-04-20 04:25:12 +04:00
|
|
|
}
|
|
|
|
return frame;
|
|
|
|
}
|
|
|
|
|
2014-05-13 04:47:52 +04:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsFirstLineFrame::Reflow(nsPresContext* aPresContext,
|
2016-07-21 13:36:38 +03:00
|
|
|
ReflowOutput& aMetrics,
|
2016-07-21 13:36:39 +03:00
|
|
|
const ReflowInput& aReflowInput,
|
2000-03-12 06:14:11 +03:00
|
|
|
nsReflowStatus& aStatus)
|
1999-04-20 04:25:12 +04:00
|
|
|
{
|
2015-03-30 01:38:40 +03:00
|
|
|
MarkInReflow();
|
2016-07-21 13:36:39 +03:00
|
|
|
if (nullptr == aReflowInput.mLineLayout) {
|
2014-05-13 04:47:52 +04:00
|
|
|
return; // XXX does this happen? why?
|
2000-03-12 06:14:11 +03:00
|
|
|
}
|
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
nsIFrame* lineContainer = aReflowInput.mLineLayout->LineContainerFrame();
|
2007-04-21 04:42:58 +04:00
|
|
|
|
1999-04-20 04:25:12 +04:00
|
|
|
// Check for an overflow list with our prev-in-flow
|
2006-02-22 00:33:47 +03:00
|
|
|
nsFirstLineFrame* prevInFlow = (nsFirstLineFrame*)GetPrevInFlow();
|
2013-04-01 19:26:02 +04:00
|
|
|
if (prevInFlow) {
|
|
|
|
AutoFrameListPtr prevOverflowFrames(aPresContext,
|
|
|
|
prevInFlow->StealOverflowFrames());
|
1999-10-21 09:11:43 +04:00
|
|
|
if (prevOverflowFrames) {
|
2007-04-21 04:42:58 +04:00
|
|
|
// Assign all floats to our block if necessary
|
|
|
|
if (lineContainer && lineContainer->GetPrevContinuation()) {
|
2009-07-28 16:51:09 +04:00
|
|
|
ReparentFloatsForInlineChild(lineContainer,
|
|
|
|
prevOverflowFrames->FirstChild(),
|
2011-10-17 18:59:28 +04:00
|
|
|
true);
|
2007-04-21 04:42:58 +04:00
|
|
|
}
|
2009-07-28 16:51:09 +04:00
|
|
|
const nsFrameList::Slice& newFrames =
|
2012-07-30 18:20:58 +04:00
|
|
|
mFrames.InsertFrames(this, nullptr, *prevOverflowFrames);
|
2010-04-02 10:07:43 +04:00
|
|
|
ReparentChildListStyle(aPresContext, newFrames, this);
|
1999-04-20 04:25:12 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-17 17:30:24 +04:00
|
|
|
// It's also possible that we have an overflow list for ourselves.
|
|
|
|
DrainSelfOverflowList();
|
1999-04-20 04:25:12 +04:00
|
|
|
|
|
|
|
// Set our own reflow state (additional state above and beyond
|
2016-07-21 13:36:39 +03:00
|
|
|
// aReflowInput)
|
|
|
|
InlineReflowInput irs;
|
2012-07-30 18:20:58 +04:00
|
|
|
irs.mPrevFrame = nullptr;
|
2007-04-21 04:42:58 +04:00
|
|
|
irs.mLineContainer = lineContainer;
|
2016-07-21 13:36:39 +03:00
|
|
|
irs.mLineLayout = aReflowInput.mLineLayout;
|
2006-02-22 00:33:47 +03:00
|
|
|
irs.mNextInFlow = (nsInlineFrame*) GetNextInFlow();
|
1999-04-20 04:25:12 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool wasEmpty = mFrames.IsEmpty();
|
1999-04-20 04:25:12 +04: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 10:19:26 +04:00
|
|
|
bool complete;
|
1999-11-24 09:03:41 +03:00
|
|
|
PullOneFrame(aPresContext, irs, &complete);
|
1999-04-20 04:25:12 +04:00
|
|
|
}
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
if (nullptr == GetPrevInFlow()) {
|
1999-11-01 18:24:57 +03: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 10:19:26 +04:00
|
|
|
bool complete;
|
1999-11-24 09:03:41 +03:00
|
|
|
nsIFrame* frame = PullOneFrame(aPresContext, irs, &complete);
|
1999-11-01 18:24:57 +03:00
|
|
|
if (!frame) {
|
|
|
|
break;
|
1999-04-20 04:25:12 +04:00
|
|
|
}
|
1999-11-01 18:24:57 +03:00
|
|
|
irs.mPrevFrame = frame;
|
1999-04-20 04:25:12 +04:00
|
|
|
}
|
2012-07-30 18:20:58 +04:00
|
|
|
irs.mPrevFrame = nullptr;
|
1999-04-20 04:25:12 +04:00
|
|
|
}
|
1999-11-01 18:24:57 +03:00
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
NS_ASSERTION(!aReflowInput.mLineLayout->GetInFirstLine(),
|
2007-01-18 04:20:09 +03:00
|
|
|
"Nested first-line frames? BOGUS");
|
2016-07-21 13:36:39 +03:00
|
|
|
aReflowInput.mLineLayout->SetInFirstLine(true);
|
|
|
|
ReflowFrames(aPresContext, aReflowInput, irs, aMetrics, aStatus);
|
|
|
|
aReflowInput.mLineLayout->SetInFirstLine(false);
|
1999-11-01 18:24:57 +03:00
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
ReflowAbsoluteFrames(aPresContext, aMetrics, aReflowInput, aStatus);
|
2011-04-30 03:02:33 +04:00
|
|
|
|
2004-08-25 17:03:28 +04:00
|
|
|
// Note: the line layout code will properly compute our overflow state for us
|
1999-11-01 18:24:57 +03:00
|
|
|
}
|
|
|
|
|
2009-07-24 17:32:32 +04:00
|
|
|
/* virtual */ void
|
|
|
|
nsFirstLineFrame::PullOverflowsFromPrevInFlow()
|
|
|
|
{
|
|
|
|
nsFirstLineFrame* prevInFlow = static_cast<nsFirstLineFrame*>(GetPrevInFlow());
|
|
|
|
if (prevInFlow) {
|
2013-04-01 19:26:02 +04:00
|
|
|
nsPresContext* presContext = PresContext();
|
|
|
|
AutoFrameListPtr prevOverflowFrames(presContext,
|
|
|
|
prevInFlow->StealOverflowFrames());
|
2009-07-24 17:32:32 +04:00
|
|
|
if (prevOverflowFrames) {
|
|
|
|
// Assume that our prev-in-flow has the same line container that we do.
|
2009-07-28 16:51:09 +04:00
|
|
|
const nsFrameList::Slice& newFrames =
|
2012-07-30 18:20:58 +04:00
|
|
|
mFrames.InsertFrames(this, nullptr, *prevOverflowFrames);
|
2013-04-01 19:26:02 +04:00
|
|
|
ReparentChildListStyle(presContext, newFrames, this);
|
2009-07-24 17:32:32 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-17 17:30:24 +04:00
|
|
|
/* virtual */ bool
|
|
|
|
nsFirstLineFrame::DrainSelfOverflowList()
|
|
|
|
{
|
|
|
|
AutoFrameListPtr overflowFrames(PresContext(), StealOverflowFrames());
|
|
|
|
if (overflowFrames) {
|
|
|
|
bool result = !overflowFrames->IsEmpty();
|
|
|
|
const nsFrameList::Slice& newFrames =
|
|
|
|
mFrames.AppendFrames(nullptr, *overflowFrames);
|
|
|
|
ReparentChildListStyle(PresContext(), newFrames, this);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|