2017-10-27 20:33:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
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 :first-letter pseudo-element */
|
|
|
|
|
2008-04-11 12:44:58 +04:00
|
|
|
#include "nsFirstLetterFrame.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
2019-03-29 18:11:22 +03:00
|
|
|
#include "nsPresContextInlines.h"
|
2018-03-22 21:20:41 +03:00
|
|
|
#include "mozilla/ComputedStyle.h"
|
2019-04-03 15:40:26 +03:00
|
|
|
#include "mozilla/PresShell.h"
|
2019-04-30 04:52:53 +03:00
|
|
|
#include "mozilla/PresShellInlines.h"
|
2019-04-03 15:40:26 +03:00
|
|
|
#include "mozilla/RestyleManager.h"
|
|
|
|
#include "mozilla/ServoStyleSet.h"
|
1999-10-29 18:34:01 +04:00
|
|
|
#include "nsIContent.h"
|
1999-04-28 02:05:02 +04:00
|
|
|
#include "nsLineLayout.h"
|
2007-01-30 03:06:41 +03:00
|
|
|
#include "nsGkAtoms.h"
|
2004-02-24 00:29:06 +03:00
|
|
|
#include "nsFrameManager.h"
|
2010-03-17 20:30:30 +03:00
|
|
|
#include "nsPlaceholderFrame.h"
|
|
|
|
#include "nsCSSFrameConstructor.h"
|
1999-04-28 02:05:02 +04:00
|
|
|
|
2013-04-01 19:26:02 +04:00
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::layout;
|
2011-10-18 16:51:58 +04:00
|
|
|
|
2019-04-16 10:24:49 +03:00
|
|
|
nsFirstLetterFrame* NS_NewFirstLetterFrame(PresShell* aPresShell,
|
2018-03-22 21:20:41 +03:00
|
|
|
ComputedStyle* aStyle) {
|
2019-02-05 19:45:54 +03:00
|
|
|
return new (aPresShell)
|
|
|
|
nsFirstLetterFrame(aStyle, aPresShell->GetPresContext());
|
1999-04-28 02:05:02 +04:00
|
|
|
}
|
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsFirstLetterFrame)
|
|
|
|
|
2010-11-27 18:21:00 +03:00
|
|
|
NS_QUERYFRAME_HEAD(nsFirstLetterFrame)
|
2018-12-07 23:00:18 +03:00
|
|
|
NS_QUERYFRAME_ENTRY(nsFirstLetterFrame)
|
2011-12-28 00:18:48 +04:00
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
|
2010-11-27 18:21:00 +03:00
|
|
|
|
2014-01-06 03:31:14 +04:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2001-11-14 04:33:42 +03:00
|
|
|
nsresult nsFirstLetterFrame::GetFrameName(nsAString& aResult) const {
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("Letter"), aResult);
|
1999-04-28 02:05:02 +04:00
|
|
|
}
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|
1999-04-28 02:05:02 +04:00
|
|
|
|
2011-12-28 00:18:48 +04:00
|
|
|
void nsFirstLetterFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsDisplayListSet& aLists) {
|
2017-08-07 05:23:35 +03:00
|
|
|
BuildDisplayListForInline(aBuilder, aLists);
|
2011-12-28 00:18:48 +04:00
|
|
|
}
|
|
|
|
|
2014-05-25 02:20:40 +04:00
|
|
|
void nsFirstLetterFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow) {
|
2018-03-22 21:20:41 +03:00
|
|
|
RefPtr<ComputedStyle> newSC;
|
1999-04-28 02:05:02 +04:00
|
|
|
if (aPrevInFlow) {
|
2018-03-23 16:49:21 +03:00
|
|
|
// Get proper ComputedStyle for ourselves. We're creating the frame
|
2001-10-31 05:53:47 +03:00
|
|
|
// that represents everything *except* the first letter, so just create
|
2018-03-23 16:49:21 +03:00
|
|
|
// a ComputedStyle that inherits from our style parent, with no extra rules.
|
2017-06-24 10:17:37 +03:00
|
|
|
nsIFrame* styleParent =
|
2019-02-19 16:44:33 +03:00
|
|
|
CorrectStyleParentFrame(aParent, PseudoStyleType::firstLetter);
|
2018-03-22 21:20:41 +03:00
|
|
|
ComputedStyle* parentComputedStyle = styleParent->Style();
|
|
|
|
newSC = PresContext()->StyleSet()->ResolveStyleForFirstLetterContinuation(
|
|
|
|
parentComputedStyle);
|
|
|
|
SetComputedStyleWithoutNotification(newSC);
|
1999-04-28 02:05:02 +04:00
|
|
|
}
|
2006-03-09 21:55:21 +03:00
|
|
|
|
2013-03-20 05:47:48 +04:00
|
|
|
nsContainerFrame::Init(aContent, aParent, aPrevInFlow);
|
1999-04-28 02:05:02 +04:00
|
|
|
}
|
|
|
|
|
2011-08-25 00:54:30 +04:00
|
|
|
void nsFirstLetterFrame::SetInitialChildList(ChildListID aListID,
|
2009-07-28 16:53:20 +04:00
|
|
|
nsFrameList& aChildList) {
|
2016-01-28 02:11:00 +03:00
|
|
|
MOZ_ASSERT(aListID == kPrincipalList,
|
|
|
|
"Principal child list is the only "
|
|
|
|
"list that nsFirstLetterFrame should set via this function");
|
2017-07-29 04:11:18 +03:00
|
|
|
for (nsIFrame* f : aChildList) {
|
|
|
|
MOZ_ASSERT(f->GetParent() == this, "Unexpected parent");
|
|
|
|
MOZ_ASSERT(f->IsTextFrame(),
|
|
|
|
"We should not have kids that are containers!");
|
|
|
|
nsLayoutUtils::MarkDescendantsDirty(f); // Drops cached textruns
|
1999-10-29 18:34:01 +04:00
|
|
|
}
|
2009-07-28 16:53:20 +04:00
|
|
|
|
|
|
|
mFrames.SetFrames(aChildList);
|
1999-04-28 02:05:02 +04:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
nsresult nsFirstLetterFrame::GetChildFrameContainingOffset(
|
|
|
|
int32_t inContentOffset, bool inHint, int32_t* outFrameContentOffset,
|
2000-01-22 04:16:50 +03:00
|
|
|
nsIFrame** outChildFrame) {
|
2000-06-27 18:47:21 +04:00
|
|
|
nsIFrame* kid = mFrames.FirstChild();
|
2016-10-04 17:22:52 +03:00
|
|
|
if (kid) {
|
2000-01-08 03:31:32 +03:00
|
|
|
return kid->GetChildFrameContainingOffset(
|
|
|
|
inContentOffset, inHint, outFrameContentOffset, outChildFrame);
|
2016-10-04 17:22:52 +03:00
|
|
|
} else {
|
2000-01-08 03:31:32 +03:00
|
|
|
return nsFrame::GetChildFrameContainingOffset(
|
|
|
|
inContentOffset, inHint, outFrameContentOffset, outChildFrame);
|
2016-10-04 17:22:52 +03:00
|
|
|
}
|
2000-01-08 03:31:32 +03:00
|
|
|
}
|
|
|
|
|
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
|
|
|
// Needed for non-floating first-letter frames and for the continuations
|
|
|
|
// following the first-letter that we also use nsFirstLetterFrame for.
|
2019-02-26 01:09:24 +03:00
|
|
|
/* virtual */
|
|
|
|
void nsFirstLetterFrame::AddInlineMinISize(
|
2017-06-09 22:14:53 +03:00
|
|
|
gfxContext* aRenderingContext, nsIFrame::InlineMinISizeData* aData) {
|
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
|
|
|
}
|
|
|
|
|
|
|
|
// Needed for non-floating first-letter frames and for the continuations
|
|
|
|
// following the first-letter that we also use nsFirstLetterFrame for.
|
2019-02-26 01:09:24 +03:00
|
|
|
/* virtual */
|
|
|
|
void nsFirstLetterFrame::AddInlinePrefISize(
|
2017-06-09 22:14:53 +03:00
|
|
|
gfxContext* aRenderingContext, nsIFrame::InlinePrefISizeData* aData) {
|
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
|
|
|
}
|
|
|
|
|
|
|
|
// Needed for floating first-letter frames.
|
2019-02-26 01:09:24 +03:00
|
|
|
/* virtual */
|
|
|
|
nscoord nsFirstLetterFrame::GetMinISize(gfxContext* aRenderingContext) {
|
2014-07-24 21:03:25 +04:00
|
|
|
return nsLayoutUtils::MinISizeFromInline(this, 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 08:38:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Needed for floating first-letter frames.
|
2019-02-26 01:09:24 +03:00
|
|
|
/* virtual */
|
|
|
|
nscoord nsFirstLetterFrame::GetPrefISize(gfxContext* aRenderingContext) {
|
2014-07-24 21:03:25 +04:00
|
|
|
return nsLayoutUtils::PrefISizeFromInline(this, 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 08:38:33 +03:00
|
|
|
}
|
|
|
|
|
2014-08-24 18:34:44 +04:00
|
|
|
/* virtual */
|
2017-06-09 22:14:53 +03:00
|
|
|
LogicalSize nsFirstLetterFrame::ComputeSize(
|
2014-08-24 18:34:44 +04:00
|
|
|
gfxContext* aRenderingContext, 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) {
|
2007-07-19 08:29:59 +04:00
|
|
|
if (GetPrevInFlow()) {
|
|
|
|
// We're wrapping the text *after* the first letter, so behave like an
|
|
|
|
// inline frame.
|
2014-08-24 18:34:44 +04:00
|
|
|
return LogicalSize(aWM, NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
|
2007-07-19 08:29:59 +04:00
|
|
|
}
|
2014-08-24 18:34:44 +04:00
|
|
|
return nsContainerFrame::ComputeSize(aRenderingContext, aWM, aCBSize,
|
|
|
|
aAvailableISize, aMargin, aBorder,
|
|
|
|
aPadding, aFlags);
|
2007-07-19 08:29:59 +04:00
|
|
|
}
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
void nsFirstLetterFrame::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-04-28 02:05:02 +04:00
|
|
|
nsReflowStatus& aReflowStatus) {
|
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("nsFirstLetterFrame");
|
2016-07-21 13:36:39 +03:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowInput, aMetrics, aReflowStatus);
|
2017-09-13 13:00:25 +03:00
|
|
|
MOZ_ASSERT(aReflowStatus.IsEmpty(),
|
|
|
|
"Caller should pass a fresh reflow status!");
|
1999-10-29 18:34:01 +04:00
|
|
|
|
1999-04-28 02:05:02 +04:00
|
|
|
// Grab overflow list
|
1999-11-24 09:03:41 +03:00
|
|
|
DrainOverflowFrames(aPresContext);
|
1999-04-28 02:05:02 +04:00
|
|
|
|
|
|
|
nsIFrame* kid = mFrames.FirstChild();
|
|
|
|
|
2019-04-11 23:27:37 +03:00
|
|
|
// Setup reflow input for our child
|
2016-07-21 13:36:39 +03:00
|
|
|
WritingMode wm = aReflowInput.GetWritingMode();
|
|
|
|
LogicalSize availSize = aReflowInput.AvailableSize();
|
|
|
|
const LogicalMargin& bp = aReflowInput.ComputedLogicalBorderPadding();
|
2014-07-24 12:28:46 +04:00
|
|
|
NS_ASSERTION(availSize.ISize(wm) != NS_UNCONSTRAINEDSIZE,
|
|
|
|
"should no longer use unconstrained inline size");
|
|
|
|
availSize.ISize(wm) -= bp.IStartEnd(wm);
|
|
|
|
if (NS_UNCONSTRAINEDSIZE != availSize.BSize(wm)) {
|
|
|
|
availSize.BSize(wm) -= bp.BStartEnd(wm);
|
1999-04-28 02:05:02 +04:00
|
|
|
}
|
|
|
|
|
2014-08-26 02:32:03 +04:00
|
|
|
WritingMode lineWM = aMetrics.GetWritingMode();
|
2016-07-21 13:36:38 +03:00
|
|
|
ReflowOutput kidMetrics(lineWM);
|
2014-08-26 02:32:03 +04:00
|
|
|
|
1999-04-28 02:05:02 +04:00
|
|
|
// Reflow the child
|
2016-07-21 13:36:39 +03:00
|
|
|
if (!aReflowInput.mLineLayout) {
|
1999-04-28 02:05:02 +04:00
|
|
|
// When there is no lineLayout provided, we provide our own. The
|
|
|
|
// only time that the first-letter-frame is not reflowing in a
|
|
|
|
// line context is when its floating.
|
2016-12-31 20:16:32 +03:00
|
|
|
WritingMode kidWritingMode = WritingModeForLine(wm, kid);
|
2014-07-24 12:28:46 +04:00
|
|
|
LogicalSize kidAvailSize = availSize.ConvertTo(kidWritingMode, wm);
|
2016-07-21 13:36:39 +03:00
|
|
|
ReflowInput rs(aPresContext, aReflowInput, kid, kidAvailSize);
|
|
|
|
nsLineLayout ll(aPresContext, nullptr, &aReflowInput, nullptr, nullptr);
|
2011-10-18 16:51:58 +04:00
|
|
|
|
2014-07-24 12:28:46 +04:00
|
|
|
ll.BeginLineReflow(
|
|
|
|
bp.IStart(wm), bp.BStart(wm), availSize.ISize(wm), NS_UNCONSTRAINEDSIZE,
|
|
|
|
false, true, kidWritingMode,
|
2016-07-21 13:36:39 +03:00
|
|
|
nsSize(aReflowInput.AvailableWidth(), aReflowInput.AvailableHeight()));
|
1999-07-20 07:51:46 +04:00
|
|
|
rs.mLineLayout = ≪
|
2011-10-17 18:59:28 +04:00
|
|
|
ll.SetInFirstLetter(true);
|
|
|
|
ll.SetFirstLetterStyleOK(true);
|
1999-10-29 18:34:01 +04:00
|
|
|
|
2014-08-26 02:32:03 +04:00
|
|
|
kid->Reflow(aPresContext, kidMetrics, rs, aReflowStatus);
|
1999-10-29 18:34:01 +04:00
|
|
|
|
1999-04-28 02:05:02 +04:00
|
|
|
ll.EndLineReflow();
|
2011-10-17 18:59:28 +04:00
|
|
|
ll.SetInFirstLetter(false);
|
2011-08-03 22:30:58 +04:00
|
|
|
|
|
|
|
// In the floating first-letter case, we need to set this ourselves;
|
|
|
|
// nsLineLayout::BeginSpan will set it in the other case
|
2014-08-26 02:32:03 +04:00
|
|
|
mBaseline = kidMetrics.BlockStartAscent();
|
2014-08-26 02:32:03 +04:00
|
|
|
|
|
|
|
// Place and size the child and update the output metrics
|
|
|
|
LogicalSize convertedSize = kidMetrics.Size(lineWM).ConvertTo(wm, lineWM);
|
|
|
|
kid->SetRect(nsRect(bp.IStart(wm), bp.BStart(wm), convertedSize.ISize(wm),
|
|
|
|
convertedSize.BSize(wm)));
|
2017-05-17 17:47:31 +03:00
|
|
|
kid->FinishAndStoreOverflow(&kidMetrics, rs.mStyleDisplay);
|
2017-12-14 18:21:49 +03:00
|
|
|
kid->DidReflow(aPresContext, nullptr);
|
2014-08-26 02:32:03 +04:00
|
|
|
|
|
|
|
convertedSize.ISize(wm) += bp.IStartEnd(wm);
|
|
|
|
convertedSize.BSize(wm) += bp.BStartEnd(wm);
|
|
|
|
aMetrics.SetSize(wm, convertedSize);
|
|
|
|
aMetrics.SetBlockStartAscent(kidMetrics.BlockStartAscent() + bp.BStart(wm));
|
2015-01-31 22:00:44 +03:00
|
|
|
|
|
|
|
// Ensure that the overflow rect contains the child textframe's
|
|
|
|
// overflow rect.
|
|
|
|
// Note that if this is floating, the overline/underline drawable
|
|
|
|
// area is in the overflow rect of the child textframe.
|
|
|
|
aMetrics.UnionOverflowAreasWithDesiredBounds();
|
|
|
|
ConsiderChildOverflow(aMetrics.mOverflowAreas, kid);
|
|
|
|
|
2017-05-17 17:47:31 +03:00
|
|
|
FinishAndStoreOverflow(&aMetrics, aReflowInput.mStyleDisplay);
|
2016-10-04 17:22:52 +03:00
|
|
|
} else {
|
1999-10-29 18:34:01 +04:00
|
|
|
// Pretend we are a span and reflow the child frame
|
2016-07-21 13:36:39 +03:00
|
|
|
nsLineLayout* ll = aReflowInput.mLineLayout;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool pushedFrame;
|
2000-01-03 07:32:13 +03:00
|
|
|
|
2019-02-19 16:44:33 +03:00
|
|
|
ll->SetInFirstLetter(Style()->GetPseudoType() ==
|
|
|
|
PseudoStyleType::firstLetter);
|
2016-07-21 13:36:39 +03:00
|
|
|
ll->BeginSpan(this, &aReflowInput, bp.IStart(wm), availSize.ISize(wm),
|
2014-07-24 12:28:46 +04:00
|
|
|
&mBaseline);
|
2014-08-26 02:32:03 +04:00
|
|
|
ll->ReflowFrame(kid, aReflowStatus, &kidMetrics, pushedFrame);
|
2014-08-26 02:32:03 +04:00
|
|
|
NS_ASSERTION(lineWM.IsVertical() == wm.IsVertical(),
|
|
|
|
"we're assuming we can mix sizes between lineWM and wm "
|
|
|
|
"since we shouldn't have orthogonal writing modes within "
|
|
|
|
"a line.");
|
|
|
|
aMetrics.ISize(lineWM) = ll->EndSpan(this) + bp.IStartEnd(wm);
|
2011-10-17 18:59:28 +04:00
|
|
|
ll->SetInFirstLetter(false);
|
1999-04-28 02:05:02 +04:00
|
|
|
|
2018-03-22 21:20:41 +03:00
|
|
|
if (mComputedStyle->StyleTextReset()->mInitialLetterSize != 0.0f) {
|
2016-10-04 17:22:52 +03:00
|
|
|
aMetrics.SetBlockStartAscent(kidMetrics.BlockStartAscent() +
|
|
|
|
bp.BStart(wm));
|
|
|
|
aMetrics.BSize(lineWM) = kidMetrics.BSize(lineWM) + bp.BStartEnd(wm);
|
|
|
|
} else {
|
|
|
|
nsLayoutUtils::SetBSizeFromFontMetrics(this, aMetrics, bp, lineWM, wm);
|
|
|
|
}
|
2014-08-26 02:32:03 +04:00
|
|
|
}
|
2008-04-11 12:44:58 +04:00
|
|
|
|
2017-02-14 11:05:24 +03:00
|
|
|
if (!aReflowStatus.IsInlineBreakBefore()) {
|
2011-07-19 16:20:33 +04:00
|
|
|
// Create a continuation or remove existing continuations based on
|
|
|
|
// the reflow completion status.
|
2017-02-11 17:45:07 +03:00
|
|
|
if (aReflowStatus.IsComplete()) {
|
2016-07-21 13:36:39 +03:00
|
|
|
if (aReflowInput.mLineLayout) {
|
|
|
|
aReflowInput.mLineLayout->SetFirstLetterStyleOK(false);
|
2010-03-17 20:30:30 +03:00
|
|
|
}
|
2011-07-19 16:20:33 +04:00
|
|
|
nsIFrame* kidNextInFlow = kid->GetNextInFlow();
|
|
|
|
if (kidNextInFlow) {
|
|
|
|
// Remove all of the childs next-in-flows
|
2014-05-25 02:20:40 +04:00
|
|
|
kidNextInFlow->GetParent()->DeleteNextInFlowChild(kidNextInFlow, true);
|
2011-07-19 16:20:33 +04:00
|
|
|
}
|
2016-10-04 17:22:52 +03:00
|
|
|
} else {
|
2011-07-19 16:20:33 +04:00
|
|
|
// Create a continuation for the child frame if it doesn't already
|
|
|
|
// have one.
|
2012-02-22 03:50:16 +04:00
|
|
|
if (!IsFloating()) {
|
2014-12-02 09:03:57 +03:00
|
|
|
CreateNextInFlow(kid);
|
2011-07-19 16:20:33 +04:00
|
|
|
// And then push it to our overflow list
|
|
|
|
const nsFrameList& overflow = mFrames.RemoveFramesAfter(kid);
|
|
|
|
if (overflow.NotEmpty()) {
|
2014-02-07 02:07:47 +04:00
|
|
|
SetOverflowFrames(overflow);
|
2011-07-19 16:20:33 +04:00
|
|
|
}
|
|
|
|
} else if (!kid->GetNextInFlow()) {
|
|
|
|
// For floating first letter frames (if a continuation wasn't already
|
|
|
|
// created for us) we need to put the continuation with the rest of the
|
|
|
|
// text that the first letter frame was made out of.
|
|
|
|
nsIFrame* continuation;
|
2014-05-13 04:47:52 +04:00
|
|
|
CreateContinuationForFloatingParent(aPresContext, kid, &continuation,
|
|
|
|
true);
|
2010-03-17 20:30:30 +03:00
|
|
|
}
|
1999-04-29 04:16:44 +04:00
|
|
|
}
|
1999-04-28 02:05:02 +04:00
|
|
|
}
|
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
NS_FRAME_SET_TRUNCATION(aReflowStatus, aReflowInput, aMetrics);
|
1999-04-28 02:05:02 +04:00
|
|
|
}
|
|
|
|
|
2019-02-26 01:09:24 +03:00
|
|
|
/* virtual */
|
|
|
|
bool nsFirstLetterFrame::CanContinueTextRun() const {
|
2000-07-29 02:29:28 +04:00
|
|
|
// We can continue a text run through a first-letter frame.
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2000-07-29 02:29:28 +04:00
|
|
|
}
|
|
|
|
|
2019-12-28 06:27:13 +03:00
|
|
|
void nsFirstLetterFrame::CreateContinuationForFloatingParent(
|
2010-03-17 20:30:30 +03:00
|
|
|
nsPresContext* aPresContext, nsIFrame* aChild, nsIFrame** aContinuation,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aIsFluid) {
|
2012-02-22 03:50:16 +04:00
|
|
|
NS_ASSERTION(IsFloating(),
|
2010-03-17 20:30:30 +03:00
|
|
|
"can only call this on floating first letter frames");
|
2018-04-28 22:50:58 +03:00
|
|
|
MOZ_ASSERT(aContinuation, "bad args");
|
2010-03-17 20:30:30 +03:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
*aContinuation = nullptr;
|
2010-03-17 20:30:30 +03:00
|
|
|
|
2019-04-03 15:40:26 +03:00
|
|
|
mozilla::PresShell* presShell = aPresContext->PresShell();
|
2017-05-31 22:29:49 +03:00
|
|
|
nsPlaceholderFrame* placeholderFrame = GetPlaceholderFrame();
|
2014-05-25 02:20:40 +04:00
|
|
|
nsContainerFrame* parent = placeholderFrame->GetParent();
|
2010-03-17 20:30:30 +03:00
|
|
|
|
2013-03-20 05:47:49 +04:00
|
|
|
nsIFrame* continuation = presShell->FrameConstructor()->CreateContinuingFrame(
|
|
|
|
aPresContext, aChild, parent, aIsFluid);
|
2010-03-17 20:30:30 +03:00
|
|
|
|
2014-01-10 05:44:58 +04:00
|
|
|
// The continuation will have gotten the first letter style from its
|
2018-03-23 16:49:21 +03:00
|
|
|
// prev continuation, so we need to repair the ComputedStyle so it
|
2010-03-17 20:30:30 +03:00
|
|
|
// doesn't have the first letter styling.
|
2017-06-02 11:49:56 +03:00
|
|
|
//
|
2018-03-23 16:49:21 +03:00
|
|
|
// Note that getting parent frame's ComputedStyle is different from getting
|
|
|
|
// this frame's ComputedStyle's parent in the presence of ::first-line,
|
2017-06-02 11:49:56 +03:00
|
|
|
// which we do want the continuation to inherit from.
|
2018-03-22 21:20:41 +03:00
|
|
|
ComputedStyle* parentSC = parent->Style();
|
2010-03-17 20:30:30 +03:00
|
|
|
if (parentSC) {
|
2018-03-22 21:20:41 +03:00
|
|
|
RefPtr<ComputedStyle> newSC;
|
2017-03-08 08:18:32 +03:00
|
|
|
newSC =
|
|
|
|
presShell->StyleSet()->ResolveStyleForFirstLetterContinuation(parentSC);
|
2018-03-22 21:20:41 +03:00
|
|
|
continuation->SetComputedStyle(newSC);
|
2014-04-08 09:13:28 +04:00
|
|
|
nsLayoutUtils::MarkDescendantsDirty(continuation);
|
2010-03-17 20:30:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// XXX Bidi may not be involved but we have to use the list name
|
2011-08-25 00:54:30 +04:00
|
|
|
// kNoReflowPrincipalList because this is just like creating a continuation
|
2010-03-17 20:30:30 +03:00
|
|
|
// except we have to insert it in a different place and we don't want a
|
|
|
|
// reflow command to try to be issued.
|
|
|
|
nsFrameList temp(continuation, continuation);
|
2019-07-18 02:34:45 +03:00
|
|
|
parent->InsertFrames(kNoReflowPrincipalList, placeholderFrame, nullptr, temp);
|
2010-03-17 20:30:30 +03:00
|
|
|
|
|
|
|
*aContinuation = continuation;
|
|
|
|
}
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
void nsFirstLetterFrame::DrainOverflowFrames(nsPresContext* aPresContext) {
|
1999-04-28 02:05:02 +04:00
|
|
|
// Check for an overflow list with our prev-in-flow
|
2006-02-22 00:33:47 +03:00
|
|
|
nsFirstLetterFrame* prevInFlow = (nsFirstLetterFrame*)GetPrevInFlow();
|
2013-04-01 19:26:02 +04:00
|
|
|
if (prevInFlow) {
|
|
|
|
AutoFrameListPtr overflowFrames(aPresContext,
|
|
|
|
prevInFlow->StealOverflowFrames());
|
1999-10-21 09:11:43 +04:00
|
|
|
if (overflowFrames) {
|
1999-04-28 02:05:02 +04:00
|
|
|
NS_ASSERTION(mFrames.IsEmpty(), "bad overflow list");
|
|
|
|
|
|
|
|
// 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(*overflowFrames, prevInFlow,
|
|
|
|
this);
|
2012-07-30 18:20:58 +04:00
|
|
|
mFrames.InsertFrames(this, nullptr, *overflowFrames);
|
1999-04-28 02:05:02 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// It's also possible that we have an overflow list for ourselves
|
2013-04-01 19:26:02 +04:00
|
|
|
AutoFrameListPtr overflowFrames(aPresContext, StealOverflowFrames());
|
1999-10-21 09:11:43 +04:00
|
|
|
if (overflowFrames) {
|
1999-04-28 02:05:02 +04:00
|
|
|
NS_ASSERTION(mFrames.NotEmpty(), "overflow list w/o frames");
|
2012-07-30 18:20:58 +04:00
|
|
|
mFrames.AppendFrames(nullptr, *overflowFrames);
|
1999-04-28 02:05:02 +04:00
|
|
|
}
|
|
|
|
|
2018-03-23 16:49:21 +03:00
|
|
|
// Now repair our first frames ComputedStyle (since we only reflow
|
1999-10-29 18:34:01 +04:00
|
|
|
// one frame there is no point in doing any other ones until they
|
|
|
|
// are reflowed)
|
1999-04-28 02:05:02 +04:00
|
|
|
nsIFrame* kid = mFrames.FirstChild();
|
1999-04-29 04:16:44 +04:00
|
|
|
if (kid) {
|
2003-06-27 22:13:48 +04:00
|
|
|
nsIContent* kidContent = kid->GetContent();
|
1999-10-29 18:34:01 +04:00
|
|
|
if (kidContent) {
|
2001-10-31 05:53:47 +03:00
|
|
|
NS_ASSERTION(kidContent->IsText(), "should contain only text nodes");
|
2018-03-22 21:20:41 +03:00
|
|
|
ComputedStyle* parentSC;
|
2017-06-24 10:17:37 +03:00
|
|
|
if (prevInFlow) {
|
|
|
|
// This is for the rest of the content not in the first-letter.
|
2019-02-19 16:44:33 +03:00
|
|
|
nsIFrame* styleParent =
|
|
|
|
CorrectStyleParentFrame(GetParent(), PseudoStyleType::firstLetter);
|
2018-03-22 21:20:41 +03:00
|
|
|
parentSC = styleParent->Style();
|
2017-06-24 10:17:37 +03:00
|
|
|
} else {
|
|
|
|
// And this for the first-letter style.
|
2018-03-22 21:20:41 +03:00
|
|
|
parentSC = mComputedStyle;
|
2017-06-24 10:17:37 +03:00
|
|
|
}
|
2018-03-22 21:20:41 +03:00
|
|
|
RefPtr<ComputedStyle> sc =
|
2017-06-24 10:17:37 +03:00
|
|
|
aPresContext->StyleSet()->ResolveStyleForText(kidContent, parentSC);
|
2018-03-22 21:20:41 +03:00
|
|
|
kid->SetComputedStyle(sc);
|
2014-04-08 09:13:28 +04:00
|
|
|
nsLayoutUtils::MarkDescendantsDirty(kid);
|
1999-10-29 18:34:01 +04:00
|
|
|
}
|
1999-04-29 04:16:44 +04:00
|
|
|
}
|
1999-04-28 02:05:02 +04:00
|
|
|
}
|
2010-08-31 22:54:44 +04:00
|
|
|
|
2014-06-17 16:19:38 +04:00
|
|
|
nscoord nsFirstLetterFrame::GetLogicalBaseline(WritingMode aWritingMode) const {
|
2010-08-31 22:54:44 +04:00
|
|
|
return mBaseline;
|
|
|
|
}
|
2014-01-12 08:05:49 +04:00
|
|
|
|
2016-07-21 13:36:39 +03:00
|
|
|
nsIFrame::LogicalSides nsFirstLetterFrame::GetLogicalSkipSides(
|
|
|
|
const ReflowInput* aReflowInput) const {
|
2014-01-12 08:05:49 +04:00
|
|
|
if (GetPrevContinuation()) {
|
|
|
|
// We shouldn't get calls to GetSkipSides for later continuations since
|
2018-03-23 16:49:21 +03:00
|
|
|
// they have separate ComputedStyles with initial values for all the
|
2014-01-12 08:05:49 +04:00
|
|
|
// properties that could trigger a call to GetSkipSides. Then again,
|
|
|
|
// it's not really an error to call GetSkipSides on any frame, so
|
|
|
|
// that's why we handle it properly.
|
2014-06-28 14:13:14 +04:00
|
|
|
return LogicalSides(eLogicalSideBitsAll);
|
2014-01-12 08:05:49 +04:00
|
|
|
}
|
2014-06-28 14:13:13 +04:00
|
|
|
return LogicalSides(); // first continuation displays all sides
|
2014-01-12 08:05:49 +04:00
|
|
|
}
|