2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 18:30:37 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1999-04-28 02:05:02 +04:00
|
|
|
*
|
2004-04-18 18:30:37 +04: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-28 02:05:02 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04: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-28 02:05:02 +04:00
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-29 00:14:13 +04:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:40:37 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 18:30:37 +04: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-29 00:14:13 +04: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 18:30:37 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-29 00:14:13 +04: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 18:30:37 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-10-29 18:34:01 +04:00
|
|
|
#include "nsCOMPtr.h"
|
1999-04-28 02:05:02 +04:00
|
|
|
#include "nsHTMLContainerFrame.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
2003-02-22 03:32:13 +03:00
|
|
|
#include "nsStyleContext.h"
|
1999-10-29 18:34:01 +04:00
|
|
|
#include "nsIContent.h"
|
1999-04-28 02:05:02 +04:00
|
|
|
#include "nsLineLayout.h"
|
|
|
|
#include "nsHTMLAtoms.h"
|
|
|
|
#include "nsLayoutAtoms.h"
|
2003-02-22 03:32:13 +03:00
|
|
|
#include "nsAutoPtr.h"
|
2004-01-28 03:18:22 +03:00
|
|
|
#include "nsStyleSet.h"
|
2004-02-24 00:29:06 +03:00
|
|
|
#include "nsFrameManager.h"
|
1999-04-28 02:05:02 +04:00
|
|
|
|
|
|
|
#define nsFirstLetterFrameSuper nsHTMLContainerFrame
|
|
|
|
|
|
|
|
class nsFirstLetterFrame : public nsFirstLetterFrameSuper {
|
|
|
|
public:
|
|
|
|
nsFirstLetterFrame();
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
NS_IMETHOD Init(nsPresContext* aPresContext,
|
1999-04-28 02:05:02 +04:00
|
|
|
nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aContext,
|
1999-04-28 02:05:02 +04:00
|
|
|
nsIFrame* aPrevInFlow);
|
2004-08-01 03:15:21 +04:00
|
|
|
NS_IMETHOD SetInitialChildList(nsPresContext* aPresContext,
|
1999-04-28 02:05:02 +04:00
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aChildList);
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef NS_DEBUG
|
2001-11-14 04:33:42 +03:00
|
|
|
NS_IMETHOD GetFrameName(nsAString& aResult) const;
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|
2003-10-31 23:19:18 +03:00
|
|
|
virtual nsIAtom* GetType() const;
|
2004-08-01 03:15:21 +04:00
|
|
|
NS_IMETHOD Paint(nsPresContext* aPresContext,
|
2003-07-12 00:45:19 +04:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
PRUint32 aFlags = 0);
|
2004-08-01 03:15:21 +04:00
|
|
|
NS_IMETHOD Reflow(nsPresContext* aPresContext,
|
1999-04-28 02:05:02 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus);
|
1999-11-06 01:09:16 +03:00
|
|
|
|
2000-07-29 02:29:28 +04:00
|
|
|
NS_IMETHOD CanContinueTextRun(PRBool& aContinueTextRun) const;
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
NS_IMETHOD SetSelected(nsPresContext* aPresContext, nsIDOMRange *aRange,PRBool aSelected, nsSpread aSpread);
|
1999-11-06 01:09:16 +03:00
|
|
|
|
2000-01-08 03:31:32 +03:00
|
|
|
//override of nsFrame method
|
2000-06-27 18:47:21 +04:00
|
|
|
NS_IMETHOD GetChildFrameContainingOffset(PRInt32 inContentOffset,
|
2000-01-22 04:16:50 +03:00
|
|
|
PRBool inHint,
|
|
|
|
PRInt32* outFrameContentOffset,
|
|
|
|
nsIFrame **outChildFrame);
|
2000-06-27 18:47:21 +04:00
|
|
|
|
1999-04-28 02:05:02 +04:00
|
|
|
protected:
|
|
|
|
virtual PRIntn GetSkipSides() const;
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
void DrainOverflowFrames(nsPresContext* aPresContext);
|
1999-04-28 02:05:02 +04:00
|
|
|
};
|
|
|
|
|
2005-11-04 05:38:33 +03:00
|
|
|
nsIFrame*
|
|
|
|
NS_NewFirstLetterFrame(nsIPresShell* aPresShell)
|
1999-04-28 02:05:02 +04:00
|
|
|
{
|
2005-11-04 05:38:33 +03:00
|
|
|
return new (aPresShell) nsFirstLetterFrame;
|
1999-04-28 02:05:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsFirstLetterFrame::nsFirstLetterFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef NS_DEBUG
|
1999-04-28 02:05:02 +04:00
|
|
|
NS_IMETHODIMP
|
2001-11-14 04:33:42 +03:00
|
|
|
nsFirstLetterFrame::GetFrameName(nsAString& aResult) const
|
1999-04-28 02:05:02 +04:00
|
|
|
{
|
2001-11-14 04:33:42 +03:00
|
|
|
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
|
|
|
|
2003-10-31 23:19:18 +03:00
|
|
|
nsIAtom*
|
|
|
|
nsFirstLetterFrame::GetType() const
|
1999-04-28 02:05:02 +04:00
|
|
|
{
|
2003-10-31 23:19:18 +03:00
|
|
|
return nsLayoutAtoms::letterFrame;
|
1999-04-28 02:05:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
PRIntn
|
|
|
|
nsFirstLetterFrame::GetSkipSides() const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsFirstLetterFrame::Init(nsPresContext* aPresContext,
|
1999-04-28 02:05:02 +04:00
|
|
|
nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aContext,
|
1999-04-28 02:05:02 +04:00
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
2003-02-22 03:32:13 +03:00
|
|
|
nsRefPtr<nsStyleContext> newSC;
|
1999-04-28 02:05:02 +04:00
|
|
|
if (aPrevInFlow) {
|
2001-10-31 05:53:47 +03: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.
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* parentStyleContext = aContext->GetParent();
|
1999-04-28 02:05:02 +04:00
|
|
|
if (parentStyleContext) {
|
2004-01-28 03:18:22 +03:00
|
|
|
newSC = aPresContext->StyleSet()->
|
|
|
|
ResolveStyleForNonElement(parentStyleContext);
|
2001-10-31 05:53:47 +03:00
|
|
|
if (newSC)
|
|
|
|
aContext = newSC;
|
1999-04-28 02:05:02 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
rv = nsFirstLetterFrameSuper::Init(aPresContext, aContent, aParent,
|
|
|
|
aContext, aPrevInFlow);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsFirstLetterFrame::SetInitialChildList(nsPresContext* aPresContext,
|
1999-04-28 02:05:02 +04:00
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aChildList)
|
|
|
|
{
|
|
|
|
mFrames.SetFrames(aChildList);
|
2004-02-24 00:29:06 +03:00
|
|
|
nsFrameManager *frameManager = aPresContext->FrameManager();
|
2004-02-01 01:41:40 +03:00
|
|
|
|
2003-11-13 07:31:04 +03:00
|
|
|
for (nsIFrame* frame = aChildList; frame; frame = frame->GetNextSibling()) {
|
2004-02-01 01:41:40 +03:00
|
|
|
frameManager->ReParentStyleContext(frame, mStyleContext);
|
1999-10-29 18:34:01 +04:00
|
|
|
}
|
1999-04-28 02:05:02 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-11-06 01:09:16 +03:00
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsFirstLetterFrame::SetSelected(nsPresContext* aPresContext, nsIDOMRange *aRange,PRBool aSelected, nsSpread aSpread)
|
1999-11-06 01:09:16 +03:00
|
|
|
{
|
|
|
|
if (aSelected && ParentDisablesSelection())
|
|
|
|
return NS_OK;
|
2004-01-09 17:20:53 +03:00
|
|
|
nsIFrame *child = GetFirstChild(nsnull);
|
2003-06-27 22:13:48 +04:00
|
|
|
while (child)
|
1999-11-06 01:09:16 +03:00
|
|
|
{
|
2003-06-27 22:13:48 +04:00
|
|
|
child->SetSelected(aPresContext, aRange, aSelected, aSpread);
|
|
|
|
// don't worry about result. there are more frames to come
|
|
|
|
child = child->GetNextSibling();
|
1999-11-06 01:09:16 +03:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-01-08 03:31:32 +03:00
|
|
|
NS_IMETHODIMP
|
2000-06-27 18:47:21 +04:00
|
|
|
nsFirstLetterFrame::GetChildFrameContainingOffset(PRInt32 inContentOffset,
|
2000-01-22 04:16:50 +03:00
|
|
|
PRBool inHint,
|
|
|
|
PRInt32* outFrameContentOffset,
|
|
|
|
nsIFrame **outChildFrame)
|
2000-01-08 03:31:32 +03:00
|
|
|
{
|
2000-06-27 18:47:21 +04:00
|
|
|
nsIFrame *kid = mFrames.FirstChild();
|
|
|
|
if (kid)
|
2000-01-08 03:31:32 +03:00
|
|
|
{
|
|
|
|
return kid->GetChildFrameContainingOffset(inContentOffset, inHint, outFrameContentOffset, outChildFrame);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return nsFrame::GetChildFrameContainingOffset(inContentOffset, inHint, outFrameContentOffset, outChildFrame);
|
|
|
|
}
|
|
|
|
|
2003-07-12 00:45:19 +04:00
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsFirstLetterFrame::Paint(nsPresContext* aPresContext,
|
2003-07-12 00:45:19 +04:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
PRUint32 aFlags)
|
|
|
|
{
|
|
|
|
if (NS_FRAME_IS_UNFLOWABLE & mState) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Paint inline element backgrounds in the foreground layer.
|
|
|
|
if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer) {
|
|
|
|
PaintSelf(aPresContext, aRenderingContext, aDirtyRect);
|
|
|
|
}
|
|
|
|
|
|
|
|
PaintDecorationsAndChildren(aPresContext, aRenderingContext, aDirtyRect,
|
|
|
|
aWhichLayer, PR_FALSE, aFlags);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-01-08 03:31:32 +03:00
|
|
|
|
|
|
|
|
1999-04-28 02:05:02 +04:00
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsFirstLetterFrame::Reflow(nsPresContext* aPresContext,
|
1999-04-28 02:05:02 +04:00
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aReflowStatus)
|
|
|
|
{
|
2000-04-21 18:59:47 +04:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsFirstLetterFrame", aReflowState.reason);
|
2001-11-14 16:40:03 +03:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aMetrics, aReflowStatus);
|
1999-10-29 18:34:01 +04:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
if (NS_UNCONSTRAINEDSIZE != availSize.width) {
|
|
|
|
availSize.width -= lr;
|
|
|
|
}
|
|
|
|
if (NS_UNCONSTRAINEDSIZE != availSize.height) {
|
1999-10-29 18:34:01 +04:00
|
|
|
availSize.height -= tb;
|
1999-04-28 02:05:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Reflow the child
|
1999-10-29 18:34:01 +04:00
|
|
|
if (!aReflowState.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.
|
1999-10-29 18:34:01 +04:00
|
|
|
nsHTMLReflowState rs(aPresContext, aReflowState, kid, availSize);
|
1999-04-28 02:05:02 +04:00
|
|
|
nsLineLayout ll(aPresContext, nsnull, &aReflowState,
|
2003-01-09 17:26:32 +03:00
|
|
|
aMetrics.mComputeMEW);
|
1999-04-28 02:05:02 +04:00
|
|
|
ll.BeginLineReflow(0, 0, NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE,
|
|
|
|
PR_FALSE, PR_TRUE);
|
1999-07-20 07:51:46 +04:00
|
|
|
rs.mLineLayout = ≪
|
1999-04-28 02:05:02 +04:00
|
|
|
ll.SetFirstLetterStyleOK(PR_TRUE);
|
1999-10-29 18:34:01 +04:00
|
|
|
|
1999-10-30 06:52:11 +04:00
|
|
|
kid->WillReflow(aPresContext);
|
|
|
|
kid->Reflow(aPresContext, aMetrics, rs, aReflowStatus);
|
1999-10-29 18:34:01 +04:00
|
|
|
|
1999-04-28 02:05:02 +04:00
|
|
|
ll.EndLineReflow();
|
|
|
|
}
|
|
|
|
else {
|
1999-10-29 18:34:01 +04:00
|
|
|
// Pretend we are a span and reflow the child frame
|
|
|
|
nsLineLayout* ll = aReflowState.mLineLayout;
|
2000-01-03 07:32:13 +03:00
|
|
|
PRBool pushedFrame;
|
|
|
|
|
1999-10-29 18:34:01 +04:00
|
|
|
ll->BeginSpan(this, &aReflowState, bp.left, availSize.width);
|
2002-05-10 22:22:41 +04:00
|
|
|
ll->ReflowFrame(kid, aReflowStatus, &aMetrics, pushedFrame);
|
1999-10-29 18:34:01 +04:00
|
|
|
nsSize size;
|
2003-01-09 17:26:32 +03:00
|
|
|
ll->EndSpan(this, size,
|
|
|
|
aMetrics.mComputeMEW ? &aMetrics.mMaxElementWidth : nsnull);
|
1999-04-28 02:05:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Place and size the child and update the output metrics
|
2003-06-27 22:13:48 +04:00
|
|
|
kid->SetRect(nsRect(bp.left, bp.top, aMetrics.width, aMetrics.height));
|
2001-12-07 17:51:12 +03:00
|
|
|
kid->DidReflow(aPresContext, nsnull, NS_FRAME_REFLOW_FINISHED);
|
1999-04-28 02:05:02 +04:00
|
|
|
aMetrics.width += lr;
|
|
|
|
aMetrics.height += tb;
|
1999-10-29 18:34:01 +04:00
|
|
|
aMetrics.ascent += bp.top;
|
|
|
|
aMetrics.descent += bp.bottom;
|
2003-01-09 17:26:32 +03:00
|
|
|
if (aMetrics.mComputeMEW) {
|
|
|
|
aMetrics.mMaxElementWidth += lr;
|
1999-04-28 02:05:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Create a continuation or remove existing continuations based on
|
|
|
|
// the reflow completion status.
|
|
|
|
if (NS_FRAME_IS_COMPLETE(aReflowStatus)) {
|
2004-09-14 06:28:03 +04:00
|
|
|
nsIFrame* kidNextInFlow = kid->GetNextInFlow();
|
2003-06-27 22:13:48 +04:00
|
|
|
if (kidNextInFlow) {
|
1999-04-28 02:05:02 +04:00
|
|
|
// Remove all of the childs next-in-flows
|
2003-06-27 22:13:48 +04:00
|
|
|
NS_STATIC_CAST(nsContainerFrame*, kidNextInFlow->GetParent())
|
|
|
|
->DeleteNextInFlowChild(aPresContext, kidNextInFlow);
|
1999-04-28 02:05:02 +04: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 09:03:41 +03:00
|
|
|
SetOverflowFrames(aPresContext, nextInFlow);
|
1999-04-28 02:05:02 +04:00
|
|
|
}
|
1999-04-29 04:16:44 +04:00
|
|
|
else {
|
2003-06-27 22:13:48 +04:00
|
|
|
nsIFrame* nextSib = kid->GetNextSibling();
|
1999-04-29 04:16:44 +04:00
|
|
|
if (nextSib) {
|
|
|
|
kid->SetNextSibling(nsnull);
|
1999-11-24 09:03:41 +03:00
|
|
|
SetOverflowFrames(aPresContext, nextSib);
|
1999-04-29 04:16:44 +04:00
|
|
|
}
|
|
|
|
}
|
1999-04-28 02:05:02 +04:00
|
|
|
}
|
|
|
|
|
2002-05-29 02:50:43 +04:00
|
|
|
NS_FRAME_SET_TRUNCATION(aReflowStatus, aReflowState, aMetrics);
|
1999-04-28 02:05:02 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2000-07-29 02:29:28 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFirstLetterFrame::CanContinueTextRun(PRBool& aContinueTextRun) const
|
|
|
|
{
|
|
|
|
// We can continue a text run through a first-letter frame.
|
|
|
|
aContinueTextRun = PR_TRUE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-04-28 02:05:02 +04:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsFirstLetterFrame::DrainOverflowFrames(nsPresContext* aPresContext)
|
1999-04-28 02:05:02 +04:00
|
|
|
{
|
1999-10-21 09:11:43 +04:00
|
|
|
nsIFrame* overflowFrames;
|
|
|
|
|
1999-04-28 02:05:02 +04:00
|
|
|
// Check for an overflow list with our prev-in-flow
|
|
|
|
nsFirstLetterFrame* prevInFlow = (nsFirstLetterFrame*)mPrevInFlow;
|
|
|
|
if (nsnull != prevInFlow) {
|
1999-10-21 09:11:43 +04:00
|
|
|
overflowFrames = prevInFlow->GetOverflowFrames(aPresContext, PR_TRUE);
|
|
|
|
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.
|
1999-10-21 09:11:43 +04:00
|
|
|
nsIFrame* f = overflowFrames;
|
1999-04-28 02:05:02 +04:00
|
|
|
while (f) {
|
1999-10-26 08:44:41 +04:00
|
|
|
nsHTMLContainerFrame::ReparentFrameView(aPresContext, f, prevInFlow, this);
|
2003-06-27 22:13:48 +04:00
|
|
|
f = f->GetNextSibling();
|
1999-04-28 02:05:02 +04:00
|
|
|
}
|
1999-10-21 09:11:43 +04:00
|
|
|
mFrames.InsertFrames(this, nsnull, overflowFrames);
|
1999-04-28 02:05:02 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// It's also possible that we have an overflow list for ourselves
|
1999-10-21 09:11:43 +04:00
|
|
|
overflowFrames = GetOverflowFrames(aPresContext, PR_TRUE);
|
|
|
|
if (overflowFrames) {
|
1999-04-28 02:05:02 +04:00
|
|
|
NS_ASSERTION(mFrames.NotEmpty(), "overflow list w/o frames");
|
1999-10-21 09:11:43 +04:00
|
|
|
mFrames.AppendFrames(nsnull, overflowFrames);
|
1999-04-28 02:05:02 +04:00
|
|
|
}
|
|
|
|
|
1999-10-29 18:34:01 +04: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-28 02:05:02 +04:00
|
|
|
nsIFrame* kid = mFrames.FirstChild();
|
1999-04-29 04:16:44 +04:00
|
|
|
if (kid) {
|
2003-02-22 03:32:13 +03:00
|
|
|
nsRefPtr<nsStyleContext> sc;
|
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->IsContentOfType(nsIContent::eTEXT),
|
|
|
|
"should contain only text nodes");
|
2004-01-28 03:18:22 +03:00
|
|
|
sc = aPresContext->StyleSet()->ResolveStyleForNonElement(mStyleContext);
|
1999-10-29 18:34:01 +04:00
|
|
|
if (sc) {
|
|
|
|
kid->SetStyleContext(aPresContext, sc);
|
|
|
|
}
|
|
|
|
}
|
1999-04-29 04:16:44 +04:00
|
|
|
}
|
1999-04-28 02:05:02 +04:00
|
|
|
}
|