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
|
1998-09-15 04:19:49 +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/
|
1998-09-15 04:19:49 +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.
|
1998-09-15 04:19:49 +04:00
|
|
|
*
|
1999-02-01 20:27:56 +03: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 ***** */
|
2006-03-29 22:29:03 +04:00
|
|
|
|
|
|
|
/* rendering object for CSS display:inline objects */
|
|
|
|
|
1999-11-01 18:24:57 +03:00
|
|
|
#include "nsCOMPtr.h"
|
1999-04-20 04:25:12 +04:00
|
|
|
#include "nsInlineFrame.h"
|
2002-09-25 02:13:20 +04:00
|
|
|
#include "nsBlockFrame.h"
|
2007-01-30 03:06:41 +03:00
|
|
|
#include "nsGkAtoms.h"
|
1999-02-01 20:27:56 +03:00
|
|
|
#include "nsHTMLParts.h"
|
2003-02-22 03:32:13 +03:00
|
|
|
#include "nsStyleContext.h"
|
1999-02-01 20:27:56 +03:00
|
|
|
#include "nsIPresShell.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
1999-03-19 00:03:25 +03:00
|
|
|
#include "nsIRenderingContext.h"
|
|
|
|
#include "nsIFontMetrics.h"
|
1999-04-19 23:10:15 +04:00
|
|
|
#include "nsAbsoluteContainingBlock.h"
|
2002-11-17 18:37:56 +03:00
|
|
|
#include "nsCSSAnonBoxes.h"
|
2003-02-22 03:32:13 +03:00
|
|
|
#include "nsAutoPtr.h"
|
2004-02-24 00:29:06 +03:00
|
|
|
#include "nsFrameManager.h"
|
2002-08-10 11:59:44 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsIAccessibilityService.h"
|
|
|
|
#endif
|
2006-04-27 06:45:03 +04:00
|
|
|
#include "nsDisplayList.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
|
|
|
|
2000-03-23 02:19:10 +03:00
|
|
|
|
2003-02-26 04:16:40 +03:00
|
|
|
NS_DEFINE_IID(kInlineFrameCID, NS_INLINE_FRAME_CID);
|
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
|
|
|
|
2005-11-04 05:38:33 +03:00
|
|
|
nsIFrame*
|
2006-03-27 01:30:36 +04:00
|
|
|
NS_NewInlineFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
1998-09-15 04:19:49 +04:00
|
|
|
{
|
2006-03-27 01:30:36 +04:00
|
|
|
return new (aPresShell) nsInlineFrame(aContext);
|
1998-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-02-01 20:27:56 +03:00
|
|
|
nsInlineFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
1998-09-15 04:19:49 +04:00
|
|
|
{
|
2007-03-23 02:01:14 +03:00
|
|
|
if (nsnull == aInstancePtr) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1999-02-01 20:27:56 +03:00
|
|
|
if (aIID.Equals(kInlineFrameCID)) {
|
2007-03-23 02:01:14 +03:00
|
|
|
nsInlineFrame* tmp = this;
|
|
|
|
*aInstancePtr = (void*) tmp;
|
1999-02-01 20:27:56 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return nsInlineFrameSuper::QueryInterface(aIID, aInstancePtr);
|
|
|
|
}
|
1998-09-15 04:19:49 +04:00
|
|
|
|
2007-03-23 02:01:14 +03:00
|
|
|
void
|
|
|
|
nsInlineFrame::Destroy()
|
|
|
|
{
|
|
|
|
if (mState & NS_FRAME_GENERATED_CONTENT) {
|
|
|
|
// Make sure all the content nodes for the generated content inside
|
|
|
|
// this frame know it's going away.
|
|
|
|
// This is duplicated in nsBlockFrame::Destroy.
|
|
|
|
// See also nsCSSFrameConstructor::CreateGeneratedContentFrame which
|
|
|
|
// created this frame.
|
|
|
|
|
|
|
|
// XXXbz would this be better done via a global structure in
|
|
|
|
// nsCSSFrameConstructor that could key off of
|
|
|
|
// GeneratedContentFrameRemoved or something? The problem is that
|
|
|
|
// our kids are gone by the time that's called.
|
|
|
|
nsContainerFrame::CleanupGeneratedContentIn(mContent, this);
|
|
|
|
}
|
|
|
|
nsInlineFrameSuper::Destroy();
|
|
|
|
}
|
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef DEBUG
|
1999-02-01 20:27:56 +03:00
|
|
|
NS_IMETHODIMP
|
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-09-15 04:19:49 +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-09-15 04:19:49 +04:00
|
|
|
}
|
|
|
|
|
2007-03-23 02:01:14 +03:00
|
|
|
inline PRBool
|
|
|
|
IsPaddingZero(nsStyleUnit aUnit, nsStyleCoord &aCoord)
|
2001-10-25 05:08:40 +04:00
|
|
|
{
|
2007-03-23 02:01:14 +03:00
|
|
|
return (aUnit == eStyleUnit_Null ||
|
|
|
|
(aUnit == eStyleUnit_Coord && aCoord.GetCoordValue() == 0) ||
|
2001-10-25 05:08:40 +04:00
|
|
|
(aUnit == eStyleUnit_Percent && aCoord.GetPercentValue() == 0.0));
|
|
|
|
}
|
|
|
|
|
2007-03-23 02:01:14 +03:00
|
|
|
inline PRBool
|
|
|
|
IsMarginZero(nsStyleUnit aUnit, nsStyleCoord &aCoord)
|
2001-10-25 05:08:40 +04:00
|
|
|
{
|
2007-03-23 02:01:14 +03:00
|
|
|
return (aUnit == eStyleUnit_Null ||
|
|
|
|
aUnit == eStyleUnit_Auto ||
|
2001-10-25 05:08:40 +04:00
|
|
|
(aUnit == eStyleUnit_Coord && aCoord.GetCoordValue() == 0) ||
|
|
|
|
(aUnit == eStyleUnit_Percent && aCoord.GetPercentValue() == 0.0));
|
|
|
|
}
|
|
|
|
|
2003-11-11 02:36:06 +03:00
|
|
|
/* virtual */ PRBool
|
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) {
|
2003-11-11 02:36:06 +03:00
|
|
|
return PR_FALSE;
|
2001-10-25 05:08:40 +04:00
|
|
|
}
|
2002-11-28 22:29:28 +03:00
|
|
|
#endif
|
2003-05-15 07:42:21 +04:00
|
|
|
const nsStyleMargin* margin = GetStyleMargin();
|
|
|
|
const nsStyleBorder* border = GetStyleBorder();
|
|
|
|
const nsStylePadding* padding = GetStylePadding();
|
2007-03-23 02:01:14 +03:00
|
|
|
nsStyleCoord coord;
|
2002-11-28 22:29:28 +03:00
|
|
|
// XXX Top and bottom removed, since they shouldn't affect things, but this
|
|
|
|
// doesn't really match with nsLineLayout.cpp's setting of
|
|
|
|
// ZeroEffectiveSpanBox, anymore, so what should this really be?
|
2005-04-29 19:44:38 +04:00
|
|
|
if (border->GetBorderWidth(NS_SIDE_RIGHT) != 0 ||
|
|
|
|
border->GetBorderWidth(NS_SIDE_LEFT) != 0 ||
|
2001-10-25 05:08:40 +04:00
|
|
|
!IsPaddingZero(padding->mPadding.GetRightUnit(),
|
2007-03-23 02:01:14 +03:00
|
|
|
padding->mPadding.GetRight(coord)) ||
|
2001-10-25 05:08:40 +04:00
|
|
|
!IsPaddingZero(padding->mPadding.GetLeftUnit(),
|
2007-03-23 02:01:14 +03:00
|
|
|
padding->mPadding.GetLeft(coord)) ||
|
2001-10-25 05:08:40 +04:00
|
|
|
!IsMarginZero(margin->mMargin.GetRightUnit(),
|
2007-03-23 02:01:14 +03:00
|
|
|
margin->mMargin.GetRight(coord)) ||
|
2001-10-25 05:08:40 +04:00
|
|
|
!IsMarginZero(margin->mMargin.GetLeftUnit(),
|
2007-03-23 02:01:14 +03:00
|
|
|
margin->mMargin.GetLeft(coord))) {
|
2003-11-11 02:36:06 +03:00
|
|
|
return PR_FALSE;
|
2001-10-25 05:08:40 +04:00
|
|
|
}
|
2004-11-15 08:01:11 +03:00
|
|
|
return PR_TRUE;
|
2004-11-14 23:22:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsInlineFrame::IsEmpty()
|
|
|
|
{
|
2004-11-15 08:01:11 +03:00
|
|
|
if (!IsSelfEmpty()) {
|
2004-11-14 23:22:58 +03:00
|
|
|
return PR_FALSE;
|
|
|
|
}
|
2001-10-25 05:08:40 +04:00
|
|
|
|
2003-06-30 14:46:59 +04:00
|
|
|
for (nsIFrame *kid = mFrames.FirstChild(); kid; kid = kid->GetNextSibling()) {
|
2003-11-11 02:36:06 +03:00
|
|
|
if (!kid->IsEmpty())
|
|
|
|
return PR_FALSE;
|
2001-10-25 05:08:40 +04:00
|
|
|
}
|
2004-11-14 23:22:58 +03:00
|
|
|
|
2003-11-11 02:36:06 +03:00
|
|
|
return PR_TRUE;
|
2001-10-25 05:08:40 +04:00
|
|
|
}
|
|
|
|
|
2006-09-12 00:43:01 +04:00
|
|
|
PRBool
|
|
|
|
nsInlineFrame::PeekOffsetCharacter(PRBool aForward, PRInt32* aOffset)
|
|
|
|
{
|
|
|
|
// Override the implementation in nsFrame, to skip empty inline frames
|
|
|
|
NS_ASSERTION (aOffset && *aOffset <= 1, "aOffset out of range");
|
|
|
|
PRInt32 startOffset = *aOffset;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
2002-12-11 07:00:18 +03:00
|
|
|
NS_IMETHODIMP
|
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
|
|
|
{
|
2006-01-26 05:29:17 +03:00
|
|
|
nsresult rv = nsHTMLContainerFrame::BuildDisplayList(aBuilder, aDirtyRect, aLists);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
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()) {
|
2006-01-26 05:29:17 +03:00
|
|
|
rv = DisplaySelectionOverlay(aBuilder, aLists);
|
2002-12-11 07:00:18 +03:00
|
|
|
}
|
2006-01-26 05:29:17 +03:00
|
|
|
return rv;
|
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
|
|
|
|
nsInlineFrame::AddInlineMinWidth(nsIRenderingContext *aRenderingContext,
|
|
|
|
nsIFrame::InlineMinWidthData *aData)
|
|
|
|
{
|
|
|
|
DoInlineIntrinsicWidth(aRenderingContext, aData, nsLayoutUtils::MIN_WIDTH);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ void
|
|
|
|
nsInlineFrame::AddInlinePrefWidth(nsIRenderingContext *aRenderingContext,
|
|
|
|
nsIFrame::InlinePrefWidthData *aData)
|
|
|
|
{
|
|
|
|
DoInlineIntrinsicWidth(aRenderingContext, aData, nsLayoutUtils::PREF_WIDTH);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nsSize
|
|
|
|
nsInlineFrame::ComputeSize(nsIRenderingContext *aRenderingContext,
|
|
|
|
nsSize aCBSize, nscoord aAvailableWidth,
|
|
|
|
nsSize aMargin, nsSize aBorder, nsSize aPadding,
|
|
|
|
PRBool aShrinkWrap)
|
|
|
|
{
|
|
|
|
// Inlines and text don't compute size before reflow.
|
|
|
|
return nsSize(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
|
|
|
|
}
|
|
|
|
|
2007-04-21 04:42:58 +04:00
|
|
|
void
|
|
|
|
nsInlineFrame::ReparentFloatsForInlineChild(nsIFrame* aOurLineContainer,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
PRBool aReparentSiblings)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aOurLineContainer->GetNextContinuation() ||
|
|
|
|
aOurLineContainer->GetPrevContinuation(),
|
|
|
|
"Don't call this when we have no continuation, it's a waste");
|
|
|
|
|
|
|
|
nsIFrame* ancestor = aFrame;
|
|
|
|
nsIFrame* ancestorBlockChild;
|
|
|
|
do {
|
|
|
|
ancestorBlockChild = ancestor;
|
|
|
|
ancestor = ancestor->GetParent();
|
|
|
|
if (!ancestor)
|
|
|
|
return;
|
|
|
|
} while (!ancestor->IsFloatContainingBlock());
|
|
|
|
|
|
|
|
if (ancestor == aOurLineContainer)
|
|
|
|
return;
|
|
|
|
|
|
|
|
nsBlockFrame* ourBlock;
|
|
|
|
nsresult rv = aOurLineContainer->QueryInterface(kBlockFrameCID, (void**)&ourBlock);
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "Not a block, but broke vertically?");
|
|
|
|
nsBlockFrame* frameBlock;
|
|
|
|
rv = ancestor->QueryInterface(kBlockFrameCID, (void**)&frameBlock);
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "ancestor not a block");
|
|
|
|
|
|
|
|
nsFrameList blockChildren(ancestor->GetFirstChild(nsnull));
|
|
|
|
PRBool isOverflow = !blockChildren.ContainsFrame(ancestorBlockChild);
|
|
|
|
|
|
|
|
while (PR_TRUE) {
|
|
|
|
ourBlock->ReparentFloats(aFrame, frameBlock, isOverflow, PR_FALSE);
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-10-27 19:52:10 +03:00
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsInlineFrame::Reflow(nsPresContext* aPresContext,
|
1999-02-01 20:27:56 +03:00
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsInlineFrame");
|
2001-11-14 16:40:03 +03:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aMetrics, aStatus);
|
1999-07-20 07:51:46 +04:00
|
|
|
if (nsnull == aReflowState.mLineLayout) {
|
1999-03-19 00:03:25 +03:00
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
2000-03-12 06:14:11 +03:00
|
|
|
|
|
|
|
PRBool lazilySetParentPointer = PR_FALSE;
|
|
|
|
|
2007-04-21 04:42:58 +04:00
|
|
|
nsIFrame* lineContainer = aReflowState.mLineLayout->GetLineContainerFrame();
|
|
|
|
|
|
|
|
// Check for an overflow list with our prev-in-flow
|
2006-02-22 00:33:47 +03:00
|
|
|
nsInlineFrame* prevInFlow = (nsInlineFrame*)GetPrevInFlow();
|
2000-03-12 06:14:11 +03:00
|
|
|
if (nsnull != prevInFlow) {
|
|
|
|
nsIFrame* prevOverflowFrames = prevInFlow->GetOverflowFrames(aPresContext, PR_TRUE);
|
|
|
|
|
|
|
|
if (prevOverflowFrames) {
|
|
|
|
// When pushing and pulling frames we need to check for whether any
|
|
|
|
// views need to be reparented.
|
|
|
|
nsHTMLContainerFrame::ReparentFrameViewList(aPresContext, prevOverflowFrames,
|
|
|
|
prevInFlow, this);
|
|
|
|
|
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-12 06:14:11 +03:00
|
|
|
// If it's the initial reflow, then our child list must be empty, so
|
|
|
|
// just set the child list rather than calling InsertFrame(). This avoids
|
|
|
|
// having to get the last child frame in the list.
|
|
|
|
// 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)
|
|
|
|
NS_ASSERTION(mFrames.IsEmpty(), "child list is not empty for initial reflow");
|
|
|
|
mFrames.SetFrames(prevOverflowFrames);
|
|
|
|
lazilySetParentPointer = PR_TRUE;
|
|
|
|
} else {
|
2007-04-21 04:42:58 +04:00
|
|
|
// Assign all floats to our block if necessary
|
|
|
|
if (lineContainer && lineContainer->GetPrevContinuation()) {
|
|
|
|
ReparentFloatsForInlineChild(lineContainer, prevOverflowFrames, PR_TRUE);
|
|
|
|
}
|
2000-03-12 06:14:11 +03:00
|
|
|
// Insert the new frames at the beginning of the child list
|
|
|
|
// and set their parent pointer
|
|
|
|
mFrames.InsertFrames(this, nsnull, prevOverflowFrames);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
|
|
|
nsIFrame* overflowFrames = GetOverflowFrames(aPresContext, PR_FALSE);
|
|
|
|
NS_ASSERTION(!overflowFrames, "overflow list is not empty for initial reflow");
|
|
|
|
}
|
|
|
|
#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)) {
|
2000-03-12 06:14:11 +03:00
|
|
|
nsIFrame* overflowFrames = GetOverflowFrames(aPresContext, PR_TRUE);
|
|
|
|
if (overflowFrames) {
|
|
|
|
NS_ASSERTION(mFrames.NotEmpty(), "overflow list w/o frames");
|
2000-03-22 07:06:37 +03:00
|
|
|
|
|
|
|
// Because we lazily set the parent pointer of child frames we get from
|
|
|
|
// our prev-in-flow's overflow list, it's possible that we have not set
|
2006-12-21 22:59:30 +03:00
|
|
|
// the parent pointer for these frames.
|
|
|
|
mFrames.AppendFrames(this, overflowFrames);
|
2000-03-12 06:14:11 +03:00
|
|
|
}
|
|
|
|
}
|
1999-02-01 20:27:56 +03:00
|
|
|
|
1999-08-31 07:09:40 +04:00
|
|
|
if (IsFrameTreeTooDeep(aReflowState, aMetrics)) {
|
|
|
|
#ifdef DEBUG_kipp
|
|
|
|
{
|
|
|
|
extern char* nsPresShell_ReflowStackPointerTop;
|
|
|
|
char marker;
|
|
|
|
char* newsp = (char*) ▮
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("XXX: frame tree is too deep; approx stack size = %d\n",
|
1999-08-31 07:09:40 +04:00
|
|
|
nsPresShell_ReflowStackPointerTop - newsp);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-03-05 07:25:57 +03:00
|
|
|
// Set our own reflow state (additional state above and beyond
|
|
|
|
// aReflowState)
|
|
|
|
InlineReflowState irs;
|
|
|
|
irs.mPrevFrame = nsnull;
|
2007-04-21 04:42:58 +04:00
|
|
|
irs.mLineContainer = lineContainer;
|
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
|
|
|
|
|
|
|
nsresult rv;
|
|
|
|
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.
|
1999-11-01 18:24:57 +03:00
|
|
|
PRBool complete;
|
1999-11-24 09:03:41 +03:00
|
|
|
(void) PullOneFrame(aPresContext, irs, &complete);
|
1999-02-01 20:27:56 +03:00
|
|
|
}
|
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
rv = ReflowFrames(aPresContext, aReflowState, irs, aMetrics, aStatus);
|
2000-03-22 07:06:37 +03:00
|
|
|
|
1999-11-01 18:24:57 +03:00
|
|
|
// Note: the line layout code will properly compute our
|
|
|
|
// NS_FRAME_OUTSIDE_CHILDREN state for us.
|
1999-02-01 20:27:56 +03:00
|
|
|
|
2002-05-29 02:50:43 +04:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aMetrics);
|
1999-02-01 20:27:56 +03: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 08:38:33 +03:00
|
|
|
/* virtual */ PRBool
|
|
|
|
nsInlineFrame::CanContinueTextRun() const
|
2000-07-29 02:29:28 +04:00
|
|
|
{
|
|
|
|
// We can continue a text run through an inline 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 08:38:33 +03:00
|
|
|
return PR_TRUE;
|
2000-01-13 00:52:58 +03:00
|
|
|
}
|
|
|
|
|
1999-02-01 20:27:56 +03:00
|
|
|
nsresult
|
2004-08-01 03:15:21 +04:00
|
|
|
nsInlineFrame::ReflowFrames(nsPresContext* aPresContext,
|
1999-11-01 18:24:57 +03:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
InlineReflowState& irs,
|
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-10-27 19:52:10 +03:00
|
|
|
{
|
1999-02-01 20:27:56 +03:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
|
1999-07-20 07:51:46 +04:00
|
|
|
nsLineLayout* lineLayout = aReflowState.mLineLayout;
|
2006-06-15 12:16:23 +04:00
|
|
|
PRBool ltr = (NS_STYLE_DIRECTION_LTR == aReflowState.mStyleVisibility->mDirection);
|
1999-03-19 00:03:25 +03:00
|
|
|
nscoord leftEdge = 0;
|
2006-02-22 00:33:47 +03:00
|
|
|
if (nsnull == GetPrevContinuation()) {
|
2006-06-15 12:16:23 +04:00
|
|
|
leftEdge = ltr ? aReflowState.mComputedBorderPadding.left
|
|
|
|
: aReflowState.mComputedBorderPadding.right;
|
1999-03-19 00:03:25 +03:00
|
|
|
}
|
1999-03-05 07:25:57 +03:00
|
|
|
nscoord availableWidth = aReflowState.availableWidth;
|
2007-03-23 02:01:14 +03:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != availableWidth) {
|
|
|
|
// Subtract off left and right border+padding from availableWidth
|
|
|
|
availableWidth -= leftEdge;
|
|
|
|
availableWidth -= ltr ? aReflowState.mComputedBorderPadding.right
|
|
|
|
: aReflowState.mComputedBorderPadding.left;
|
|
|
|
availableWidth = PR_MAX(0, availableWidth);
|
|
|
|
}
|
1999-11-01 18:24:57 +03:00
|
|
|
lineLayout->BeginSpan(this, &aReflowState, leftEdge, leftEdge + availableWidth);
|
1999-02-01 20:27:56 +03:00
|
|
|
|
|
|
|
// First reflow our current children
|
|
|
|
nsIFrame* frame = mFrames.FirstChild();
|
|
|
|
PRBool done = PR_FALSE;
|
|
|
|
while (nsnull != frame) {
|
1999-04-28 02:12:37 +04:00
|
|
|
PRBool reflowingFirstLetter = lineLayout->GetFirstLetterStyleOK();
|
2000-03-12 06:14:11 +03:00
|
|
|
|
|
|
|
// Check if we should lazily set the child frame's parent pointer
|
|
|
|
if (irs.mSetParentPointer) {
|
2007-04-21 04:42:58 +04:00
|
|
|
PRBool havePrevBlock =
|
|
|
|
irs.mLineContainer && irs.mLineContainer->GetPrevContinuation();
|
|
|
|
// If our block is the first in flow, then any floats under the pulled
|
|
|
|
// frame must already belong to our block.
|
|
|
|
if (havePrevBlock) {
|
|
|
|
// 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, frame, PR_FALSE);
|
|
|
|
}
|
2000-03-12 06:14:11 +03:00
|
|
|
frame->SetParent(this);
|
2005-11-21 01:05:24 +03:00
|
|
|
// We also need to check if frame has a next-in-flow. If it does, then set
|
2000-03-22 07:06:37 +03:00
|
|
|
// its parent frame pointer, too. Otherwise, if we reflow frame and it's
|
|
|
|
// complete we'll fail when deleting its next-in-flow which is no longer
|
|
|
|
// needed. This scenario doesn't happen often, but it can happen
|
2004-09-14 06:28:03 +04:00
|
|
|
nsIFrame* nextInFlow = frame->GetNextInFlow();
|
2000-03-22 07:06:37 +03:00
|
|
|
while (nextInFlow) {
|
|
|
|
// Since we only do lazy setting of parent pointers for the frame's
|
|
|
|
// initial reflow, this frame can't have a next-in-flow. That means
|
|
|
|
// the continuing child frame must be in our child list as well. If
|
|
|
|
// not, then something is wrong
|
|
|
|
NS_ASSERTION(mFrames.ContainsFrame(nextInFlow), "unexpected flow");
|
2007-04-21 04:42:58 +04:00
|
|
|
if (havePrevBlock) {
|
|
|
|
ReparentFloatsForInlineChild(irs.mLineContainer, nextInFlow, PR_FALSE);
|
|
|
|
}
|
2000-03-22 07:06:37 +03:00
|
|
|
nextInFlow->SetParent(this);
|
2004-09-14 06:28:03 +04:00
|
|
|
nextInFlow = nextInFlow->GetNextInFlow();
|
2000-03-22 07:06:37 +03:00
|
|
|
}
|
2000-03-12 06:14:11 +03:00
|
|
|
}
|
1999-03-05 07:25:57 +03:00
|
|
|
rv = ReflowInlineFrame(aPresContext, aReflowState, irs, frame, aStatus);
|
1999-04-28 02:12:37 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
1999-02-01 20:27:56 +03:00
|
|
|
done = PR_TRUE;
|
|
|
|
break;
|
|
|
|
}
|
2002-07-15 18:46:01 +04:00
|
|
|
if (NS_INLINE_IS_BREAK(aStatus) ||
|
|
|
|
(!reflowingFirstLetter && NS_FRAME_IS_NOT_COMPLETE(aStatus))) {
|
|
|
|
done = PR_TRUE;
|
|
|
|
break;
|
1999-04-28 02:12:37 +04:00
|
|
|
}
|
1999-03-05 07:25:57 +03:00
|
|
|
irs.mPrevFrame = frame;
|
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
|
2006-02-22 00:33:47 +03:00
|
|
|
if (!done && (nsnull != GetNextInFlow())) {
|
1999-02-01 20:27:56 +03:00
|
|
|
while (!done) {
|
1999-04-28 02:12:37 +04:00
|
|
|
PRBool reflowingFirstLetter = lineLayout->GetFirstLetterStyleOK();
|
1999-02-01 20:27:56 +03:00
|
|
|
PRBool 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
|
1999-02-01 20:27:56 +03:00
|
|
|
if (nsnull == frame) {
|
|
|
|
if (!isComplete) {
|
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
1998-12-05 19:04:46 +03:00
|
|
|
}
|
1999-02-01 20:27:56 +03:00
|
|
|
break;
|
|
|
|
}
|
1999-03-05 07:25:57 +03:00
|
|
|
rv = ReflowInlineFrame(aPresContext, aReflowState, irs, frame, aStatus);
|
1999-04-28 02:12:37 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
1999-02-01 20:27:56 +03:00
|
|
|
done = PR_TRUE;
|
|
|
|
break;
|
1998-10-27 19:52:10 +03:00
|
|
|
}
|
2002-07-15 18:46:01 +04:00
|
|
|
if (NS_INLINE_IS_BREAK(aStatus) ||
|
|
|
|
(!reflowingFirstLetter && NS_FRAME_IS_NOT_COMPLETE(aStatus))) {
|
|
|
|
done = PR_TRUE;
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
1999-03-19 00:03:25 +03:00
|
|
|
#ifdef DEBUG
|
2002-07-15 18:46:01 +04:00
|
|
|
if (NS_FRAME_IS_COMPLETE(aStatus)) {
|
1999-03-19 00:03:25 +03:00
|
|
|
// We can't be complete AND have overflow frames!
|
1999-10-21 09:11:43 +04:00
|
|
|
nsIFrame* overflowFrames = GetOverflowFrames(aPresContext, PR_FALSE);
|
|
|
|
NS_ASSERTION(!overflowFrames, "whoops");
|
1999-03-19 00:03:25 +03:00
|
|
|
}
|
|
|
|
#endif
|
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.
|
2007-03-23 02:01:14 +03:00
|
|
|
nsSize size;
|
|
|
|
lineLayout->EndSpan(this, size);
|
2007-05-05 21:06:04 +04:00
|
|
|
|
|
|
|
// Compute final width
|
|
|
|
aMetrics.width = size.width;
|
|
|
|
if (nsnull == GetPrevContinuation()) {
|
|
|
|
aMetrics.width += ltr ? aReflowState.mComputedBorderPadding.left
|
|
|
|
: aReflowState.mComputedBorderPadding.right;
|
|
|
|
}
|
|
|
|
if (NS_FRAME_IS_COMPLETE(aStatus) && (!GetNextContinuation() || GetNextInFlow())) {
|
|
|
|
aMetrics.width += ltr ? aReflowState.mComputedBorderPadding.right
|
|
|
|
: aReflowState.mComputedBorderPadding.left;
|
2007-05-05 21:06:04 +04:00
|
|
|
}
|
|
|
|
|
2007-05-05 21:06:04 +04:00
|
|
|
nsLayoutUtils::SetFontFromStyle(aReflowState.rendContext, mStyleContext);
|
|
|
|
nsCOMPtr<nsIFontMetrics> fm;
|
|
|
|
aReflowState.rendContext->GetFontMetrics(*getter_AddRefs(fm));
|
|
|
|
|
|
|
|
if (fm) {
|
|
|
|
// Compute final height of the frame.
|
|
|
|
//
|
|
|
|
// Do things the standard css2 way -- though it's hard to find it
|
|
|
|
// in the css2 spec! It's actually found in the css1 spec section
|
|
|
|
// 4.4 (you will have to read between the lines to really see
|
|
|
|
// it).
|
|
|
|
//
|
|
|
|
// The height of our box is the sum of our font size plus the top
|
|
|
|
// and bottom border and padding. The height of children do not
|
|
|
|
// affect our height.
|
|
|
|
fm->GetMaxAscent(aMetrics.ascent);
|
|
|
|
fm->GetHeight(aMetrics.height);
|
|
|
|
} else {
|
|
|
|
NS_WARNING("Cannot get font metrics - defaulting sizes to 0");
|
|
|
|
aMetrics.ascent = aMetrics.height = 0;
|
1999-02-01 20:27:56 +03:00
|
|
|
}
|
2007-05-05 21:06:04 +04:00
|
|
|
aMetrics.ascent += aReflowState.mComputedBorderPadding.top;
|
|
|
|
aMetrics.height += aReflowState.mComputedBorderPadding.top +
|
|
|
|
aReflowState.mComputedBorderPadding.bottom;
|
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
|
2007-03-23 02:01:14 +03:00
|
|
|
// computed during vertical alignment of the line we are on.
|
2004-08-25 17:03:28 +04:00
|
|
|
aMetrics.mOverflowArea.SetRect(0, 0, 0, 0);
|
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",
|
|
|
|
aMetrics.width, aMetrics.height, aMetrics.ascent);
|
1999-03-19 00:03:25 +03:00
|
|
|
#endif
|
1999-02-01 20:27:56 +03:00
|
|
|
|
|
|
|
return rv;
|
1998-10-27 19:52:10 +03:00
|
|
|
}
|
|
|
|
|
1999-02-01 20:27:56 +03:00
|
|
|
nsresult
|
2004-08-01 03:15:21 +04:00
|
|
|
nsInlineFrame::ReflowInlineFrame(nsPresContext* aPresContext,
|
1999-03-05 07:25:57 +03:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
InlineReflowState& irs,
|
1999-02-01 20:27:56 +03:00
|
|
|
nsIFrame* aFrame,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-09-19 08:29:36 +04:00
|
|
|
{
|
1999-07-20 07:51:46 +04:00
|
|
|
nsLineLayout* lineLayout = aReflowState.mLineLayout;
|
1999-04-28 02:12:37 +04:00
|
|
|
PRBool reflowingFirstLetter = lineLayout->GetFirstLetterStyleOK();
|
2000-01-03 07:32:13 +03:00
|
|
|
PRBool pushedFrame;
|
2006-10-19 05:47:47 +04:00
|
|
|
nsresult rv =
|
|
|
|
lineLayout->ReflowFrame(aFrame, aStatus, nsnull, pushedFrame);
|
|
|
|
|
1999-02-01 20:27:56 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
if (NS_INLINE_IS_BREAK(aStatus)) {
|
|
|
|
if (NS_INLINE_IS_BREAK_BEFORE(aStatus)) {
|
|
|
|
if (aFrame != mFrames.FirstChild()) {
|
|
|
|
// Change break-before status into break-after since we have
|
|
|
|
// already placed at least one child frame. This preserves the
|
2001-12-24 02:23:41 +03:00
|
|
|
// break-type so that it can be propagated upward.
|
1999-02-01 20:27:56 +03:00
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE |
|
|
|
|
NS_INLINE_BREAK | NS_INLINE_BREAK_AFTER |
|
|
|
|
(aStatus & NS_INLINE_BREAK_TYPE_MASK);
|
1999-04-20 04:25:12 +04:00
|
|
|
PushFrames(aPresContext, aFrame, irs.mPrevFrame);
|
1999-02-01 20:27:56 +03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Preserve reflow status when breaking-before our first child
|
2001-12-24 02:23:41 +03:00
|
|
|
// and propagate it upward without modification.
|
2000-03-22 07:06:37 +03:00
|
|
|
// Note: if we're lazily setting the frame pointer for our child
|
|
|
|
// frames, then we need to set it now. Don't return and leave the
|
|
|
|
// remaining child frames in our child list with the wrong parent
|
|
|
|
// frame pointer...
|
|
|
|
if (irs.mSetParentPointer) {
|
2007-04-21 04:42:58 +04:00
|
|
|
if (irs.mLineContainer && irs.mLineContainer->GetPrevContinuation()) {
|
|
|
|
ReparentFloatsForInlineChild(irs.mLineContainer, aFrame->GetNextSibling(),
|
|
|
|
PR_TRUE);
|
|
|
|
}
|
2003-06-30 14:46:59 +04:00
|
|
|
for (nsIFrame* f = aFrame->GetNextSibling(); f; f = f->GetNextSibling()) {
|
2000-03-22 07:06:37 +03:00
|
|
|
f->SetParent(this);
|
|
|
|
}
|
|
|
|
}
|
1999-02-01 20:27:56 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Break-after
|
|
|
|
if (NS_FRAME_IS_NOT_COMPLETE(aStatus)) {
|
|
|
|
nsIFrame* newFrame;
|
1999-11-24 09:03:41 +03:00
|
|
|
rv = CreateNextInFlow(aPresContext, this, aFrame, newFrame);
|
1999-02-01 20:27:56 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
}
|
2003-06-30 14:46:59 +04:00
|
|
|
nsIFrame* nextFrame = aFrame->GetNextSibling();
|
|
|
|
if (nextFrame) {
|
2007-03-23 02:01:14 +03:00
|
|
|
aStatus |= NS_FRAME_NOT_COMPLETE;
|
1999-04-20 04:25:12 +04:00
|
|
|
PushFrames(aPresContext, nextFrame, aFrame);
|
1999-02-01 20:27:56 +03:00
|
|
|
}
|
2006-02-22 00:33:47 +03:00
|
|
|
else if (nsnull != GetNextInFlow()) {
|
1999-02-03 22:12:02 +03:00
|
|
|
// We must return an incomplete status if there are more child
|
|
|
|
// frames remaining in a next-in-flow that follows this frame.
|
2006-02-22 00:33:47 +03:00
|
|
|
nsInlineFrame* nextInFlow = (nsInlineFrame*) GetNextInFlow();
|
1999-02-03 22:12:02 +03:00
|
|
|
while (nsnull != nextInFlow) {
|
|
|
|
if (nextInFlow->mFrames.NotEmpty()) {
|
2007-03-23 02:01:14 +03:00
|
|
|
aStatus |= NS_FRAME_NOT_COMPLETE;
|
1999-02-03 22:12:02 +03:00
|
|
|
break;
|
|
|
|
}
|
2006-02-22 00:33:47 +03:00
|
|
|
nextInFlow = (nsInlineFrame*) nextInFlow->GetNextInFlow();
|
1999-02-03 22:12:02 +03:00
|
|
|
}
|
|
|
|
}
|
1999-02-01 20:27:56 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (NS_FRAME_IS_NOT_COMPLETE(aStatus)) {
|
2006-12-26 20:47:52 +03:00
|
|
|
if (nsGkAtoms::placeholderFrame == aFrame->GetType()) {
|
2002-09-25 02:13:20 +04:00
|
|
|
nsBlockReflowState* blockRS = lineLayout->mBlockRS;
|
2005-03-23 06:35:08 +03:00
|
|
|
blockRS->mBlock->SplitPlaceholder(*blockRS, aFrame);
|
2005-03-24 04:15:07 +03:00
|
|
|
// Allow the parent to continue reflowing
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
1999-02-01 20:27:56 +03:00
|
|
|
}
|
2002-09-25 02:13:20 +04:00
|
|
|
else {
|
|
|
|
nsIFrame* newFrame;
|
|
|
|
rv = CreateNextInFlow(aPresContext, this, aFrame, newFrame);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
if (!reflowingFirstLetter) {
|
2003-06-30 14:46:59 +04:00
|
|
|
nsIFrame* nextFrame = aFrame->GetNextSibling();
|
|
|
|
if (nextFrame) {
|
2002-09-25 02:13:20 +04:00
|
|
|
PushFrames(aPresContext, nextFrame, aFrame);
|
|
|
|
}
|
1999-04-28 02:12:37 +04:00
|
|
|
}
|
1999-02-01 20:27:56 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame*
|
2004-08-01 03:15:21 +04:00
|
|
|
nsInlineFrame::PullOneFrame(nsPresContext* aPresContext,
|
1999-11-01 18:24:57 +03:00
|
|
|
InlineReflowState& irs,
|
|
|
|
PRBool* aIsComplete)
|
1999-02-01 20:27:56 +03:00
|
|
|
{
|
|
|
|
PRBool isComplete = PR_TRUE;
|
|
|
|
|
|
|
|
nsIFrame* frame = nsnull;
|
1999-03-05 07:25:57 +03:00
|
|
|
nsInlineFrame* nextInFlow = irs.mNextInFlow;
|
1999-02-01 20:27:56 +03:00
|
|
|
while (nsnull != nextInFlow) {
|
2007-04-21 04:42:58 +04:00
|
|
|
frame = nextInFlow->mFrames.FirstChild();
|
1999-02-01 20:27:56 +03:00
|
|
|
if (nsnull != 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.
|
|
|
|
ReparentFloatsForInlineChild(irs.mLineContainer, frame, PR_FALSE);
|
|
|
|
}
|
|
|
|
nextInFlow->mFrames.RemoveFirstChild();
|
|
|
|
mFrames.InsertFrame(this, irs.mPrevFrame, frame);
|
1999-02-01 20:27:56 +03:00
|
|
|
isComplete = PR_FALSE;
|
1999-10-26 08:44:41 +04:00
|
|
|
nsHTMLContainerFrame::ReparentFrameView(aPresContext, frame, nextInFlow, this);
|
1999-02-01 20:27:56 +03:00
|
|
|
break;
|
|
|
|
}
|
2006-02-22 00:33:47 +03:00
|
|
|
nextInFlow = (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,
|
|
|
|
nsIFrame* aPrevSibling)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aFromChild, "null pointer");
|
|
|
|
NS_PRECONDITION(nsnull != 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
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("%p pushing aFromChild %p, disconnecting from prev sib %p\n",
|
2000-03-23 02:19:10 +03:00
|
|
|
this, aFromChild, aPrevSibling);
|
|
|
|
#endif
|
1999-11-01 18:24:57 +03:00
|
|
|
// Disconnect aFromChild from its previous sibling
|
|
|
|
aPrevSibling->SetNextSibling(nsnull);
|
|
|
|
|
|
|
|
// Add the frames to our overflow list (let our next in flow drain
|
|
|
|
// our overflow list when it is ready)
|
|
|
|
SetOverflowFrames(aPresContext, aFromChild);
|
1999-02-01 20:27:56 +03:00
|
|
|
}
|
|
|
|
|
2000-01-12 11:28:24 +03:00
|
|
|
|
1999-02-01 20:27:56 +03:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
1998-12-19 01:12:42 +03:00
|
|
|
PRIntn
|
|
|
|
nsInlineFrame::GetSkipSides() const
|
|
|
|
{
|
|
|
|
PRIntn skip = 0;
|
2006-06-15 12:16:23 +04:00
|
|
|
if (!IsLeftMost()) {
|
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))) {
|
2006-02-22 00:33:47 +03:00
|
|
|
// Prev continuation is not empty therefore we don't render our left
|
1999-04-20 04:25:12 +04:00
|
|
|
// border edge.
|
|
|
|
skip |= 1 << NS_SIDE_LEFT;
|
|
|
|
}
|
|
|
|
else {
|
2006-02-22 00:33:47 +03:00
|
|
|
// If the prev continuation is empty, then go ahead and let our left
|
1999-04-20 04:25:12 +04:00
|
|
|
// edge border render.
|
|
|
|
}
|
1998-12-19 01:12:42 +03:00
|
|
|
}
|
2006-06-15 12:16:23 +04:00
|
|
|
if (!IsRightMost()) {
|
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))) {
|
2006-02-22 00:33:47 +03:00
|
|
|
// Next continuation is not empty therefore we don't render our right
|
1999-04-20 04:25:12 +04:00
|
|
|
// border edge.
|
|
|
|
skip |= 1 << NS_SIDE_RIGHT;
|
|
|
|
}
|
|
|
|
else {
|
2006-02-22 00:33:47 +03:00
|
|
|
// If the next continuation is empty, then go ahead and let our right
|
1999-04-20 04:25:12 +04:00
|
|
|
// edge border render.
|
|
|
|
}
|
1998-12-19 01:12:42 +03:00
|
|
|
}
|
|
|
|
return skip;
|
|
|
|
}
|
1999-04-20 04:25:12 +04:00
|
|
|
|
2002-08-10 11:59:44 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
NS_IMETHODIMP nsInlineFrame::GetAccessible(nsIAccessible** aAccessible)
|
|
|
|
{
|
|
|
|
// Broken image accessibles are created here, because layout
|
|
|
|
// replaces the image or image control frame with an inline frame
|
|
|
|
*aAccessible = nsnull;
|
2003-11-19 04:20:56 +03:00
|
|
|
nsIAtom *tagAtom = mContent->Tag();
|
2006-12-26 20:47:52 +03:00
|
|
|
if ((tagAtom == nsGkAtoms::img || tagAtom == nsGkAtoms::input ||
|
|
|
|
tagAtom == nsGkAtoms::label) && mContent->IsNodeOfType(nsINode::eHTML)) {
|
2002-08-10 11:59:44 +04:00
|
|
|
// Only get accessibility service if we're going to use it
|
|
|
|
nsCOMPtr<nsIAccessibilityService> accService(do_GetService("@mozilla.org/accessibilityService;1"));
|
|
|
|
if (!accService)
|
|
|
|
return NS_ERROR_FAILURE;
|
2006-12-26 20:47:52 +03:00
|
|
|
if (tagAtom == nsGkAtoms::input) // Broken <input type=image ... />
|
2007-03-23 02:01:14 +03:00
|
|
|
return accService->CreateHTMLButtonAccessible(NS_STATIC_CAST(nsIFrame*, this), aAccessible);
|
2006-12-26 20:47:52 +03:00
|
|
|
else if (tagAtom == nsGkAtoms::img) // Create accessible for broken <img>
|
2007-03-23 02:01:14 +03:00
|
|
|
return accService->CreateHTMLImageAccessible(NS_STATIC_CAST(nsIFrame*, this), aAccessible);
|
2006-12-26 20:47:52 +03:00
|
|
|
else if (tagAtom == nsGkAtoms::label) // Creat accessible for <label>
|
2007-03-23 02:01:14 +03:00
|
|
|
return accService->CreateHTMLLabelAccessible(NS_STATIC_CAST(nsIFrame*, this), aAccessible);
|
2002-08-10 11:59:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1999-04-20 04:25:12 +04:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// nsLineFrame implementation
|
|
|
|
|
|
|
|
static void
|
2004-08-01 03:15:21 +04:00
|
|
|
ReParentChildListStyle(nsPresContext* aPresContext,
|
2006-03-16 04:30:38 +03:00
|
|
|
nsFrameList& aFrameList,
|
|
|
|
nsIFrame* aParentFrame)
|
1999-04-20 04:25:12 +04:00
|
|
|
{
|
2004-02-24 00:29:06 +03:00
|
|
|
nsFrameManager *frameManager = aPresContext->FrameManager();
|
2004-02-01 01:41:40 +03:00
|
|
|
|
2003-06-30 14:46:59 +04:00
|
|
|
for (nsIFrame* kid = aFrameList.FirstChild(); kid;
|
|
|
|
kid = kid->GetNextSibling()) {
|
2006-03-16 04:30:38 +03:00
|
|
|
NS_ASSERTION(kid->GetParent() == aParentFrame, "Bogus parentage");
|
|
|
|
frameManager->ReParentStyleContext(kid);
|
1999-04-20 04:25:12 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-11-04 05:38:33 +03:00
|
|
|
nsIFrame*
|
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
|
|
|
}
|
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef DEBUG
|
1999-04-20 04:25:12 +04:00
|
|
|
NS_IMETHODIMP
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-08-31 07:09:40 +04:00
|
|
|
nsFirstLineFrame::StealFramesFrom(nsIFrame* aFrame)
|
1999-04-20 04:25:12 +04:00
|
|
|
{
|
|
|
|
nsIFrame* prevFrame = mFrames.GetPrevSiblingFor(aFrame);
|
|
|
|
if (prevFrame) {
|
|
|
|
prevFrame->SetNextSibling(nsnull);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mFrames.SetFrames(nsnull);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame*
|
2007-04-21 04:42:58 +04:00
|
|
|
nsFirstLineFrame::PullOneFrame(nsPresContext* aPresContext, InlineReflowState& irs,
|
|
|
|
PRBool* 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?");
|
|
|
|
aPresContext->FrameManager()->ReParentStyleContext(frame);
|
1999-04-20 04:25:12 +04:00
|
|
|
}
|
|
|
|
return frame;
|
|
|
|
}
|
|
|
|
|
2000-03-12 06:14:11 +03:00
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsFirstLineFrame::Reflow(nsPresContext* aPresContext,
|
2000-03-12 06:14:11 +03:00
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1999-04-20 04:25:12 +04:00
|
|
|
{
|
2000-03-12 06:14:11 +03:00
|
|
|
if (nsnull == aReflowState.mLineLayout) {
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
|
2007-04-21 04:42:58 +04:00
|
|
|
nsIFrame* lineContainer = aReflowState.mLineLayout->GetLineContainerFrame();
|
|
|
|
|
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();
|
1999-04-20 04:25:12 +04:00
|
|
|
if (nsnull != prevInFlow) {
|
1999-10-21 09:11:43 +04:00
|
|
|
nsIFrame* prevOverflowFrames = prevInFlow->GetOverflowFrames(aPresContext, PR_TRUE);
|
|
|
|
if (prevOverflowFrames) {
|
|
|
|
nsFrameList frames(prevOverflowFrames);
|
|
|
|
|
2007-04-21 04:42:58 +04:00
|
|
|
// Assign all floats to our block if necessary
|
|
|
|
if (lineContainer && lineContainer->GetPrevContinuation()) {
|
|
|
|
ReparentFloatsForInlineChild(lineContainer, prevOverflowFrames, PR_TRUE);
|
|
|
|
}
|
1999-10-21 09:11:43 +04:00
|
|
|
mFrames.InsertFrames(this, nsnull, prevOverflowFrames);
|
2006-03-16 04:30:38 +03:00
|
|
|
ReParentChildListStyle(aPresContext, frames, this);
|
1999-04-20 04:25:12 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// It's also possible that we have an overflow list for ourselves
|
1999-10-21 09:11:43 +04:00
|
|
|
nsIFrame* overflowFrames = GetOverflowFrames(aPresContext, PR_TRUE);
|
|
|
|
if (overflowFrames) {
|
1999-04-20 04:25:12 +04:00
|
|
|
NS_ASSERTION(mFrames.NotEmpty(), "overflow list w/o frames");
|
1999-10-21 09:11:43 +04:00
|
|
|
nsFrameList frames(overflowFrames);
|
|
|
|
|
|
|
|
mFrames.AppendFrames(nsnull, overflowFrames);
|
2006-03-16 04:30:38 +03:00
|
|
|
ReParentChildListStyle(aPresContext, frames, this);
|
1999-04-20 04:25:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set our own reflow state (additional state above and beyond
|
|
|
|
// aReflowState)
|
|
|
|
InlineReflowState irs;
|
|
|
|
irs.mPrevFrame = nsnull;
|
2007-04-21 04:42:58 +04:00
|
|
|
irs.mLineContainer = lineContainer;
|
2006-02-22 00:33:47 +03:00
|
|
|
irs.mNextInFlow = (nsInlineFrame*) GetNextInFlow();
|
1999-04-20 04:25:12 +04:00
|
|
|
|
|
|
|
nsresult rv;
|
|
|
|
PRBool wasEmpty = mFrames.IsEmpty();
|
|
|
|
if (wasEmpty) {
|
|
|
|
// Try to pull over one frame before starting so that we know
|
|
|
|
// whether we have an anonymous block or not.
|
1999-11-01 18:24:57 +03:00
|
|
|
PRBool complete;
|
1999-11-24 09:03:41 +03:00
|
|
|
PullOneFrame(aPresContext, irs, &complete);
|
1999-04-20 04:25:12 +04:00
|
|
|
}
|
|
|
|
|
2006-02-22 00:33:47 +03:00
|
|
|
if (nsnull == 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 (;;) {
|
|
|
|
PRBool 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
|
|
|
}
|
1999-11-01 18:24:57 +03:00
|
|
|
irs.mPrevFrame = nsnull;
|
1999-04-20 04:25:12 +04:00
|
|
|
}
|
|
|
|
else {
|
1999-04-28 02:12:37 +04:00
|
|
|
// XXX do this in the Init method instead
|
1999-11-01 18:24:57 +03:00
|
|
|
// For continuations, we need to check and see if our style
|
|
|
|
// context is right. If its the same as the first-in-flow, then
|
|
|
|
// we need to fix it up (that way :first-line style doesn't leak
|
|
|
|
// into this continuation since we aren't the first line).
|
|
|
|
nsFirstLineFrame* first = (nsFirstLineFrame*) GetFirstInFlow();
|
|
|
|
if (mStyleContext == first->mStyleContext) {
|
|
|
|
// Fixup our style context and our children. First get the
|
|
|
|
// proper parent context.
|
2003-06-30 14:46:59 +04:00
|
|
|
nsStyleContext* parentContext = first->GetParent()->GetStyleContext();
|
1999-11-01 18:24:57 +03:00
|
|
|
if (parentContext) {
|
|
|
|
// 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.
|
2004-01-28 03:18:22 +03:00
|
|
|
nsRefPtr<nsStyleContext> newSC;
|
|
|
|
newSC = aPresContext->StyleSet()->
|
|
|
|
ResolvePseudoStyleFor(nsnull,
|
|
|
|
nsCSSAnonBoxes::mozLineFrame, parentContext);
|
1999-11-01 18:24:57 +03:00
|
|
|
if (newSC) {
|
|
|
|
// Switch to the new style context.
|
2006-03-09 21:55:21 +03:00
|
|
|
SetStyleContext(newSC);
|
1999-11-01 18:24:57 +03:00
|
|
|
|
|
|
|
// Re-resolve all children
|
2006-03-16 04:30:38 +03:00
|
|
|
ReParentChildListStyle(aPresContext, mFrames, this);
|
1999-04-20 04:25:12 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-11-01 18:24:57 +03:00
|
|
|
}
|
|
|
|
|
2007-01-18 04:20:09 +03:00
|
|
|
NS_ASSERTION(!aReflowState.mLineLayout->GetInFirstLine(),
|
|
|
|
"Nested first-line frames? BOGUS");
|
|
|
|
aReflowState.mLineLayout->SetInFirstLine(PR_TRUE);
|
1999-11-24 09:03:41 +03:00
|
|
|
rv = ReflowFrames(aPresContext, aReflowState, irs, aMetrics, aStatus);
|
2007-01-18 04:20:09 +03:00
|
|
|
aReflowState.mLineLayout->SetInFirstLine(PR_FALSE);
|
1999-11-01 18:24:57 +03: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
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
2005-11-04 05:38:33 +03:00
|
|
|
nsIFrame*
|
2006-03-27 01:30:36 +04:00
|
|
|
NS_NewPositionedInlineFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
1999-11-01 18:24:57 +03:00
|
|
|
{
|
2006-03-27 01:30:36 +04:00
|
|
|
return new (aPresShell) nsPositionedInlineFrame(aContext);
|
1999-11-01 18:24:57 +03:00
|
|
|
}
|
|
|
|
|
2006-04-10 04:16:29 +04:00
|
|
|
void
|
|
|
|
nsPositionedInlineFrame::Destroy()
|
1999-11-01 18:24:57 +03:00
|
|
|
{
|
2006-04-10 04:16:29 +04:00
|
|
|
mAbsoluteContainer.DestroyFrames(this);
|
|
|
|
nsInlineFrame::Destroy();
|
1999-11-01 18:24:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2006-04-10 04:16:29 +04:00
|
|
|
nsPositionedInlineFrame::SetInitialChildList(nsIAtom* aListName,
|
1999-11-01 18:24:57 +03:00
|
|
|
nsIFrame* aChildList)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
2007-03-23 02:01:14 +03:00
|
|
|
if (mAbsoluteContainer.GetChildListName() == aListName) {
|
2006-04-10 04:16:29 +04:00
|
|
|
rv = mAbsoluteContainer.SetInitialChildList(this, aListName, aChildList);
|
1999-11-01 18:24:57 +03:00
|
|
|
} else {
|
2006-04-10 04:16:29 +04:00
|
|
|
rv = nsInlineFrame::SetInitialChildList(aListName, aChildList);
|
1999-11-01 18:24:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2005-02-07 04:58:25 +03:00
|
|
|
nsPositionedInlineFrame::AppendFrames(nsIAtom* aListName,
|
1999-11-01 18:24:57 +03:00
|
|
|
nsIFrame* aFrameList)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
2007-03-23 02:01:14 +03:00
|
|
|
if (mAbsoluteContainer.GetChildListName() == aListName) {
|
2005-02-07 04:58:25 +03:00
|
|
|
rv = mAbsoluteContainer.AppendFrames(this, aListName, aFrameList);
|
1999-11-01 18:24:57 +03:00
|
|
|
} else {
|
2005-02-07 04:58:25 +03:00
|
|
|
rv = nsInlineFrame::AppendFrames(aListName, aFrameList);
|
1999-11-01 18:24:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2005-02-07 04:58:25 +03:00
|
|
|
nsPositionedInlineFrame::InsertFrames(nsIAtom* aListName,
|
1999-11-01 18:24:57 +03:00
|
|
|
nsIFrame* aPrevFrame,
|
|
|
|
nsIFrame* aFrameList)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
2007-03-23 02:01:14 +03:00
|
|
|
if (mAbsoluteContainer.GetChildListName() == aListName) {
|
2005-02-07 04:58:25 +03:00
|
|
|
rv = mAbsoluteContainer.InsertFrames(this, aListName, aPrevFrame,
|
|
|
|
aFrameList);
|
1999-11-01 18:24:57 +03:00
|
|
|
} else {
|
2005-02-07 04:58:25 +03:00
|
|
|
rv = nsInlineFrame::InsertFrames(aListName, aPrevFrame, aFrameList);
|
1999-11-01 18:24:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2005-02-07 04:58:25 +03:00
|
|
|
nsPositionedInlineFrame::RemoveFrame(nsIAtom* aListName,
|
1999-11-01 18:24:57 +03:00
|
|
|
nsIFrame* aOldFrame)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
2007-03-23 02:01:14 +03:00
|
|
|
if (mAbsoluteContainer.GetChildListName() == aListName) {
|
2005-02-07 04:58:25 +03:00
|
|
|
rv = mAbsoluteContainer.RemoveFrame(this, aListName, aOldFrame);
|
1999-11-01 18:24:57 +03:00
|
|
|
} else {
|
2005-02-07 04:58:25 +03:00
|
|
|
rv = nsInlineFrame::RemoveFrame(aListName, aOldFrame);
|
1999-11-01 18:24:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPositionedInlineFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
|
|
|
{
|
2006-04-27 06:45:03 +04:00
|
|
|
aBuilder->MarkFramesForDisplayList(this, mAbsoluteContainer.GetFirstChild(), aDirtyRect);
|
|
|
|
return nsHTMLContainerFrame::BuildDisplayList(aBuilder, aDirtyRect, aLists);
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
|
|
|
|
2004-01-09 17:20:53 +03:00
|
|
|
nsIAtom*
|
|
|
|
nsPositionedInlineFrame::GetAdditionalChildListName(PRInt32 aIndex) const
|
1999-11-01 18:24:57 +03:00
|
|
|
{
|
|
|
|
if (0 == aIndex) {
|
2007-03-23 02:01:14 +03:00
|
|
|
return mAbsoluteContainer.GetChildListName();
|
1999-11-01 18:24:57 +03:00
|
|
|
}
|
2004-01-09 17:20:53 +03:00
|
|
|
return nsnull;
|
1999-11-01 18:24:57 +03:00
|
|
|
}
|
|
|
|
|
2004-01-09 17:20:53 +03:00
|
|
|
nsIFrame*
|
|
|
|
nsPositionedInlineFrame::GetFirstChild(nsIAtom* aListName) const
|
1999-11-01 18:24:57 +03:00
|
|
|
{
|
2007-03-23 02:01:14 +03:00
|
|
|
if (mAbsoluteContainer.GetChildListName() == aListName) {
|
2004-01-09 17:20:53 +03:00
|
|
|
nsIFrame* result = nsnull;
|
|
|
|
mAbsoluteContainer.FirstChild(this, aListName, &result);
|
|
|
|
return result;
|
1999-11-01 18:24:57 +03:00
|
|
|
}
|
|
|
|
|
2004-01-09 17:20:53 +03:00
|
|
|
return nsInlineFrame::GetFirstChild(aListName);
|
1999-11-01 18:24:57 +03:00
|
|
|
}
|
|
|
|
|
2003-10-31 23:19:18 +03:00
|
|
|
nsIAtom*
|
|
|
|
nsPositionedInlineFrame::GetType() const
|
1999-11-01 18:24:57 +03:00
|
|
|
{
|
2006-12-26 20:47:52 +03:00
|
|
|
return nsGkAtoms::positionedInlineFrame;
|
1999-11-01 18:24:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsPositionedInlineFrame::Reflow(nsPresContext* aPresContext,
|
1999-11-01 18:24:57 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
2004-11-14 23:22:58 +03:00
|
|
|
// Don't bother optimizing for fast incremental reflow of absolute
|
|
|
|
// children of an inline
|
1999-11-01 18:24:57 +03:00
|
|
|
|
|
|
|
// Let the inline frame do its reflow first
|
|
|
|
rv = nsInlineFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
1999-04-20 04:25:12 +04:00
|
|
|
|
1999-11-01 18:24:57 +03:00
|
|
|
// Let the absolutely positioned container reflow any absolutely positioned
|
|
|
|
// child frames that need to be reflowed
|
2002-06-12 07:21:00 +04:00
|
|
|
// We want to do this under either of two conditions:
|
|
|
|
// 1. If we didn't do the incremental reflow above.
|
|
|
|
// 2. If our size changed.
|
|
|
|
// Even though it's the padding edge that's the containing block, we
|
|
|
|
// can use our rect (the border edge) since if the border style
|
|
|
|
// changed, the reflow would have been targeted at us so we'd satisfy
|
|
|
|
// condition 1.
|
|
|
|
if (NS_SUCCEEDED(rv) &&
|
2004-11-14 23:22:58 +03:00
|
|
|
mAbsoluteContainer.HasAbsoluteFrames()) {
|
2005-07-26 00:15:31 +04:00
|
|
|
// The containing block for the abs pos kids is formed by our padding edge.
|
|
|
|
nsMargin computedBorder =
|
|
|
|
aReflowState.mComputedBorderPadding - aReflowState.mComputedPadding;
|
|
|
|
nscoord containingBlockWidth =
|
|
|
|
aDesiredSize.width - computedBorder.LeftRight();
|
|
|
|
nscoord containingBlockHeight =
|
|
|
|
aDesiredSize.height - computedBorder.TopBottom();
|
1999-11-01 18:24:57 +03:00
|
|
|
|
2004-08-25 17:03:28 +04:00
|
|
|
// Factor the absolutely positioned child bounds into the overflow area
|
|
|
|
// Don't include this frame's bounds, nor its inline descendants' bounds,
|
|
|
|
// and don't store the overflow property.
|
|
|
|
// That will all be done by nsLineLayout::RelativePositionFrames.
|
2007-03-23 02:01:14 +03:00
|
|
|
rv = mAbsoluteContainer.Reflow(this, aPresContext, aReflowState,
|
1999-12-06 18:49:53 +03:00
|
|
|
containingBlockWidth, containingBlockHeight,
|
2007-03-23 02:01:14 +03:00
|
|
|
PR_TRUE, PR_TRUE, // XXX could be optimized
|
2004-08-25 17:03:28 +04:00
|
|
|
&aDesiredSize.mOverflowArea);
|
1999-04-20 04:25:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|