2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
1998-06-18 20:25:41 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* The contents of this file are subject to the Netscape 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/NPL/
|
1998-06-18 20:25:41 +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-06-18 20:25:41 +04:00
|
|
|
*
|
1999-02-01 20:27:56 +03:00
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* 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
|
|
|
|
* either 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"),
|
|
|
|
* 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
|
|
|
|
* use your version of this file under the terms of the NPL, indicate your
|
|
|
|
* 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
|
|
|
|
* the terms of any one of the NPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
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"
|
1999-02-01 20:27:56 +03:00
|
|
|
#include "nsHTMLAtoms.h"
|
|
|
|
#include "nsHTMLParts.h"
|
|
|
|
#include "nsIStyleContext.h"
|
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsIPresContext.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"
|
|
|
|
#include "nsLayoutAtoms.h"
|
2002-11-17 18:37:56 +03:00
|
|
|
#include "nsCSSAnonBoxes.h"
|
2002-06-12 07:21:00 +04:00
|
|
|
#include "nsReflowPath.h"
|
2002-08-10 11:59:44 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsIAccessibilityService.h"
|
|
|
|
#endif
|
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
|
|
|
|
1999-07-14 21:28:45 +04:00
|
|
|
nsIID nsInlineFrame::kInlineFrameCID = NS_INLINE_FRAME_CID;
|
1998-09-23 06:25:26 +04:00
|
|
|
|
2000-03-23 02:19:10 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1999-04-19 23:10:15 +04:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
1999-02-01 20:27:56 +03:00
|
|
|
// Basic nsInlineFrame methods
|
1998-09-23 06:25:26 +04:00
|
|
|
|
1998-09-12 08:46:35 +04:00
|
|
|
nsresult
|
1999-12-05 02:49:50 +03:00
|
|
|
NS_NewInlineFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
|
1998-09-12 08:46:35 +04:00
|
|
|
{
|
1999-05-12 02:03:29 +04:00
|
|
|
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
|
|
|
if (nsnull == aNewFrame) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1999-12-05 02:49:50 +03:00
|
|
|
nsInlineFrame* it = new (aPresShell) nsInlineFrame;
|
1998-12-05 19:04:46 +03:00
|
|
|
if (nsnull == it) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
1998-09-12 08:46:35 +04:00
|
|
|
}
|
1999-05-12 02:03:29 +04:00
|
|
|
*aNewFrame = it;
|
1998-09-29 08:47:59 +04:00
|
|
|
return NS_OK;
|
1998-09-12 08:46:35 +04:00
|
|
|
}
|
|
|
|
|
1998-12-05 19:04:46 +03:00
|
|
|
nsInlineFrame::nsInlineFrame()
|
1998-09-12 08:46:35 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
1998-06-19 03:16:00 +04:00
|
|
|
NS_IMETHODIMP
|
1999-02-01 20:27:56 +03:00
|
|
|
nsInlineFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
1998-06-18 20:25:41 +04:00
|
|
|
{
|
1999-02-01 20:27:56 +03:00
|
|
|
if (nsnull == aInstancePtr) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
if (aIID.Equals(kInlineFrameCID)) {
|
|
|
|
nsInlineFrame* tmp = this;
|
|
|
|
*aInstancePtr = (void*) tmp;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return nsInlineFrameSuper::QueryInterface(aIID, aInstancePtr);
|
|
|
|
}
|
1998-06-28 02:56:09 +04:00
|
|
|
|
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-06-28 02:56:09 +04:00
|
|
|
|
1999-11-01 18:24:57 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsInlineFrame::GetFrameType(nsIAtom** aType) const
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aType, "null OUT parameter pointer");
|
|
|
|
*aType = nsLayoutAtoms::inlineFrame;
|
|
|
|
NS_ADDREF(*aType);
|
|
|
|
return NS_OK;
|
1998-06-18 20:25:41 +04:00
|
|
|
}
|
|
|
|
|
2001-10-25 05:08:40 +04:00
|
|
|
inline PRBool
|
|
|
|
IsBorderZero(nsStyleUnit aUnit, nsStyleCoord &aCoord)
|
|
|
|
{
|
|
|
|
return ((aUnit == eStyleUnit_Coord && aCoord.GetCoordValue() == 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
inline PRBool
|
|
|
|
IsPaddingZero(nsStyleUnit aUnit, nsStyleCoord &aCoord)
|
|
|
|
{
|
|
|
|
return (aUnit == eStyleUnit_Null ||
|
|
|
|
(aUnit == eStyleUnit_Coord && aCoord.GetCoordValue() == 0) ||
|
|
|
|
(aUnit == eStyleUnit_Percent && aCoord.GetPercentValue() == 0.0));
|
|
|
|
}
|
|
|
|
|
|
|
|
inline PRBool
|
|
|
|
IsMarginZero(nsStyleUnit aUnit, nsStyleCoord &aCoord)
|
|
|
|
{
|
|
|
|
return (aUnit == eStyleUnit_Null ||
|
|
|
|
aUnit == eStyleUnit_Auto ||
|
|
|
|
(aUnit == eStyleUnit_Coord && aCoord.GetCoordValue() == 0) ||
|
|
|
|
(aUnit == eStyleUnit_Percent && aCoord.GetPercentValue() == 0.0));
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2002-06-26 01:16:17 +04:00
|
|
|
nsInlineFrame::IsEmpty(nsCompatibility aCompatMode, PRBool aIsPre,
|
|
|
|
PRBool* aResult)
|
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.
|
2002-06-26 01:16:17 +04:00
|
|
|
if (aCompatMode == eCompatibility_FullStandards) {
|
2001-10-25 05:08:40 +04:00
|
|
|
*aResult = PR_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2002-11-28 22:29:28 +03:00
|
|
|
#endif
|
2001-10-25 05:08:40 +04:00
|
|
|
const nsStyleMargin* margin = NS_STATIC_CAST(const nsStyleMargin*,
|
|
|
|
mStyleContext->GetStyleData(eStyleStruct_Margin));
|
|
|
|
const nsStyleBorder* border = NS_STATIC_CAST(const nsStyleBorder*,
|
|
|
|
mStyleContext->GetStyleData(eStyleStruct_Border));
|
|
|
|
const nsStylePadding* padding = NS_STATIC_CAST(const nsStylePadding*,
|
|
|
|
mStyleContext->GetStyleData(eStyleStruct_Padding));
|
|
|
|
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?
|
|
|
|
if ((border->IsBorderSideVisible(NS_SIDE_RIGHT) &&
|
|
|
|
!IsBorderZero(border->mBorder.GetRightUnit(),
|
|
|
|
border->mBorder.GetRight(coord))) ||
|
2001-10-25 05:08:40 +04:00
|
|
|
(border->IsBorderSideVisible(NS_SIDE_LEFT) &&
|
2002-11-28 22:29:28 +03:00
|
|
|
!IsBorderZero(border->mBorder.GetLeftUnit(),
|
|
|
|
border->mBorder.GetLeft(coord))) ||
|
2001-10-25 05:08:40 +04:00
|
|
|
!IsPaddingZero(padding->mPadding.GetRightUnit(),
|
|
|
|
padding->mPadding.GetRight(coord)) ||
|
|
|
|
!IsPaddingZero(padding->mPadding.GetLeftUnit(),
|
|
|
|
padding->mPadding.GetLeft(coord)) ||
|
|
|
|
!IsMarginZero(margin->mMargin.GetRightUnit(),
|
|
|
|
margin->mMargin.GetRight(coord)) ||
|
|
|
|
!IsMarginZero(margin->mMargin.GetLeftUnit(),
|
|
|
|
margin->mMargin.GetLeft(coord))) {
|
|
|
|
*aResult = PR_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aResult = PR_TRUE;
|
|
|
|
for (nsIFrame *kid = mFrames.FirstChild(); kid; kid->GetNextSibling(&kid)) {
|
2002-06-26 01:16:17 +04:00
|
|
|
kid->IsEmpty(aCompatMode, aIsPre, aResult);
|
2001-10-25 05:08:40 +04:00
|
|
|
if (! *aResult)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-10-27 19:52:10 +03:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsInlineFrame::AppendFrames(nsIPresContext* aPresContext,
|
1999-02-01 20:27:56 +03:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aFrameList)
|
1998-10-27 19:52:10 +03:00
|
|
|
{
|
1999-02-01 20:27:56 +03:00
|
|
|
if (nsnull != aListName) {
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
1999-11-01 18:24:57 +03:00
|
|
|
if (aFrameList) {
|
|
|
|
mFrames.AppendFrames(this, aFrameList);
|
1999-02-01 20:27:56 +03:00
|
|
|
|
2000-01-19 06:58:05 +03:00
|
|
|
// Ask the parent frame to reflow me.
|
|
|
|
ReflowDirtyChild(&aPresShell, nsnull);
|
1999-02-01 20:27:56 +03:00
|
|
|
}
|
1999-11-01 18:24:57 +03:00
|
|
|
return NS_OK;
|
1999-02-01 20:27:56 +03:00
|
|
|
}
|
|
|
|
|
1999-11-01 18:24:57 +03:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsInlineFrame::InsertFrames(nsIPresContext* aPresContext,
|
1999-11-01 18:24:57 +03:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aPrevFrame,
|
|
|
|
nsIFrame* aFrameList)
|
1999-02-01 20:27:56 +03:00
|
|
|
{
|
1999-11-01 18:24:57 +03:00
|
|
|
if (nsnull != aListName) {
|
2001-03-09 06:29:00 +03:00
|
|
|
#ifdef IBMBIDI
|
|
|
|
if (aListName != nsLayoutAtoms::nextBidi)
|
|
|
|
#endif
|
1999-11-01 18:24:57 +03:00
|
|
|
return NS_ERROR_INVALID_ARG;
|
1999-02-01 20:27:56 +03:00
|
|
|
}
|
1999-11-01 18:24:57 +03:00
|
|
|
if (aFrameList) {
|
|
|
|
// Insert frames after aPrevFrame
|
|
|
|
mFrames.InsertFrames(this, aPrevFrame, aFrameList);
|
1999-02-01 20:27:56 +03:00
|
|
|
|
2001-03-09 06:29:00 +03:00
|
|
|
#ifdef IBMBIDI
|
|
|
|
if (nsnull == aListName)
|
|
|
|
#endif
|
2000-01-19 06:58:05 +03:00
|
|
|
// Ask the parent frame to reflow me.
|
|
|
|
ReflowDirtyChild(&aPresShell, nsnull);
|
1999-02-01 20:27:56 +03:00
|
|
|
}
|
1999-11-01 18:24:57 +03:00
|
|
|
return NS_OK;
|
1999-02-01 20:27:56 +03:00
|
|
|
}
|
1998-10-27 19:52:10 +03:00
|
|
|
|
1999-02-01 20:27:56 +03:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsInlineFrame::RemoveFrame(nsIPresContext* aPresContext,
|
1999-02-01 20:27:56 +03:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aOldFrame)
|
|
|
|
{
|
|
|
|
if (nsnull != aListName) {
|
2001-03-09 06:29:00 +03:00
|
|
|
#ifdef IBMBIDI
|
|
|
|
if (nsLayoutAtoms::nextBidi != aListName)
|
|
|
|
#endif
|
1999-02-01 20:27:56 +03:00
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
|
1999-11-01 18:24:57 +03:00
|
|
|
if (aOldFrame) {
|
|
|
|
// Loop and destroy the frame and all of its continuations.
|
|
|
|
PRBool generateReflowCommand = PR_FALSE;
|
2002-03-20 04:44:43 +03:00
|
|
|
|
|
|
|
// If the frame we are removing is a brFrame and we have a
|
|
|
|
// nextInFlow, we need a reflow so we can attempt to pull up
|
|
|
|
// any frames in the nextInFlow that can fit on the line
|
|
|
|
// the brFrame was on.
|
|
|
|
nsCOMPtr<nsIAtom> frameType;
|
|
|
|
aOldFrame->GetFrameType(getter_AddRefs(frameType));
|
|
|
|
if (frameType == nsLayoutAtoms::brFrame && mNextInFlow)
|
|
|
|
generateReflowCommand = PR_TRUE;
|
|
|
|
|
1999-11-01 18:24:57 +03:00
|
|
|
nsIFrame* oldFrameParent;
|
|
|
|
aOldFrame->GetParent(&oldFrameParent);
|
1999-03-16 22:36:24 +03:00
|
|
|
nsInlineFrame* parent = (nsInlineFrame*) oldFrameParent;
|
|
|
|
while (nsnull != aOldFrame) {
|
2001-03-09 06:29:00 +03:00
|
|
|
#ifdef IBMBIDI
|
|
|
|
if (nsLayoutAtoms::nextBidi != aListName) {
|
|
|
|
#endif
|
1999-03-16 22:36:24 +03:00
|
|
|
// If the frame being removed has zero size then don't bother
|
1999-11-01 18:24:57 +03:00
|
|
|
// generating a reflow command, otherwise make sure we do.
|
1999-03-16 22:36:24 +03:00
|
|
|
nsRect bbox;
|
|
|
|
aOldFrame->GetRect(bbox);
|
1999-11-01 18:24:57 +03:00
|
|
|
if (bbox.width || bbox.height) {
|
1999-03-16 22:36:24 +03:00
|
|
|
generateReflowCommand = PR_TRUE;
|
|
|
|
}
|
2001-03-09 06:29:00 +03:00
|
|
|
#ifdef IBMBIDI
|
|
|
|
}
|
|
|
|
#endif
|
1999-02-26 20:08:20 +03:00
|
|
|
|
1999-11-01 18:24:57 +03:00
|
|
|
// When the parent is an inline frame we have a simple task - just
|
|
|
|
// remove the frame from its parents list and generate a reflow
|
|
|
|
// command.
|
1999-03-16 22:36:24 +03:00
|
|
|
nsIFrame* oldFrameNextInFlow;
|
|
|
|
aOldFrame->GetNextInFlow(&oldFrameNextInFlow);
|
1999-07-22 08:00:57 +04:00
|
|
|
parent->mFrames.DestroyFrame(aPresContext, aOldFrame);
|
1999-03-16 22:36:24 +03:00
|
|
|
aOldFrame = oldFrameNextInFlow;
|
|
|
|
if (nsnull != aOldFrame) {
|
|
|
|
aOldFrame->GetParent((nsIFrame**) &parent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-11-01 18:24:57 +03:00
|
|
|
if (generateReflowCommand) {
|
2000-01-19 06:58:05 +03:00
|
|
|
// Ask the parent frame to reflow me.
|
|
|
|
ReflowDirtyChild(&aPresShell, nsnull);
|
1999-02-01 20:27:56 +03:00
|
|
|
}
|
1999-11-01 18:24:57 +03:00
|
|
|
}
|
1999-02-01 20:27:56 +03:00
|
|
|
|
1999-11-01 18:24:57 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-02-01 20:27:56 +03:00
|
|
|
|
1999-11-01 18:24:57 +03:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsInlineFrame::ReplaceFrame(nsIPresContext* aPresContext,
|
1999-11-01 18:24:57 +03:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aOldFrame,
|
|
|
|
nsIFrame* aNewFrame)
|
|
|
|
{
|
2002-11-12 06:30:13 +03:00
|
|
|
if (aListName) {
|
|
|
|
NS_ERROR("Don't have any special lists on inline frames!");
|
1999-11-01 18:24:57 +03:00
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
if (!aOldFrame || !aNewFrame) {
|
2002-11-12 06:30:13 +03:00
|
|
|
NS_ERROR("Missing aOldFrame or aNewFrame");
|
1999-11-01 18:24:57 +03:00
|
|
|
return NS_ERROR_INVALID_ARG;
|
1998-10-27 19:52:10 +03:00
|
|
|
}
|
|
|
|
|
2002-11-12 06:30:13 +03:00
|
|
|
PRBool retval =
|
|
|
|
mFrames.ReplaceFrame(aPresContext, this, aOldFrame, aNewFrame, PR_TRUE);
|
|
|
|
|
2000-01-19 06:58:05 +03:00
|
|
|
// Ask the parent frame to reflow me.
|
|
|
|
ReflowDirtyChild(&aPresShell, nsnull);
|
1998-10-27 19:52:10 +03:00
|
|
|
|
2002-11-12 06:30:13 +03:00
|
|
|
return retval ? NS_OK : NS_ERROR_FAILURE;
|
1998-10-27 19:52:10 +03:00
|
|
|
}
|
|
|
|
|
2000-01-12 11:28:24 +03:00
|
|
|
|
2002-12-11 07:00:18 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsInlineFrame::Paint(nsIPresContext* aPresContext,
|
|
|
|
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 (bug 36710).
|
|
|
|
if (aWhichLayer == NS_FRAME_PAINT_LAYER_FOREGROUND) {
|
2002-12-24 01:05:47 +03:00
|
|
|
PaintSelf(aPresContext, aRenderingContext, aDirtyRect);
|
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()) {
|
|
|
|
nsFrame::Paint(aPresContext, aRenderingContext, aDirtyRect,
|
|
|
|
aWhichLayer, aFlags);
|
|
|
|
}
|
|
|
|
|
|
|
|
PaintDecorationsAndChildren(aPresContext, aRenderingContext,
|
|
|
|
aDirtyRect, aWhichLayer, PR_FALSE,
|
|
|
|
aFlags);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-02-01 20:27:56 +03:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// Reflow methods
|
|
|
|
|
1998-10-27 19:52:10 +03:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsInlineFrame::Reflow(nsIPresContext* aPresContext,
|
1999-02-01 20:27:56 +03:00
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
2000-04-21 18:59:47 +04:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsInlineFrame", aReflowState.reason);
|
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;
|
|
|
|
|
|
|
|
// Check for an overflow list with our prev-in-flow
|
|
|
|
nsInlineFrame* prevInFlow = (nsInlineFrame*)mPrevInFlow;
|
|
|
|
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);
|
|
|
|
|
|
|
|
if (aReflowState.reason == eReflowReason_Initial) {
|
|
|
|
// 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 {
|
|
|
|
// 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
|
|
|
|
if (aReflowState.reason == eReflowReason_Initial) {
|
|
|
|
// 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
|
2000-03-12 06:14:11 +03:00
|
|
|
if (aReflowState.reason != eReflowReason_Initial) {
|
|
|
|
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
|
|
|
|
// the parent pointer for these frames. Check the first frame to see, and
|
|
|
|
// if we haven't set the parent pointer then set it now
|
|
|
|
nsIFrame* parent;
|
|
|
|
overflowFrames->GetParent(&parent);
|
|
|
|
mFrames.AppendFrames(parent == this ? nsnull : 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;
|
|
|
|
irs.mNextInFlow = (nsInlineFrame*) mNextInFlow;
|
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;
|
|
|
|
}
|
|
|
|
|
2000-07-29 02:29:28 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsInlineFrame::CanContinueTextRun(PRBool& aContinueTextRun) const
|
|
|
|
{
|
|
|
|
// We can continue a text run through an inline frame
|
|
|
|
aContinueTextRun = PR_TRUE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-01-13 00:52:58 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsInlineFrame::ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild)
|
|
|
|
{
|
|
|
|
// The inline container frame does not handle the reflow
|
2001-05-22 03:03:46 +04:00
|
|
|
// request. It passes it up to its parent container.
|
2000-01-13 00:52:58 +03:00
|
|
|
|
|
|
|
// If you don't already have dirty children,
|
|
|
|
if (!(mState & NS_FRAME_HAS_DIRTY_CHILDREN)) {
|
|
|
|
if (mParent) {
|
2001-05-22 03:03:46 +04:00
|
|
|
// Record that you are dirty and have dirty children
|
2000-01-13 00:52:58 +03:00
|
|
|
mState |= NS_FRAME_IS_DIRTY;
|
2001-05-22 03:03:46 +04:00
|
|
|
mState |= NS_FRAME_HAS_DIRTY_CHILDREN;
|
2000-01-13 00:52:58 +03:00
|
|
|
|
2001-05-22 03:03:46 +04:00
|
|
|
// Pass the reflow request up to the parent
|
|
|
|
mParent->ReflowDirtyChild(aPresShell, this);
|
2000-01-13 00:52:58 +03:00
|
|
|
}
|
|
|
|
else {
|
2001-05-22 03:03:46 +04:00
|
|
|
NS_ERROR("No parent to pass the reflow request up to.");
|
2000-01-13 00:52:58 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-02-01 20:27:56 +03:00
|
|
|
nsresult
|
1999-11-01 18:24:57 +03:00
|
|
|
nsInlineFrame::ReflowFrames(nsIPresContext* aPresContext,
|
|
|
|
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;
|
1999-03-19 00:03:25 +03:00
|
|
|
nscoord leftEdge = 0;
|
|
|
|
if (nsnull == mPrevInFlow) {
|
|
|
|
leftEdge = aReflowState.mComputedBorderPadding.left;
|
|
|
|
}
|
1999-03-05 07:25:57 +03:00
|
|
|
nscoord availableWidth = aReflowState.availableWidth;
|
1999-02-01 20:27:56 +03:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != availableWidth) {
|
1999-03-19 00:03:25 +03:00
|
|
|
// Subtract off left and right border+padding from availableWidth
|
|
|
|
availableWidth -= leftEdge;
|
|
|
|
availableWidth -= aReflowState.mComputedBorderPadding.right;
|
2002-09-25 01:02:20 +04:00
|
|
|
availableWidth = PR_MAX(0, availableWidth);
|
1999-02-01 20:27:56 +03:00
|
|
|
}
|
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) {
|
|
|
|
frame->SetParent(this);
|
2000-03-22 07:06:37 +03:00
|
|
|
|
|
|
|
// We also need to check if frame has a next-in-flow. It it does, then set
|
|
|
|
// 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
|
|
|
|
nsIFrame* nextInFlow;
|
|
|
|
frame->GetNextInFlow(&nextInFlow);
|
|
|
|
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");
|
|
|
|
nextInFlow->SetParent(this);
|
|
|
|
nextInFlow->GetNextInFlow(&nextInFlow);
|
|
|
|
}
|
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;
|
1999-02-10 09:13:38 +03:00
|
|
|
frame->GetNextSibling(&frame);
|
1999-02-01 20:27:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Attempt to pull frames from our next-in-flow until we can't
|
|
|
|
if (!done && (nsnull != mNextInFlow)) {
|
|
|
|
while (!done) {
|
1999-04-28 02:12:37 +04:00
|
|
|
PRBool reflowingFirstLetter = lineLayout->GetFirstLetterStyleOK();
|
1999-02-01 20:27:56 +03:00
|
|
|
PRBool isComplete;
|
1999-11-01 18:24:57 +03:00
|
|
|
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;
|
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.
|
1999-03-19 00:03:25 +03:00
|
|
|
nsSize size;
|
1999-09-10 01:04:00 +04:00
|
|
|
lineLayout->EndSpan(this, size, aMetrics.maxElementSize);
|
1999-04-20 04:25:12 +04:00
|
|
|
if ((0 == size.height) && (0 == size.width) &&
|
|
|
|
((nsnull != mPrevInFlow) || (nsnull != mNextInFlow))) {
|
|
|
|
// This is a continuation of a previous inline. Therefore make
|
|
|
|
// sure we don't affect the line-height.
|
1999-03-19 00:03:25 +03:00
|
|
|
aMetrics.width = 0;
|
|
|
|
aMetrics.height = 0;
|
|
|
|
aMetrics.ascent = 0;
|
|
|
|
aMetrics.descent = 0;
|
|
|
|
if (nsnull != aMetrics.maxElementSize) {
|
|
|
|
aMetrics.maxElementSize->width = 0;
|
|
|
|
aMetrics.maxElementSize->height = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Compute final width
|
|
|
|
aMetrics.width = size.width;
|
|
|
|
if (nsnull == mPrevInFlow) {
|
|
|
|
aMetrics.width += aReflowState.mComputedBorderPadding.left;
|
1999-02-01 20:27:56 +03:00
|
|
|
}
|
|
|
|
if (NS_FRAME_IS_COMPLETE(aStatus)) {
|
1999-03-05 07:25:57 +03:00
|
|
|
aMetrics.width += aReflowState.mComputedBorderPadding.right;
|
1999-02-01 20:27:56 +03:00
|
|
|
}
|
1999-03-19 00:03:25 +03:00
|
|
|
|
2002-05-25 00:11:14 +04:00
|
|
|
SetFontFromStyle(aReflowState.rendContext, mStyleContext);
|
2002-03-26 04:22:31 +03:00
|
|
|
nsCOMPtr<nsIFontMetrics> fm;
|
2002-05-25 00:11:14 +04:00
|
|
|
aReflowState.rendContext->GetFontMetrics(*getter_AddRefs(fm));
|
2002-03-26 04:22:31 +03:00
|
|
|
|
|
|
|
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->GetMaxDescent(aMetrics.descent);
|
|
|
|
fm->GetHeight(aMetrics.height);
|
|
|
|
} else {
|
|
|
|
NS_WARNING("Cannot get font metrics - defaulting sizes to 0");
|
|
|
|
aMetrics.ascent = aMetrics.descent = aMetrics.height = 0;
|
|
|
|
}
|
1999-09-10 01:04:00 +04:00
|
|
|
aMetrics.ascent += aReflowState.mComputedBorderPadding.top;
|
|
|
|
aMetrics.descent += aReflowState.mComputedBorderPadding.bottom;
|
|
|
|
aMetrics.height += aReflowState.mComputedBorderPadding.top +
|
|
|
|
aReflowState.mComputedBorderPadding.bottom;
|
1999-04-20 04:25:12 +04:00
|
|
|
|
1999-09-10 01:04:00 +04:00
|
|
|
// Note: we normally use the actual font height for computing the
|
|
|
|
// line-height raw value from the style context. On systems where
|
|
|
|
// they disagree the actual font height is more appropriate. This
|
|
|
|
// little hack lets us override that behavior to allow for more
|
|
|
|
// precise layout in the face of imprecise fonts.
|
1999-10-13 03:25:49 +04:00
|
|
|
if (nsHTMLReflowState::UseComputedHeight()) {
|
2002-05-25 00:11:14 +04:00
|
|
|
const nsStyleFont* font;
|
|
|
|
GetStyleData(eStyleStruct_Font, (const nsStyleStruct*&)font);
|
1999-09-10 01:04:00 +04:00
|
|
|
aMetrics.height = font->mFont.size +
|
|
|
|
aReflowState.mComputedBorderPadding.top +
|
1999-09-03 07:47:49 +04:00
|
|
|
aReflowState.mComputedBorderPadding.bottom;
|
|
|
|
}
|
1999-02-01 20:27:56 +03:00
|
|
|
}
|
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
|
1999-03-19 00:03:25 +03:00
|
|
|
// computed during vertical alignment of the line we are on.
|
1999-12-06 18:49:53 +03:00
|
|
|
aMetrics.mOverflowArea.x = 0;
|
|
|
|
aMetrics.mOverflowArea.y = 0;
|
|
|
|
aMetrics.mOverflowArea.width = aMetrics.width;
|
|
|
|
aMetrics.mOverflowArea.height = aMetrics.height;
|
1999-03-19 00:03:25 +03:00
|
|
|
|
|
|
|
#ifdef NOISY_FINAL_SIZE
|
|
|
|
ListTag(stdout);
|
2000-10-29 02:17:53 +04:00
|
|
|
printf(": metrics=%d,%d ascent=%d descent=%d\n",
|
1999-03-19 00:03:25 +03:00
|
|
|
aMetrics.width, aMetrics.height, aMetrics.ascent, aMetrics.descent);
|
2000-02-02 10:38:23 +03:00
|
|
|
if (nsnull != aMetrics.maxElementSize) {
|
2000-10-29 02:17:53 +04:00
|
|
|
printf(" maxElementSize %d,%d\n",
|
|
|
|
aMetrics.maxElementSize->width, aMetrics.maxElementSize->height);
|
2000-02-02 10:38:23 +03:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2000-09-12 00:46:44 +04:00
|
|
|
static
|
|
|
|
void SetContainsPercentAwareChild(nsIFrame *aFrame)
|
|
|
|
{
|
|
|
|
nsFrameState myFrameState;
|
|
|
|
aFrame->GetFrameState(&myFrameState);
|
|
|
|
aFrame->SetFrameState(myFrameState | NS_INLINE_FRAME_CONTAINS_PERCENT_AWARE_CHILD);
|
|
|
|
}
|
|
|
|
|
|
|
|
static
|
|
|
|
void MarkPercentAwareFrame(nsIPresContext *aPresContext,
|
|
|
|
nsInlineFrame *aInline,
|
|
|
|
nsIFrame *aFrame)
|
|
|
|
{
|
|
|
|
nsFrameState childFrameState;
|
|
|
|
aFrame->GetFrameState(&childFrameState);
|
|
|
|
if (childFrameState & NS_FRAME_REPLACED_ELEMENT)
|
|
|
|
{ // aFrame is a replaced element, check it's style
|
|
|
|
if (nsLineLayout::IsPercentageAwareReplacedElement(aPresContext, aFrame)) {
|
|
|
|
SetContainsPercentAwareChild(aInline);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nsIFrame *child;
|
|
|
|
aFrame->FirstChild(aPresContext, nsnull, &child);
|
|
|
|
if (child)
|
|
|
|
{ // aFrame is an inline container frame, check my frame state
|
|
|
|
if (childFrameState & NS_INLINE_FRAME_CONTAINS_PERCENT_AWARE_CHILD) {
|
|
|
|
SetContainsPercentAwareChild(aInline); // if a child container is effected, so am I
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// else frame is a leaf that we don't care about
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-02-01 20:27:56 +03:00
|
|
|
nsresult
|
1999-04-20 04:25:12 +04:00
|
|
|
nsInlineFrame::ReflowInlineFrame(nsIPresContext* 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;
|
2002-05-10 22:22:41 +04:00
|
|
|
nsresult rv = lineLayout->ReflowFrame(aFrame, aStatus, nsnull, pushedFrame);
|
2000-09-12 00:46:44 +04:00
|
|
|
/* This next block is for bug 28811
|
|
|
|
Test the child frame for %-awareness,
|
|
|
|
and mark this frame with a bit if it is %-aware.
|
|
|
|
Don't bother if this frame is already marked
|
|
|
|
*/
|
|
|
|
if (!(mState & NS_INLINE_FRAME_CONTAINS_PERCENT_AWARE_CHILD)) {
|
|
|
|
MarkPercentAwareFrame(aPresContext, this, aFrame);
|
|
|
|
}
|
|
|
|
|
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) {
|
|
|
|
nsIFrame* f;
|
|
|
|
aFrame->GetNextSibling(&f);
|
|
|
|
while (f) {
|
|
|
|
f->SetParent(this);
|
|
|
|
f->GetNextSibling(&f);
|
|
|
|
}
|
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
nsIFrame* nextFrame;
|
1999-02-10 09:13:38 +03:00
|
|
|
aFrame->GetNextSibling(&nextFrame);
|
1999-02-01 20:27:56 +03:00
|
|
|
if (nsnull != nextFrame) {
|
1999-02-03 22:12:02 +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
|
|
|
}
|
1999-02-03 22:12:02 +03:00
|
|
|
else if (nsnull != mNextInFlow) {
|
|
|
|
// We must return an incomplete status if there are more child
|
|
|
|
// frames remaining in a next-in-flow that follows this frame.
|
|
|
|
nsInlineFrame* nextInFlow = (nsInlineFrame*) mNextInFlow;
|
|
|
|
while (nsnull != nextInFlow) {
|
|
|
|
if (nextInFlow->mFrames.NotEmpty()) {
|
|
|
|
aStatus |= NS_FRAME_NOT_COMPLETE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
nextInFlow = (nsInlineFrame*) nextInFlow->mNextInFlow;
|
|
|
|
}
|
|
|
|
}
|
1999-02-01 20:27:56 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (NS_FRAME_IS_NOT_COMPLETE(aStatus)) {
|
2002-09-25 02:13:20 +04:00
|
|
|
nsCOMPtr<nsIAtom> frameType;
|
|
|
|
aFrame->GetFrameType(getter_AddRefs(frameType));
|
|
|
|
if (nsLayoutAtoms::placeholderFrame == frameType) {
|
|
|
|
nsBlockReflowState* blockRS = lineLayout->mBlockRS;
|
2002-12-04 03:58:52 +03:00
|
|
|
blockRS->mBlock->SplitPlaceholder(*aPresContext, *aFrame);
|
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) {
|
|
|
|
nsIFrame* nextFrame;
|
|
|
|
aFrame->GetNextSibling(&nextFrame);
|
|
|
|
if (nsnull != nextFrame) {
|
|
|
|
PushFrames(aPresContext, nextFrame, aFrame);
|
|
|
|
}
|
1999-04-28 02:12:37 +04:00
|
|
|
}
|
1999-02-01 20:27:56 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame*
|
1999-11-01 18:24:57 +03:00
|
|
|
nsInlineFrame::PullOneFrame(nsIPresContext* aPresContext,
|
|
|
|
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) {
|
1999-03-05 07:25:57 +03:00
|
|
|
frame = mFrames.PullFrame(this, irs.mPrevFrame, nextInFlow->mFrames);
|
1999-02-01 20:27:56 +03:00
|
|
|
if (nsnull != frame) {
|
|
|
|
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;
|
|
|
|
}
|
1999-11-01 18:24:57 +03:00
|
|
|
nextInFlow = (nsInlineFrame*) nextInFlow->mNextInFlow;
|
|
|
|
irs.mNextInFlow = nextInFlow;
|
1999-02-01 20:27:56 +03:00
|
|
|
}
|
|
|
|
|
1999-11-01 18:24:57 +03:00
|
|
|
*aIsComplete = isComplete;
|
|
|
|
return frame;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsInlineFrame::PushFrames(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame* aFromChild,
|
|
|
|
nsIFrame* aPrevSibling)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aFromChild, "null pointer");
|
|
|
|
NS_PRECONDITION(nsnull != aPrevSibling, "pushing first child");
|
|
|
|
#ifdef DEBUG
|
|
|
|
nsIFrame* prevNextSibling;
|
|
|
|
aPrevSibling->GetNextSibling(&prevNextSibling);
|
|
|
|
NS_PRECONDITION(prevNextSibling == aFromChild, "bad prev sibling");
|
|
|
|
#endif
|
|
|
|
|
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;
|
|
|
|
if (nsnull != mPrevInFlow) {
|
1999-04-20 04:25:12 +04:00
|
|
|
nsInlineFrame* prev = (nsInlineFrame*) mPrevInFlow;
|
|
|
|
if (prev->mRect.height || prev->mRect.width) {
|
|
|
|
// Prev-in-flow is not empty therefore we don't render our left
|
|
|
|
// border edge.
|
|
|
|
skip |= 1 << NS_SIDE_LEFT;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// If the prev-in-flow is empty, then go ahead and let our right
|
|
|
|
// edge border render.
|
|
|
|
}
|
1998-12-19 01:12:42 +03:00
|
|
|
}
|
|
|
|
if (nsnull != mNextInFlow) {
|
1999-04-20 04:25:12 +04:00
|
|
|
nsInlineFrame* next = (nsInlineFrame*) mNextInFlow;
|
|
|
|
if (next->mRect.height || next->mRect.width) {
|
|
|
|
// Next-in-flow is not empty therefore we don't render our right
|
|
|
|
// border edge.
|
|
|
|
skip |= 1 << NS_SIDE_RIGHT;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// If the next-in-flow is empty, then go ahead and let our right
|
|
|
|
// 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;
|
|
|
|
nsCOMPtr<nsIAtom> tagAtom;
|
|
|
|
mContent->GetTag(*getter_AddRefs(tagAtom));
|
2002-11-06 04:29:58 +03:00
|
|
|
if (tagAtom == nsHTMLAtoms::img || tagAtom == nsHTMLAtoms::input || tagAtom == nsHTMLAtoms::hr) {
|
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;
|
|
|
|
if (tagAtom == nsHTMLAtoms::input) // Broken <input type=image ... />
|
|
|
|
return accService->CreateHTML4ButtonAccessible(NS_STATIC_CAST(nsIFrame*, this), aAccessible);
|
2002-11-06 04:29:58 +03:00
|
|
|
else if (tagAtom == nsHTMLAtoms::img) // Create accessible for broken <img>
|
|
|
|
return accService->CreateHTMLImageAccessible(NS_STATIC_CAST(nsIFrame*, this), aAccessible);
|
|
|
|
// Create accessible for <hr>
|
|
|
|
return accService->CreateHTMLHRAccessible(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
|
1999-09-04 03:35:41 +04:00
|
|
|
ReParentChildListStyle(nsIPresContext* aPresContext,
|
|
|
|
nsIStyleContext* aParentStyleContext,
|
|
|
|
nsFrameList& aFrameList)
|
1999-04-20 04:25:12 +04:00
|
|
|
{
|
|
|
|
nsIFrame* kid = aFrameList.FirstChild();
|
|
|
|
while (nsnull != kid) {
|
1999-09-04 03:35:41 +04:00
|
|
|
aPresContext->ReParentStyleContext(kid, aParentStyleContext);
|
1999-04-20 04:25:12 +04:00
|
|
|
kid->GetNextSibling(&kid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
1999-12-05 02:49:50 +03:00
|
|
|
NS_NewFirstLineFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
|
1999-04-20 04:25:12 +04:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aNewFrame, "null ptr");
|
|
|
|
if (nsnull == aNewFrame) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1999-12-05 02:49:50 +03:00
|
|
|
nsInlineFrame* it = new (aPresShell) nsFirstLineFrame;
|
1999-04-20 04:25:12 +04:00
|
|
|
if (nsnull == it) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
*aNewFrame = it;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsFirstLineFrame::nsFirstLineFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFirstLineFrame::GetFrameType(nsIAtom** aType) const
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aType, "null OUT parameter pointer");
|
1999-04-28 02:12:37 +04:00
|
|
|
*aType = nsLayoutAtoms::lineFrame;
|
1999-04-20 04:25:12 +04:00
|
|
|
NS_ADDREF(*aType);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
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*
|
1999-11-01 18:24:57 +03:00
|
|
|
nsFirstLineFrame::PullOneFrame(nsIPresContext* 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);
|
1999-04-20 04:25:12 +04:00
|
|
|
if (frame && !mPrevInFlow) {
|
|
|
|
// We are a first-line frame. Fixup the child frames
|
|
|
|
// style-context that we just pulled.
|
1999-09-04 03:35:41 +04:00
|
|
|
aPresContext->ReParentStyleContext(frame, mStyleContext);
|
1999-04-20 04:25:12 +04:00
|
|
|
}
|
|
|
|
return frame;
|
|
|
|
}
|
|
|
|
|
2000-03-12 06:14:11 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFirstLineFrame::Reflow(nsIPresContext* aPresContext,
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
1999-04-20 04:25:12 +04:00
|
|
|
// Check for an overflow list with our prev-in-flow
|
|
|
|
nsFirstLineFrame* prevInFlow = (nsFirstLineFrame*)mPrevInFlow;
|
|
|
|
if (nsnull != prevInFlow) {
|
1999-10-21 09:11:43 +04:00
|
|
|
nsIFrame* prevOverflowFrames = prevInFlow->GetOverflowFrames(aPresContext, PR_TRUE);
|
|
|
|
if (prevOverflowFrames) {
|
|
|
|
nsFrameList frames(prevOverflowFrames);
|
|
|
|
|
|
|
|
ReParentChildListStyle(aPresContext, mStyleContext, frames);
|
|
|
|
mFrames.InsertFrames(this, nsnull, prevOverflowFrames);
|
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);
|
|
|
|
|
|
|
|
ReParentChildListStyle(aPresContext, mStyleContext, frames);
|
|
|
|
mFrames.AppendFrames(nsnull, overflowFrames);
|
1999-04-20 04:25:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set our own reflow state (additional state above and beyond
|
|
|
|
// aReflowState)
|
|
|
|
InlineReflowState irs;
|
|
|
|
irs.mPrevFrame = nsnull;
|
|
|
|
irs.mNextInFlow = (nsInlineFrame*) mNextInFlow;
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
1999-11-01 18:24:57 +03:00
|
|
|
if (nsnull == mPrevInFlow) {
|
|
|
|
// 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.
|
|
|
|
nsIFrame* parentFrame;
|
|
|
|
first->GetParent(&parentFrame);
|
|
|
|
nsIStyleContext* parentContext;
|
|
|
|
parentFrame->GetStyleContext(&parentContext);
|
|
|
|
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.
|
|
|
|
nsIStyleContext* newSC;
|
2002-11-17 18:37:56 +03:00
|
|
|
aPresContext->ResolvePseudoStyleContextFor(nsnull,
|
|
|
|
nsCSSAnonBoxes::mozLineFrame, parentContext, &newSC);
|
1999-11-01 18:24:57 +03:00
|
|
|
if (newSC) {
|
|
|
|
// Switch to the new style context.
|
1999-11-24 09:03:41 +03:00
|
|
|
SetStyleContext(aPresContext, newSC);
|
1999-11-01 18:24:57 +03:00
|
|
|
|
|
|
|
// Re-resolve all children
|
1999-11-24 09:03:41 +03:00
|
|
|
ReParentChildListStyle(aPresContext, mStyleContext, mFrames);
|
1999-11-01 18:24:57 +03:00
|
|
|
|
|
|
|
NS_RELEASE(newSC);
|
1999-04-20 04:25:12 +04:00
|
|
|
}
|
1999-11-01 18:24:57 +03:00
|
|
|
NS_RELEASE(parentContext);
|
1999-04-20 04:25:12 +04:00
|
|
|
}
|
|
|
|
}
|
1999-11-01 18:24:57 +03:00
|
|
|
}
|
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
rv = ReflowFrames(aPresContext, aReflowState, irs, aMetrics, aStatus);
|
1999-11-01 18:24:57 +03:00
|
|
|
|
|
|
|
// Note: the line layout code will properly compute our
|
|
|
|
// NS_FRAME_OUTSIDE_CHILDREN state for us.
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
nsresult
|
1999-12-05 02:49:50 +03:00
|
|
|
NS_NewPositionedInlineFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
|
1999-11-01 18:24:57 +03:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
|
|
|
if (nsnull == aNewFrame) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1999-12-05 02:49:50 +03:00
|
|
|
nsPositionedInlineFrame* it = new (aPresShell) nsPositionedInlineFrame;
|
1999-11-01 18:24:57 +03:00
|
|
|
if (nsnull == it) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
*aNewFrame = it;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsPositionedInlineFrame::Destroy(nsIPresContext* aPresContext)
|
1999-11-01 18:24:57 +03:00
|
|
|
{
|
|
|
|
mAbsoluteContainer.DestroyFrames(this, aPresContext);
|
|
|
|
return nsInlineFrame::Destroy(aPresContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsPositionedInlineFrame::SetInitialChildList(nsIPresContext* aPresContext,
|
1999-11-01 18:24:57 +03:00
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aChildList)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
if (nsLayoutAtoms::absoluteList == aListName) {
|
|
|
|
rv = mAbsoluteContainer.SetInitialChildList(this, aPresContext, aListName, aChildList);
|
|
|
|
} else {
|
|
|
|
rv = nsInlineFrame::SetInitialChildList(aPresContext, aListName, aChildList);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsPositionedInlineFrame::AppendFrames(nsIPresContext* aPresContext,
|
1999-11-01 18:24:57 +03:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aFrameList)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
if (nsLayoutAtoms::absoluteList == aListName) {
|
|
|
|
rv = mAbsoluteContainer.AppendFrames(this, aPresContext, aPresShell, aListName,
|
|
|
|
aFrameList);
|
|
|
|
} else {
|
|
|
|
rv = nsInlineFrame::AppendFrames(aPresContext, aPresShell, aListName,
|
|
|
|
aFrameList);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsPositionedInlineFrame::InsertFrames(nsIPresContext* aPresContext,
|
1999-11-01 18:24:57 +03:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aPrevFrame,
|
|
|
|
nsIFrame* aFrameList)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
if (nsLayoutAtoms::absoluteList == aListName) {
|
|
|
|
rv = mAbsoluteContainer.InsertFrames(this, aPresContext, aPresShell, aListName,
|
|
|
|
aPrevFrame, aFrameList);
|
|
|
|
} else {
|
|
|
|
rv = nsInlineFrame::InsertFrames(aPresContext, aPresShell, aListName, aPrevFrame,
|
|
|
|
aFrameList);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsPositionedInlineFrame::RemoveFrame(nsIPresContext* aPresContext,
|
1999-11-01 18:24:57 +03:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aOldFrame)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
if (nsLayoutAtoms::absoluteList == aListName) {
|
|
|
|
rv = mAbsoluteContainer.RemoveFrame(this, aPresContext, aPresShell, aListName, aOldFrame);
|
|
|
|
} else {
|
|
|
|
rv = nsInlineFrame::RemoveFrame(aPresContext, aPresShell, aListName, aOldFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2002-11-12 06:30:13 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPositionedInlineFrame::ReplaceFrame(nsIPresContext* aPresContext,
|
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aOldFrame,
|
|
|
|
nsIFrame* aNewFrame)
|
|
|
|
{
|
|
|
|
if (nsLayoutAtoms::absoluteList == aListName) {
|
|
|
|
return mAbsoluteContainer.ReplaceFrame(this, aPresContext, aPresShell,
|
|
|
|
aListName, aOldFrame, aNewFrame);
|
|
|
|
} else {
|
|
|
|
return nsInlineFrame::ReplaceFrame(aPresContext, aPresShell, aListName,
|
|
|
|
aOldFrame, aNewFrame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-11-01 18:24:57 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPositionedInlineFrame::GetAdditionalChildListName(PRInt32 aIndex,
|
|
|
|
nsIAtom** aListName) const
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aListName, "null OUT parameter pointer");
|
|
|
|
*aListName = nsnull;
|
|
|
|
if (0 == aIndex) {
|
|
|
|
*aListName = nsLayoutAtoms::absoluteList;
|
|
|
|
NS_ADDREF(*aListName);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2000-01-22 04:16:50 +03:00
|
|
|
nsPositionedInlineFrame::FirstChild(nsIPresContext* aPresContext,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame** aFirstChild) const
|
1999-11-01 18:24:57 +03:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aFirstChild, "null OUT parameter pointer");
|
|
|
|
if (aListName == nsLayoutAtoms::absoluteList) {
|
|
|
|
return mAbsoluteContainer.FirstChild(this, aListName, aFirstChild);
|
|
|
|
}
|
|
|
|
|
2000-01-22 04:16:50 +03:00
|
|
|
return nsInlineFrame::FirstChild(aPresContext, aListName, aFirstChild);
|
1999-11-01 18:24:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPositionedInlineFrame::GetFrameType(nsIAtom** aType) const
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aType, "null OUT parameter pointer");
|
|
|
|
*aType = nsLayoutAtoms::positionedInlineFrame;
|
|
|
|
NS_ADDREF(*aType);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsPositionedInlineFrame::Reflow(nsIPresContext* aPresContext,
|
1999-11-01 18:24:57 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
2002-06-12 07:21:00 +04:00
|
|
|
nsRect oldRect(mRect);
|
|
|
|
|
2002-07-29 08:19:15 +04:00
|
|
|
// See if it's an incremental reflow command
|
2002-06-12 07:21:00 +04:00
|
|
|
if (mAbsoluteContainer.HasAbsoluteFrames() &&
|
2002-07-29 08:19:15 +04:00
|
|
|
eReflowReason_Incremental == aReflowState.reason) {
|
1999-11-01 18:24:57 +03:00
|
|
|
// Give the absolute positioning code a chance to handle it
|
|
|
|
PRBool handled;
|
|
|
|
nscoord containingBlockWidth = -1;
|
|
|
|
nscoord containingBlockHeight = -1;
|
|
|
|
|
|
|
|
mAbsoluteContainer.IncrementalReflow(this, aPresContext, aReflowState,
|
|
|
|
containingBlockWidth, containingBlockHeight,
|
2002-09-24 15:43:48 +04:00
|
|
|
handled);
|
1999-11-01 18:24:57 +03:00
|
|
|
|
|
|
|
// If the incremental reflow command was handled by the absolute positioning
|
|
|
|
// code, then we're all done
|
|
|
|
if (handled) {
|
|
|
|
// Just return our current size as our desired size
|
|
|
|
// XXX I don't know how to compute that without a reflow, so for the
|
|
|
|
// time being pretend a resize reflow occured
|
|
|
|
nsHTMLReflowState reflowState(aReflowState);
|
|
|
|
reflowState.reason = eReflowReason_Resize;
|
2002-05-10 22:22:41 +04:00
|
|
|
reflowState.path = nsnull;
|
1999-12-06 18:49:53 +03:00
|
|
|
rv = nsInlineFrame::Reflow(aPresContext, aDesiredSize, reflowState, aStatus);
|
|
|
|
|
|
|
|
// XXX Although this seems like the correct thing to do the line layout
|
|
|
|
// code seems to reset the NS_FRAME_OUTSIDE_CHILDREN and so it is ignored
|
|
|
|
#if 0
|
|
|
|
// Factor the absolutely positioned child bounds into the overflow area
|
2002-09-24 15:43:48 +04:00
|
|
|
nsRect childBounds;
|
|
|
|
mAbsoluteContainer.CalculateChildBounds(aPresContext, childBounds);
|
1999-12-06 18:49:53 +03:00
|
|
|
aDesiredSize.mOverflowArea.UnionRect(aDesiredSize.mOverflowArea, childBounds);
|
|
|
|
|
2002-12-22 08:40:51 +03:00
|
|
|
// Make sure the NS_FRAME_OUTSIDE_CHILDREN flag is set correctly
|
|
|
|
if ((aDesiredSize.mOverflowArea.x < 0) ||
|
|
|
|
(aDesiredSize.mOverflowArea.y < 0) ||
|
|
|
|
(aDesiredSize.mOverflowArea.XMost() > aDesiredSize.width) ||
|
|
|
|
(aDesiredSize.mOverflowArea.YMost() > aDesiredSize.height)) {
|
|
|
|
mState |= NS_FRAME_OUTSIDE_CHILDREN;
|
|
|
|
} else {
|
|
|
|
mState &= ~NS_FRAME_OUTSIDE_CHILDREN;
|
|
|
|
}
|
1999-12-06 18:49:53 +03:00
|
|
|
#endif
|
|
|
|
return rv;
|
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) &&
|
|
|
|
mAbsoluteContainer.HasAbsoluteFrames() &&
|
|
|
|
(eReflowReason_Incremental != aReflowState.reason ||
|
|
|
|
aReflowState.path->mReflowCommand ||
|
|
|
|
mRect != oldRect)) {
|
1999-11-01 18:24:57 +03:00
|
|
|
nscoord containingBlockWidth = -1;
|
|
|
|
nscoord containingBlockHeight = -1;
|
1999-12-06 18:49:53 +03:00
|
|
|
nsRect childBounds;
|
1999-11-01 18:24:57 +03:00
|
|
|
|
|
|
|
rv = mAbsoluteContainer.Reflow(this, aPresContext, aReflowState,
|
1999-12-06 18:49:53 +03:00
|
|
|
containingBlockWidth, containingBlockHeight,
|
|
|
|
childBounds);
|
|
|
|
|
|
|
|
// XXX Although this seems like the correct thing to do the line layout
|
|
|
|
// code seems to reset the NS_FRAME_OUTSIDE_CHILDREN and so it is ignored
|
|
|
|
#if 0
|
|
|
|
// Factor the absolutely positioned child bounds into the overflow area
|
|
|
|
aDesiredSize.mOverflowArea.UnionRect(aDesiredSize.mOverflowArea, childBounds);
|
|
|
|
|
2002-12-22 08:40:51 +03:00
|
|
|
// Make sure the NS_FRAME_OUTSIDE_CHILDREN flag is set correctly
|
|
|
|
if ((aDesiredSize.mOverflowArea.x < 0) ||
|
|
|
|
(aDesiredSize.mOverflowArea.y < 0) ||
|
|
|
|
(aDesiredSize.mOverflowArea.XMost() > aDesiredSize.width) ||
|
|
|
|
(aDesiredSize.mOverflowArea.YMost() > aDesiredSize.height)) {
|
|
|
|
mState |= NS_FRAME_OUTSIDE_CHILDREN;
|
|
|
|
} else {
|
|
|
|
mState &= ~NS_FRAME_OUTSIDE_CHILDREN;
|
|
|
|
}
|
1999-12-06 18:49:53 +03:00
|
|
|
#endif
|
1999-04-20 04:25:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
1999-08-31 07:09:40 +04:00
|
|
|
|
1999-09-01 05:02:16 +04:00
|
|
|
#ifdef DEBUG
|
1999-08-31 07:09:40 +04:00
|
|
|
NS_IMETHODIMP
|
1999-11-01 18:24:57 +03:00
|
|
|
nsPositionedInlineFrame::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const
|
1999-08-31 07:09:40 +04:00
|
|
|
{
|
1999-09-01 05:02:16 +04:00
|
|
|
if (!aResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
1999-08-31 07:09:40 +04:00
|
|
|
}
|
1999-09-01 05:02:16 +04:00
|
|
|
*aResult = sizeof(*this);
|
|
|
|
return NS_OK;
|
1999-08-31 07:09:40 +04:00
|
|
|
}
|
1999-09-01 05:02:16 +04:00
|
|
|
#endif
|