2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 14:30:37 +00:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1999-04-27 22:05:02 +00:00
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
1999-04-27 22:05:02 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1999-04-27 22:05:02 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-28 20:14:13 +00:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 03:40:37 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 14:30:37 +00:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-28 20:14:13 +00:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-18 14:30:37 +00:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-28 20:14:13 +00:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-18 14:30:37 +00:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-28 20:14:13 +00:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2006-03-29 18:29:03 +00:00
|
|
|
|
|
|
|
/* rendering object for CSS :first-letter pseudo-element */
|
|
|
|
|
1999-10-29 14:34:01 +00:00
|
|
|
#include "nsCOMPtr.h"
|
2008-04-11 08:44:58 +00:00
|
|
|
#include "nsFirstLetterFrame.h"
|
2004-07-31 23:15:21 +00:00
|
|
|
#include "nsPresContext.h"
|
2003-02-22 00:32:13 +00:00
|
|
|
#include "nsStyleContext.h"
|
1999-10-29 14:34:01 +00:00
|
|
|
#include "nsIContent.h"
|
1999-04-27 22:05:02 +00:00
|
|
|
#include "nsLineLayout.h"
|
2007-01-30 00:06:41 +00:00
|
|
|
#include "nsGkAtoms.h"
|
2003-02-22 00:32:13 +00:00
|
|
|
#include "nsAutoPtr.h"
|
2004-01-28 00:18:22 +00:00
|
|
|
#include "nsStyleSet.h"
|
2004-02-23 21:29:06 +00:00
|
|
|
#include "nsFrameManager.h"
|
1999-04-27 22:05:02 +00:00
|
|
|
|
2005-11-04 02:38:33 +00:00
|
|
|
nsIFrame*
|
2006-03-26 21:30:36 +00:00
|
|
|
NS_NewFirstLetterFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
1999-04-27 22:05:02 +00:00
|
|
|
{
|
2006-03-26 21:30:36 +00:00
|
|
|
return new (aPresShell) nsFirstLetterFrame(aContext);
|
1999-04-27 22:05:02 +00:00
|
|
|
}
|
|
|
|
|
1999-11-01 22:12:45 +00:00
|
|
|
#ifdef NS_DEBUG
|
1999-04-27 22:05:02 +00:00
|
|
|
NS_IMETHODIMP
|
2001-11-14 01:33:42 +00:00
|
|
|
nsFirstLetterFrame::GetFrameName(nsAString& aResult) const
|
1999-04-27 22:05:02 +00:00
|
|
|
{
|
2001-11-14 01:33:42 +00:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("Letter"), aResult);
|
1999-04-27 22:05:02 +00:00
|
|
|
}
|
1999-11-01 22:12:45 +00:00
|
|
|
#endif
|
1999-04-27 22:05:02 +00:00
|
|
|
|
2003-10-31 20:19:18 +00:00
|
|
|
nsIAtom*
|
|
|
|
nsFirstLetterFrame::GetType() const
|
1999-04-27 22:05:02 +00:00
|
|
|
{
|
2006-12-26 17:47:52 +00:00
|
|
|
return nsGkAtoms::letterFrame;
|
1999-04-27 22:05:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PRIntn
|
|
|
|
nsFirstLetterFrame::GetSkipSides() const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2006-03-09 18:55:21 +00:00
|
|
|
nsFirstLetterFrame::Init(nsIContent* aContent,
|
1999-04-27 22:05:02 +00:00
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
2003-02-22 00:32:13 +00:00
|
|
|
nsRefPtr<nsStyleContext> newSC;
|
1999-04-27 22:05:02 +00:00
|
|
|
if (aPrevInFlow) {
|
2001-10-31 02:53:47 +00:00
|
|
|
// Get proper style context for ourselves. We're creating the frame
|
|
|
|
// that represents everything *except* the first letter, so just create
|
|
|
|
// a style context like we would for a text node.
|
2006-03-26 21:30:36 +00:00
|
|
|
nsStyleContext* parentStyleContext = mStyleContext->GetParent();
|
1999-04-27 22:05:02 +00:00
|
|
|
if (parentStyleContext) {
|
2006-03-26 21:30:36 +00:00
|
|
|
newSC = mStyleContext->GetRuleNode()->GetPresContext()->StyleSet()->
|
2004-01-28 00:18:22 +00:00
|
|
|
ResolveStyleForNonElement(parentStyleContext);
|
2001-10-31 02:53:47 +00:00
|
|
|
if (newSC)
|
2006-03-26 21:30:36 +00:00
|
|
|
SetStyleContextWithoutNotification(newSC);
|
1999-04-27 22:05:02 +00:00
|
|
|
}
|
|
|
|
}
|
2006-03-09 18:55:21 +00:00
|
|
|
|
2006-03-26 21:30:36 +00:00
|
|
|
return nsFirstLetterFrameSuper::Init(aContent, aParent, aPrevInFlow);
|
1999-04-27 22:05:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2006-04-10 00:16:29 +00:00
|
|
|
nsFirstLetterFrame::SetInitialChildList(nsIAtom* aListName,
|
|
|
|
nsIFrame* aChildList)
|
1999-04-27 22:05:02 +00:00
|
|
|
{
|
|
|
|
mFrames.SetFrames(aChildList);
|
2007-03-30 21:11:41 +00:00
|
|
|
nsFrameManager *frameManager = PresContext()->FrameManager();
|
2004-01-31 22:41:40 +00:00
|
|
|
|
2003-11-13 04:31:04 +00:00
|
|
|
for (nsIFrame* frame = aChildList; frame; frame = frame->GetNextSibling()) {
|
2006-03-16 01:30:38 +00:00
|
|
|
NS_ASSERTION(frame->GetParent() == this, "Unexpected parent");
|
|
|
|
frameManager->ReParentStyleContext(frame);
|
1999-10-29 14:34:01 +00:00
|
|
|
}
|
1999-04-27 22:05:02 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-11-05 22:09:16 +00:00
|
|
|
NS_IMETHODIMP
|
2008-09-07 14:12:50 +00:00
|
|
|
nsFirstLetterFrame::SetSelected(nsPresContext* aPresContext, nsIDOMRange *aRange,PRBool aSelected, nsSpread aSpread, SelectionType aType)
|
1999-11-05 22:09:16 +00:00
|
|
|
{
|
|
|
|
if (aSelected && ParentDisablesSelection())
|
|
|
|
return NS_OK;
|
2004-01-09 14:20:53 +00:00
|
|
|
nsIFrame *child = GetFirstChild(nsnull);
|
2003-06-27 18:13:48 +00:00
|
|
|
while (child)
|
1999-11-05 22:09:16 +00:00
|
|
|
{
|
2008-09-07 14:12:50 +00:00
|
|
|
child->SetSelected(aPresContext, aRange, aSelected, aSpread, aType);
|
2003-06-27 18:13:48 +00:00
|
|
|
// don't worry about result. there are more frames to come
|
|
|
|
child = child->GetNextSibling();
|
1999-11-05 22:09:16 +00:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-01-08 00:31:32 +00:00
|
|
|
NS_IMETHODIMP
|
2000-06-27 14:47:21 +00:00
|
|
|
nsFirstLetterFrame::GetChildFrameContainingOffset(PRInt32 inContentOffset,
|
2000-01-22 01:16:50 +00:00
|
|
|
PRBool inHint,
|
|
|
|
PRInt32* outFrameContentOffset,
|
|
|
|
nsIFrame **outChildFrame)
|
2000-01-08 00:31:32 +00:00
|
|
|
{
|
2000-06-27 14:47:21 +00:00
|
|
|
nsIFrame *kid = mFrames.FirstChild();
|
|
|
|
if (kid)
|
2000-01-08 00:31:32 +00:00
|
|
|
{
|
|
|
|
return kid->GetChildFrameContainingOffset(inContentOffset, inHint, outFrameContentOffset, outChildFrame);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return nsFrame::GetChildFrameContainingOffset(inContentOffset, inHint, outFrameContentOffset, outChildFrame);
|
|
|
|
}
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
// Needed for non-floating first-letter frames and for the continuations
|
|
|
|
// following the first-letter that we also use nsFirstLetterFrame for.
|
|
|
|
/* virtual */ void
|
|
|
|
nsFirstLetterFrame::AddInlineMinWidth(nsIRenderingContext *aRenderingContext,
|
|
|
|
nsIFrame::InlineMinWidthData *aData)
|
|
|
|
{
|
|
|
|
DoInlineIntrinsicWidth(aRenderingContext, aData, nsLayoutUtils::MIN_WIDTH);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Needed for non-floating first-letter frames and for the continuations
|
|
|
|
// following the first-letter that we also use nsFirstLetterFrame for.
|
|
|
|
/* virtual */ void
|
|
|
|
nsFirstLetterFrame::AddInlinePrefWidth(nsIRenderingContext *aRenderingContext,
|
|
|
|
nsIFrame::InlinePrefWidthData *aData)
|
|
|
|
{
|
|
|
|
DoInlineIntrinsicWidth(aRenderingContext, aData, nsLayoutUtils::PREF_WIDTH);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Needed for floating first-letter frames.
|
|
|
|
/* virtual */ nscoord
|
|
|
|
nsFirstLetterFrame::GetMinWidth(nsIRenderingContext *aRenderingContext)
|
|
|
|
{
|
|
|
|
return nsLayoutUtils::MinWidthFromInline(this, aRenderingContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Needed for floating first-letter frames.
|
|
|
|
/* virtual */ nscoord
|
|
|
|
nsFirstLetterFrame::GetPrefWidth(nsIRenderingContext *aRenderingContext)
|
|
|
|
{
|
|
|
|
return nsLayoutUtils::PrefWidthFromInline(this, aRenderingContext);
|
|
|
|
}
|
|
|
|
|
2007-07-19 04:29:59 +00:00
|
|
|
/* virtual */ nsSize
|
|
|
|
nsFirstLetterFrame::ComputeSize(nsIRenderingContext *aRenderingContext,
|
|
|
|
nsSize aCBSize, nscoord aAvailableWidth,
|
|
|
|
nsSize aMargin, nsSize aBorder, nsSize aPadding,
|
|
|
|
PRBool aShrinkWrap)
|
|
|
|
{
|
|
|
|
if (GetPrevInFlow()) {
|
|
|
|
// We're wrapping the text *after* the first letter, so behave like an
|
|
|
|
// inline frame.
|
|
|
|
return nsSize(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
|
|
|
|
}
|
|
|
|
return nsFirstLetterFrameSuper::ComputeSize(aRenderingContext,
|
|
|
|
aCBSize, aAvailableWidth, aMargin, aBorder, aPadding, aShrinkWrap);
|
|
|
|
}
|
|
|
|
|
1999-04-27 22:05:02 +00:00
|
|
|
NS_IMETHODIMP
|
2004-07-31 23:15:21 +00:00
|
|
|
nsFirstLetterFrame::Reflow(nsPresContext* aPresContext,
|
1999-04-27 22:05:02 +00:00
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aReflowStatus)
|
|
|
|
{
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsFirstLetterFrame");
|
2001-11-14 13:40:03 +00:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aMetrics, aReflowStatus);
|
1999-10-29 14:34:01 +00:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
1999-04-27 22:05:02 +00:00
|
|
|
// Grab overflow list
|
1999-11-24 06:03:41 +00:00
|
|
|
DrainOverflowFrames(aPresContext);
|
1999-04-27 22:05:02 +00:00
|
|
|
|
|
|
|
nsIFrame* kid = mFrames.FirstChild();
|
|
|
|
|
|
|
|
// Setup reflow state for our child
|
|
|
|
nsSize availSize(aReflowState.availableWidth, aReflowState.availableHeight);
|
|
|
|
const nsMargin& bp = aReflowState.mComputedBorderPadding;
|
|
|
|
nscoord lr = bp.left + bp.right;
|
|
|
|
nscoord tb = bp.top + bp.bottom;
|
2007-12-12 21:51:00 +00:00
|
|
|
NS_ASSERTION(availSize.width != NS_UNCONSTRAINEDSIZE,
|
|
|
|
"should no longer use unconstrained widths");
|
|
|
|
availSize.width -= lr;
|
1999-04-27 22:05:02 +00:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != availSize.height) {
|
1999-10-29 14:34:01 +00:00
|
|
|
availSize.height -= tb;
|
1999-04-27 22:05:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Reflow the child
|
1999-10-29 14:34:01 +00:00
|
|
|
if (!aReflowState.mLineLayout) {
|
1999-04-27 22:05:02 +00: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.
|
1999-10-29 14:34:01 +00:00
|
|
|
nsHTMLReflowState rs(aPresContext, aReflowState, kid, availSize);
|
2007-01-18 01:20:09 +00:00
|
|
|
nsLineLayout ll(aPresContext, nsnull, &aReflowState, nsnull);
|
2007-12-12 21:51:00 +00:00
|
|
|
ll.BeginLineReflow(bp.left, bp.top, availSize.width, NS_UNCONSTRAINEDSIZE,
|
1999-04-27 22:05:02 +00:00
|
|
|
PR_FALSE, PR_TRUE);
|
1999-07-20 03:51:46 +00:00
|
|
|
rs.mLineLayout = ≪
|
2009-01-05 00:36:56 +00:00
|
|
|
ll.SetInFirstLetter(PR_TRUE);
|
1999-04-27 22:05:02 +00:00
|
|
|
ll.SetFirstLetterStyleOK(PR_TRUE);
|
1999-10-29 14:34:01 +00:00
|
|
|
|
1999-10-30 02:52:11 +00:00
|
|
|
kid->WillReflow(aPresContext);
|
|
|
|
kid->Reflow(aPresContext, aMetrics, rs, aReflowStatus);
|
1999-10-29 14:34:01 +00:00
|
|
|
|
1999-04-27 22:05:02 +00:00
|
|
|
ll.EndLineReflow();
|
2009-01-05 00:36:56 +00:00
|
|
|
ll.SetInFirstLetter(PR_FALSE);
|
1999-04-27 22:05:02 +00:00
|
|
|
}
|
|
|
|
else {
|
1999-10-29 14:34:01 +00:00
|
|
|
// Pretend we are a span and reflow the child frame
|
|
|
|
nsLineLayout* ll = aReflowState.mLineLayout;
|
2000-01-03 04:32:13 +00:00
|
|
|
PRBool pushedFrame;
|
|
|
|
|
2009-01-05 00:36:56 +00:00
|
|
|
ll->SetInFirstLetter(
|
|
|
|
mStyleContext->GetPseudoType() == nsCSSPseudoElements::firstLetter);
|
1999-10-29 14:34:01 +00:00
|
|
|
ll->BeginSpan(this, &aReflowState, bp.left, availSize.width);
|
2002-05-10 18:22:41 +00:00
|
|
|
ll->ReflowFrame(kid, aReflowStatus, &aMetrics, pushedFrame);
|
2007-12-12 21:51:18 +00:00
|
|
|
ll->EndSpan(this);
|
2009-01-05 00:36:56 +00:00
|
|
|
ll->SetInFirstLetter(PR_FALSE);
|
1999-04-27 22:05:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Place and size the child and update the output metrics
|
2003-06-27 18:13:48 +00:00
|
|
|
kid->SetRect(nsRect(bp.left, bp.top, aMetrics.width, aMetrics.height));
|
2008-04-11 08:44:58 +00:00
|
|
|
kid->FinishAndStoreOverflow(&aMetrics);
|
2001-12-07 14:51:12 +00:00
|
|
|
kid->DidReflow(aPresContext, nsnull, NS_FRAME_REFLOW_FINISHED);
|
2008-04-11 08:44:58 +00:00
|
|
|
|
1999-04-27 22:05:02 +00:00
|
|
|
aMetrics.width += lr;
|
|
|
|
aMetrics.height += tb;
|
1999-10-29 14:34:01 +00:00
|
|
|
aMetrics.ascent += bp.top;
|
2008-04-11 08:44:58 +00:00
|
|
|
mBaseline = aMetrics.ascent;
|
|
|
|
|
|
|
|
// 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.mOverflowArea.UnionRect(aMetrics.mOverflowArea,
|
|
|
|
nsRect(0, 0, aMetrics.width, aMetrics.height));
|
|
|
|
ConsiderChildOverflow(aMetrics.mOverflowArea, kid);
|
1999-04-27 22:05:02 +00:00
|
|
|
|
|
|
|
// Create a continuation or remove existing continuations based on
|
|
|
|
// the reflow completion status.
|
|
|
|
if (NS_FRAME_IS_COMPLETE(aReflowStatus)) {
|
2007-11-11 19:44:33 +00:00
|
|
|
if (aReflowState.mLineLayout) {
|
|
|
|
aReflowState.mLineLayout->SetFirstLetterStyleOK(PR_FALSE);
|
|
|
|
}
|
2004-09-14 02:28:03 +00:00
|
|
|
nsIFrame* kidNextInFlow = kid->GetNextInFlow();
|
2003-06-27 18:13:48 +00:00
|
|
|
if (kidNextInFlow) {
|
1999-04-27 22:05:02 +00:00
|
|
|
// Remove all of the childs next-in-flows
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<nsContainerFrame*>(kidNextInFlow->GetParent())
|
2008-12-03 01:27:19 +00:00
|
|
|
->DeleteNextInFlowChild(aPresContext, kidNextInFlow, PR_TRUE);
|
1999-04-27 22:05:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Create a continuation for the child frame if it doesn't already
|
|
|
|
// have one.
|
|
|
|
nsIFrame* nextInFlow;
|
|
|
|
rv = CreateNextInFlow(aPresContext, this, kid, nextInFlow);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
// And then push it to our overflow list
|
|
|
|
if (nextInFlow) {
|
|
|
|
kid->SetNextSibling(nsnull);
|
1999-11-24 06:03:41 +00:00
|
|
|
SetOverflowFrames(aPresContext, nextInFlow);
|
1999-04-27 22:05:02 +00:00
|
|
|
}
|
1999-04-29 00:16:44 +00:00
|
|
|
else {
|
2003-06-27 18:13:48 +00:00
|
|
|
nsIFrame* nextSib = kid->GetNextSibling();
|
1999-04-29 00:16:44 +00:00
|
|
|
if (nextSib) {
|
|
|
|
kid->SetNextSibling(nsnull);
|
1999-11-24 06:03:41 +00:00
|
|
|
SetOverflowFrames(aPresContext, nextSib);
|
1999-04-29 00:16:44 +00:00
|
|
|
}
|
|
|
|
}
|
1999-04-27 22:05:02 +00:00
|
|
|
}
|
|
|
|
|
2008-04-11 08:44:58 +00:00
|
|
|
FinishAndStoreOverflow(&aMetrics);
|
|
|
|
|
2002-05-28 22:50:43 +00:00
|
|
|
NS_FRAME_SET_TRUNCATION(aReflowStatus, aReflowState, aMetrics);
|
1999-04-27 22:05:02 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
/* virtual */ PRBool
|
|
|
|
nsFirstLetterFrame::CanContinueTextRun() const
|
2000-07-28 22:29:28 +00:00
|
|
|
{
|
|
|
|
// We can continue a text run through a first-letter frame.
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
return PR_TRUE;
|
2000-07-28 22:29:28 +00:00
|
|
|
}
|
|
|
|
|
1999-04-27 22:05:02 +00:00
|
|
|
void
|
2004-07-31 23:15:21 +00:00
|
|
|
nsFirstLetterFrame::DrainOverflowFrames(nsPresContext* aPresContext)
|
1999-04-27 22:05:02 +00:00
|
|
|
{
|
1999-10-21 05:11:43 +00:00
|
|
|
nsIFrame* overflowFrames;
|
|
|
|
|
1999-04-27 22:05:02 +00:00
|
|
|
// Check for an overflow list with our prev-in-flow
|
2006-02-21 21:33:47 +00:00
|
|
|
nsFirstLetterFrame* prevInFlow = (nsFirstLetterFrame*)GetPrevInFlow();
|
1999-04-27 22:05:02 +00:00
|
|
|
if (nsnull != prevInFlow) {
|
1999-10-21 05:11:43 +00:00
|
|
|
overflowFrames = prevInFlow->GetOverflowFrames(aPresContext, PR_TRUE);
|
|
|
|
if (overflowFrames) {
|
1999-04-27 22:05:02 +00: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.
|
1999-10-21 05:11:43 +00:00
|
|
|
nsIFrame* f = overflowFrames;
|
1999-04-27 22:05:02 +00:00
|
|
|
while (f) {
|
1999-10-26 04:44:41 +00:00
|
|
|
nsHTMLContainerFrame::ReparentFrameView(aPresContext, f, prevInFlow, this);
|
2003-06-27 18:13:48 +00:00
|
|
|
f = f->GetNextSibling();
|
1999-04-27 22:05:02 +00:00
|
|
|
}
|
1999-10-21 05:11:43 +00:00
|
|
|
mFrames.InsertFrames(this, nsnull, overflowFrames);
|
1999-04-27 22:05:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// It's also possible that we have an overflow list for ourselves
|
1999-10-21 05:11:43 +00:00
|
|
|
overflowFrames = GetOverflowFrames(aPresContext, PR_TRUE);
|
|
|
|
if (overflowFrames) {
|
1999-04-27 22:05:02 +00:00
|
|
|
NS_ASSERTION(mFrames.NotEmpty(), "overflow list w/o frames");
|
1999-10-21 05:11:43 +00:00
|
|
|
mFrames.AppendFrames(nsnull, overflowFrames);
|
1999-04-27 22:05:02 +00:00
|
|
|
}
|
|
|
|
|
1999-10-29 14:34:01 +00:00
|
|
|
// Now repair our first frames style context (since we only reflow
|
|
|
|
// one frame there is no point in doing any other ones until they
|
|
|
|
// are reflowed)
|
1999-04-27 22:05:02 +00:00
|
|
|
nsIFrame* kid = mFrames.FirstChild();
|
1999-04-29 00:16:44 +00:00
|
|
|
if (kid) {
|
2003-02-22 00:32:13 +00:00
|
|
|
nsRefPtr<nsStyleContext> sc;
|
2003-06-27 18:13:48 +00:00
|
|
|
nsIContent* kidContent = kid->GetContent();
|
1999-10-29 14:34:01 +00:00
|
|
|
if (kidContent) {
|
2006-05-05 06:52:21 +00:00
|
|
|
NS_ASSERTION(kidContent->IsNodeOfType(nsINode::eTEXT),
|
2001-10-31 02:53:47 +00:00
|
|
|
"should contain only text nodes");
|
2004-01-28 00:18:22 +00:00
|
|
|
sc = aPresContext->StyleSet()->ResolveStyleForNonElement(mStyleContext);
|
1999-10-29 14:34:01 +00:00
|
|
|
if (sc) {
|
2006-03-09 18:55:21 +00:00
|
|
|
kid->SetStyleContext(sc);
|
1999-10-29 14:34:01 +00:00
|
|
|
}
|
|
|
|
}
|
1999-04-29 00:16:44 +00:00
|
|
|
}
|
1999-04-27 22:05:02 +00:00
|
|
|
}
|