2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2001-10-25 01:08:40 +00:00
|
|
|
// vim:cindent:ts=2:et:sw=2:
|
2001-09-28 20:14:13 +00:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 14:30:37 +00:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1998-06-18 16:25:41 +00:00
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
1998-06-18 16:25:41 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1998-06-18 16:25:41 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-28 20:14:13 +00:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 03:40:37 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* Contributor(s):
|
2000-04-17 14:40:46 +00:00
|
|
|
* Steve Clark <buster@netscape.com>
|
|
|
|
* Robert O'Callahan <roc+moz@cs.cmu.edu>
|
2003-01-01 23:53:20 +00:00
|
|
|
* L. David Baron <dbaron@dbaron.org>
|
2004-06-20 09:51:10 +00:00
|
|
|
* IBM Corporation
|
2010-06-01 23:32:59 +00:00
|
|
|
* Mats Palmgren <matspal@gmail.com>
|
2001-09-28 20:14:13 +00:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 14:30:37 +00:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-28 20:14:13 +00:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-18 14:30:37 +00:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-28 20:14:13 +00:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-18 14:30:37 +00:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-28 20:14:13 +00:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2006-03-29 18:29:03 +00:00
|
|
|
|
|
|
|
/*
|
2007-12-12 21:49:14 +00:00
|
|
|
* rendering object for CSS display:block, inline-block, and list-item
|
|
|
|
* boxes, also used for various anonymous boxes
|
2006-03-29 18:29:03 +00:00
|
|
|
*/
|
|
|
|
|
1999-03-19 23:05:56 +00:00
|
|
|
#include "nsCOMPtr.h"
|
1998-11-16 17:11:12 +00:00
|
|
|
#include "nsBlockFrame.h"
|
1998-12-05 16:02:08 +00:00
|
|
|
#include "nsBlockReflowContext.h"
|
2001-05-01 04:22:57 +00:00
|
|
|
#include "nsBlockReflowState.h"
|
1998-12-05 16:02:08 +00:00
|
|
|
#include "nsBulletFrame.h"
|
|
|
|
#include "nsLineBox.h"
|
1999-04-20 00:27:43 +00:00
|
|
|
#include "nsInlineFrame.h"
|
1998-09-15 00:19:49 +00:00
|
|
|
#include "nsLineLayout.h"
|
1998-06-18 16:25:41 +00:00
|
|
|
#include "nsPlaceholderFrame.h"
|
|
|
|
#include "nsStyleConsts.h"
|
2004-02-23 21:29:06 +00:00
|
|
|
#include "nsFrameManager.h"
|
2004-07-31 23:15:21 +00:00
|
|
|
#include "nsPresContext.h"
|
1998-06-18 16:25:41 +00:00
|
|
|
#include "nsIPresShell.h"
|
2003-02-22 00:32:13 +00:00
|
|
|
#include "nsStyleContext.h"
|
1998-06-18 16:25:41 +00:00
|
|
|
#include "nsIView.h"
|
1998-09-23 02:25:26 +00:00
|
|
|
#include "nsHTMLParts.h"
|
2007-01-30 00:06:41 +00:00
|
|
|
#include "nsGkAtoms.h"
|
2000-12-30 19:22:22 +00:00
|
|
|
#include "nsIDOMEvent.h"
|
2005-01-12 19:45:38 +00:00
|
|
|
#include "nsGenericHTMLElement.h"
|
1998-11-14 21:01:26 +00:00
|
|
|
#include "prprf.h"
|
1999-07-14 17:26:20 +00:00
|
|
|
#include "nsStyleChangeList.h"
|
2006-04-26 02:01:07 +00:00
|
|
|
#include "nsFrameSelection.h"
|
2009-01-05 00:39:54 +00:00
|
|
|
#include "nsFloatManager.h"
|
2001-10-25 01:08:40 +00:00
|
|
|
#include "nsIntervalSet.h"
|
1999-10-15 23:35:10 +00:00
|
|
|
#include "prenv.h"
|
|
|
|
#include "plstr.h"
|
2001-07-16 02:40:48 +00:00
|
|
|
#include "nsGUIEvent.h"
|
2002-11-25 11:21:22 +00:00
|
|
|
#include "nsLayoutErrors.h"
|
2003-02-22 00:32:13 +00:00
|
|
|
#include "nsAutoPtr.h"
|
2003-03-05 02:51:36 +00:00
|
|
|
#include "nsIServiceManager.h"
|
2005-10-18 05:00:24 +00:00
|
|
|
#include "nsIScrollableFrame.h"
|
2004-06-04 21:08:05 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2006-07-11 22:14:09 +00:00
|
|
|
#include "nsIDOMHTMLDocument.h"
|
2011-01-28 04:38:14 +00:00
|
|
|
#include "nsAccessibilityService.h"
|
2004-06-04 21:08:05 +00:00
|
|
|
#endif
|
2004-09-13 13:35:46 +00:00
|
|
|
#include "nsLayoutUtils.h"
|
2006-01-26 02:29:17 +00:00
|
|
|
#include "nsDisplayList.h"
|
2006-03-22 18:36:36 +00:00
|
|
|
#include "nsContentErrors.h"
|
2007-04-21 03:57:40 +00:00
|
|
|
#include "nsCSSAnonBoxes.h"
|
2009-09-18 11:09:35 +00:00
|
|
|
#include "nsCSSFrameConstructor.h"
|
2007-08-06 08:15:00 +00:00
|
|
|
#include "nsCSSRendering.h"
|
2010-08-31 00:49:13 +00:00
|
|
|
#include "FrameLayerBuilder.h"
|
2011-04-08 01:04:40 +00:00
|
|
|
#include "nsRenderingContext.h"
|
1999-01-05 23:01:54 +00:00
|
|
|
|
2001-03-09 03:29:00 +00:00
|
|
|
#ifdef IBMBIDI
|
|
|
|
#include "nsBidiPresUtils.h"
|
|
|
|
#endif // IBMBIDI
|
|
|
|
|
2001-03-08 02:46:44 +00:00
|
|
|
#include "nsIDOMHTMLBodyElement.h"
|
|
|
|
#include "nsIDOMHTMLHtmlElement.h"
|
|
|
|
|
2004-03-07 18:04:24 +00:00
|
|
|
static const int MIN_LINES_NEEDING_CURSOR = 20;
|
|
|
|
|
2010-10-15 15:34:24 +00:00
|
|
|
static const PRUnichar kDiscCharacter = 0x2022;
|
|
|
|
static const PRUnichar kCircleCharacter = 0x25e6;
|
|
|
|
static const PRUnichar kSquareCharacter = 0x25aa;
|
|
|
|
|
2008-08-12 09:32:10 +00:00
|
|
|
#define DISABLE_FLOAT_BREAKING_IN_COLUMNS
|
|
|
|
|
2010-03-29 01:46:55 +00:00
|
|
|
using namespace mozilla;
|
|
|
|
|
1999-10-15 23:35:10 +00:00
|
|
|
#ifdef DEBUG
|
2001-12-17 22:39:59 +00:00
|
|
|
#include "nsPrintfCString.h"
|
2001-05-01 04:22:57 +00:00
|
|
|
#include "nsBlockDebugFlags.h"
|
1999-10-15 23:35:10 +00:00
|
|
|
|
2001-05-01 04:22:57 +00:00
|
|
|
PRBool nsBlockFrame::gLamePaintMetrics;
|
|
|
|
PRBool nsBlockFrame::gLameReflowMetrics;
|
|
|
|
PRBool nsBlockFrame::gNoisy;
|
|
|
|
PRBool nsBlockFrame::gNoisyDamageRepair;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
PRBool nsBlockFrame::gNoisyIntrinsic;
|
2001-05-01 04:22:57 +00:00
|
|
|
PRBool nsBlockFrame::gNoisyReflow;
|
|
|
|
PRBool nsBlockFrame::gReallyNoisyReflow;
|
2009-01-05 00:39:54 +00:00
|
|
|
PRBool nsBlockFrame::gNoisyFloatManager;
|
2001-05-01 04:22:57 +00:00
|
|
|
PRBool nsBlockFrame::gVerifyLines;
|
|
|
|
PRBool nsBlockFrame::gDisableResizeOpt;
|
|
|
|
|
|
|
|
PRInt32 nsBlockFrame::gNoiseIndent;
|
1999-10-15 23:35:10 +00:00
|
|
|
|
|
|
|
struct BlockDebugFlags {
|
|
|
|
const char* name;
|
|
|
|
PRBool* on;
|
|
|
|
};
|
|
|
|
|
2004-01-21 23:08:51 +00:00
|
|
|
static const BlockDebugFlags gFlags[] = {
|
2001-05-01 04:22:57 +00:00
|
|
|
{ "reflow", &nsBlockFrame::gNoisyReflow },
|
|
|
|
{ "really-noisy-reflow", &nsBlockFrame::gReallyNoisyReflow },
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
{ "intrinsic", &nsBlockFrame::gNoisyIntrinsic },
|
2009-01-05 00:39:54 +00:00
|
|
|
{ "float-manager", &nsBlockFrame::gNoisyFloatManager },
|
2001-05-01 04:22:57 +00:00
|
|
|
{ "verify-lines", &nsBlockFrame::gVerifyLines },
|
|
|
|
{ "damage-repair", &nsBlockFrame::gNoisyDamageRepair },
|
|
|
|
{ "lame-paint-metrics", &nsBlockFrame::gLamePaintMetrics },
|
|
|
|
{ "lame-reflow-metrics", &nsBlockFrame::gLameReflowMetrics },
|
|
|
|
{ "disable-resize-opt", &nsBlockFrame::gDisableResizeOpt },
|
1999-10-15 23:35:10 +00:00
|
|
|
};
|
|
|
|
#define NUM_DEBUG_FLAGS (sizeof(gFlags) / sizeof(gFlags[0]))
|
|
|
|
|
|
|
|
static void
|
|
|
|
ShowDebugFlags()
|
|
|
|
{
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("Here are the available GECKO_BLOCK_DEBUG_FLAGS:\n");
|
2004-01-21 23:08:51 +00:00
|
|
|
const BlockDebugFlags* bdf = gFlags;
|
|
|
|
const BlockDebugFlags* end = gFlags + NUM_DEBUG_FLAGS;
|
1999-10-15 23:35:10 +00:00
|
|
|
for (; bdf < end; bdf++) {
|
2000-10-28 22:17:53 +00:00
|
|
|
printf(" %s\n", bdf->name);
|
1999-10-15 23:35:10 +00:00
|
|
|
}
|
2003-03-24 04:15:34 +00:00
|
|
|
printf("Note: GECKO_BLOCK_DEBUG_FLAGS is a comma separated list of flag\n");
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("names (no whitespace)\n");
|
1999-10-15 23:35:10 +00:00
|
|
|
}
|
|
|
|
|
2001-05-01 04:22:57 +00:00
|
|
|
void
|
|
|
|
nsBlockFrame::InitDebugFlags()
|
1999-10-15 23:35:10 +00:00
|
|
|
{
|
|
|
|
static PRBool firstTime = PR_TRUE;
|
|
|
|
if (firstTime) {
|
|
|
|
firstTime = PR_FALSE;
|
|
|
|
char* flags = PR_GetEnv("GECKO_BLOCK_DEBUG_FLAGS");
|
|
|
|
if (flags) {
|
|
|
|
PRBool error = PR_FALSE;
|
|
|
|
for (;;) {
|
|
|
|
char* cm = PL_strchr(flags, ',');
|
|
|
|
if (cm) *cm = '\0';
|
|
|
|
|
|
|
|
PRBool found = PR_FALSE;
|
2004-01-21 23:08:51 +00:00
|
|
|
const BlockDebugFlags* bdf = gFlags;
|
|
|
|
const BlockDebugFlags* end = gFlags + NUM_DEBUG_FLAGS;
|
1999-10-15 23:35:10 +00:00
|
|
|
for (; bdf < end; bdf++) {
|
|
|
|
if (PL_strcasecmp(bdf->name, flags) == 0) {
|
|
|
|
*(bdf->on) = PR_TRUE;
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("nsBlockFrame: setting %s debug flag on\n", bdf->name);
|
1999-10-15 23:35:10 +00:00
|
|
|
gNoisy = PR_TRUE;
|
|
|
|
found = PR_TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found) {
|
|
|
|
error = PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!cm) break;
|
|
|
|
*cm = ',';
|
|
|
|
flags = cm + 1;
|
|
|
|
}
|
|
|
|
if (error) {
|
|
|
|
ShowDebugFlags();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-11-05 19:33:01 +00:00
|
|
|
#endif
|
|
|
|
|
2000-06-14 23:15:59 +00:00
|
|
|
// add in a sanity check for absurdly deep frame trees. See bug 42138
|
|
|
|
// can't just use IsFrameTreeTooDeep() because that method has side effects we don't want
|
|
|
|
#define MAX_DEPTH_FOR_LIST_RENUMBERING 200 // 200 open displayable tags is pretty unrealistic
|
2000-06-11 22:14:33 +00:00
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
//----------------------------------------------------------------------
|
1998-09-23 20:10:40 +00:00
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
// Debugging support code
|
|
|
|
|
1999-10-15 23:35:10 +00:00
|
|
|
#ifdef DEBUG
|
2001-12-17 22:39:59 +00:00
|
|
|
const char* nsBlockFrame::kReflowCommandType[] = {
|
1998-12-05 16:02:08 +00:00
|
|
|
"ContentChanged",
|
|
|
|
"StyleChanged",
|
1999-03-05 04:21:32 +00:00
|
|
|
"ReflowDirty",
|
2001-12-17 22:39:59 +00:00
|
|
|
"Timeout",
|
1998-12-05 16:02:08 +00:00
|
|
|
"UserDefined",
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef REALLY_NOISY_FIRST_LINE
|
|
|
|
static void
|
|
|
|
DumpStyleGeneaology(nsIFrame* aFrame, const char* gap)
|
|
|
|
{
|
|
|
|
fputs(gap, stdout);
|
1999-03-05 04:21:32 +00:00
|
|
|
nsFrame::ListTag(stdout, aFrame);
|
2000-10-28 22:17:53 +00:00
|
|
|
printf(": ");
|
2003-02-22 00:32:13 +00:00
|
|
|
nsStyleContext* sc = aFrame->GetStyleContext();
|
1998-12-05 16:02:08 +00:00
|
|
|
while (nsnull != sc) {
|
2003-02-22 00:32:13 +00:00
|
|
|
nsStyleContext* psc;
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("%p ", sc);
|
1998-12-05 16:02:08 +00:00
|
|
|
psc = sc->GetParent();
|
|
|
|
sc = psc;
|
|
|
|
}
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("\n");
|
1998-12-05 16:02:08 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef REFLOW_STATUS_COVERAGE
|
|
|
|
static void
|
1999-02-09 17:31:33 +00:00
|
|
|
RecordReflowStatus(PRBool aChildIsBlock, nsReflowStatus aFrameReflowStatus)
|
1998-12-05 16:02:08 +00:00
|
|
|
{
|
1999-02-09 17:31:33 +00:00
|
|
|
static PRUint32 record[2];
|
1998-12-05 16:02:08 +00:00
|
|
|
|
1999-02-09 17:31:33 +00:00
|
|
|
// 0: child-is-block
|
|
|
|
// 1: child-is-inline
|
1998-12-05 16:02:08 +00:00
|
|
|
PRIntn index = 0;
|
|
|
|
if (!aChildIsBlock) index |= 1;
|
|
|
|
|
|
|
|
// Compute new status
|
|
|
|
PRUint32 newS = record[index];
|
|
|
|
if (NS_INLINE_IS_BREAK(aFrameReflowStatus)) {
|
|
|
|
if (NS_INLINE_IS_BREAK_BEFORE(aFrameReflowStatus)) {
|
|
|
|
newS |= 1;
|
|
|
|
}
|
|
|
|
else if (NS_FRAME_IS_NOT_COMPLETE(aFrameReflowStatus)) {
|
|
|
|
newS |= 2;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
newS |= 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (NS_FRAME_IS_NOT_COMPLETE(aFrameReflowStatus)) {
|
|
|
|
newS |= 8;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
newS |= 16;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Log updates to the status that yield different values
|
|
|
|
if (record[index] != newS) {
|
|
|
|
record[index] = newS;
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("record(%d): %02x %02x\n", index, record[0], record[1]);
|
1998-12-05 16:02:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-03-29 01:46:55 +00:00
|
|
|
// Destructor function for the overflowLines frame property
|
|
|
|
static void
|
|
|
|
DestroyOverflowLines(void* aPropertyValue)
|
|
|
|
{
|
|
|
|
NS_ERROR("Overflow lines should never be destroyed by the FramePropertyTable");
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_DECLARE_FRAME_PROPERTY(LineCursorProperty, nsnull)
|
|
|
|
NS_DECLARE_FRAME_PROPERTY(OverflowLinesProperty, DestroyOverflowLines)
|
|
|
|
NS_DECLARE_FRAME_PROPERTY(OverflowOutOfFlowsProperty,
|
|
|
|
nsContainerFrame::DestroyFrameList)
|
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2005-11-04 02:38:33 +00:00
|
|
|
nsIFrame*
|
2006-03-26 21:30:36 +00:00
|
|
|
NS_NewBlockFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, PRUint32 aFlags)
|
1999-02-09 17:31:33 +00:00
|
|
|
{
|
2006-03-26 21:30:36 +00:00
|
|
|
nsBlockFrame* it = new (aPresShell) nsBlockFrame(aContext);
|
2005-11-04 02:38:33 +00:00
|
|
|
if (it) {
|
|
|
|
it->SetFlags(aFlags);
|
1999-02-09 17:31:33 +00:00
|
|
|
}
|
2005-11-04 02:38:33 +00:00
|
|
|
return it;
|
1999-02-09 17:31:33 +00:00
|
|
|
}
|
|
|
|
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsBlockFrame)
|
|
|
|
|
1999-02-09 17:31:33 +00:00
|
|
|
nsBlockFrame::~nsBlockFrame()
|
1998-09-23 20:10:40 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-04-10 00:16:29 +00:00
|
|
|
void
|
2009-12-24 05:21:15 +00:00
|
|
|
nsBlockFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
1998-09-23 20:10:40 +00:00
|
|
|
{
|
2011-04-29 23:02:33 +00:00
|
|
|
DestroyAbsoluteFrames(aDestructRoot);
|
1999-02-18 22:22:55 +00:00
|
|
|
// Outside bullets are not in our child-list so check for them here
|
|
|
|
// and delete them when present.
|
2001-03-14 06:45:41 +00:00
|
|
|
if (mBullet && HaveOutsideBullet()) {
|
2009-12-24 05:21:15 +00:00
|
|
|
mBullet->DestroyFrom(aDestructRoot);
|
1999-02-09 17:31:33 +00:00
|
|
|
mBullet = nsnull;
|
|
|
|
}
|
|
|
|
|
2009-12-24 05:21:15 +00:00
|
|
|
mFloats.DestroyFramesFrom(aDestructRoot);
|
2008-01-30 18:12:38 +00:00
|
|
|
|
2007-03-30 21:11:41 +00:00
|
|
|
nsPresContext* presContext = PresContext();
|
1999-06-15 06:16:29 +00:00
|
|
|
|
2009-12-24 05:21:15 +00:00
|
|
|
nsLineBox::DeleteLineList(presContext, mLines, aDestructRoot);
|
2009-09-29 19:47:05 +00:00
|
|
|
// Now clear mFrames, since we've destroyed all the frames in it.
|
|
|
|
mFrames.Clear();
|
1999-02-10 18:12:24 +00:00
|
|
|
|
2010-08-19 13:38:00 +00:00
|
|
|
nsFrameList* pushedFloats = RemovePushedFloats();
|
|
|
|
if (pushedFloats) {
|
|
|
|
pushedFloats->DestroyFrom(aDestructRoot);
|
|
|
|
}
|
|
|
|
|
2003-06-02 04:03:07 +00:00
|
|
|
// destroy overflow lines now
|
2004-06-01 06:20:16 +00:00
|
|
|
nsLineList* overflowLines = RemoveOverflowLines();
|
2003-06-02 04:03:07 +00:00
|
|
|
if (overflowLines) {
|
2009-12-24 05:21:15 +00:00
|
|
|
nsLineBox::DeleteLineList(presContext, *overflowLines, aDestructRoot);
|
2009-09-29 01:23:33 +00:00
|
|
|
delete overflowLines;
|
2003-06-02 04:03:07 +00:00
|
|
|
}
|
2005-03-23 03:35:08 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
nsAutoOOFFrameList oofs(this);
|
2009-12-24 05:21:15 +00:00
|
|
|
oofs.mList.DestroyFramesFrom(aDestructRoot);
|
2005-03-23 03:35:08 +00:00
|
|
|
// oofs is now empty and will remove the frame list property
|
2004-05-05 02:30:33 +00:00
|
|
|
}
|
2003-06-02 04:03:07 +00:00
|
|
|
|
2009-12-24 05:21:15 +00:00
|
|
|
nsBlockFrameSuper::DestroyFrom(aDestructRoot);
|
1998-12-05 16:02:08 +00:00
|
|
|
}
|
1998-09-26 20:05:09 +00:00
|
|
|
|
2008-10-30 19:17:59 +00:00
|
|
|
/* virtual */ nsILineIterator*
|
|
|
|
nsBlockFrame::GetLineIterator()
|
|
|
|
{
|
|
|
|
nsLineIterator* it = new nsLineIterator;
|
|
|
|
if (!it)
|
|
|
|
return nsnull;
|
|
|
|
|
|
|
|
const nsStyleVisibility* visibility = GetStyleVisibility();
|
|
|
|
nsresult rv = it->Init(mLines, visibility->mDirection == NS_STYLE_DIRECTION_RTL);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
delete it;
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
return it;
|
|
|
|
}
|
|
|
|
|
2009-01-12 19:20:59 +00:00
|
|
|
NS_QUERYFRAME_HEAD(nsBlockFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsBlockFrame)
|
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsBlockFrameSuper)
|
1998-09-23 20:10:40 +00:00
|
|
|
|
2006-12-20 03:52:34 +00:00
|
|
|
nsSplittableType
|
|
|
|
nsBlockFrame::GetSplittableType() const
|
1998-09-23 20:10:40 +00:00
|
|
|
{
|
2006-12-20 03:52:34 +00:00
|
|
|
return NS_FRAME_SPLITTABLE_NON_RECTANGULAR;
|
1998-09-23 20:10:40 +00:00
|
|
|
}
|
|
|
|
|
1999-11-01 22:12:45 +00:00
|
|
|
#ifdef DEBUG
|
1998-12-05 16:02:08 +00:00
|
|
|
NS_METHOD
|
2005-09-06 21:34:50 +00:00
|
|
|
nsBlockFrame::List(FILE* out, PRInt32 aIndent) const
|
1998-12-05 16:02:08 +00:00
|
|
|
{
|
1999-03-05 04:21:32 +00:00
|
|
|
IndentBy(out, aIndent);
|
1999-01-16 00:00:50 +00:00
|
|
|
ListTag(out);
|
2000-07-27 05:16:08 +00:00
|
|
|
#ifdef DEBUG_waterson
|
2000-10-28 22:17:53 +00:00
|
|
|
fprintf(out, " [parent=%p]", mParent);
|
2000-07-27 05:16:08 +00:00
|
|
|
#endif
|
2003-06-19 23:44:01 +00:00
|
|
|
if (HasView()) {
|
2007-07-08 07:08:04 +00:00
|
|
|
fprintf(out, " [view=%p]", static_cast<void*>(GetView()));
|
1999-01-16 00:00:50 +00:00
|
|
|
}
|
2009-09-18 11:09:36 +00:00
|
|
|
if (GetNextSibling()) {
|
|
|
|
fprintf(out, " next=%p", static_cast<void*>(GetNextSibling()));
|
1999-04-27 22:10:51 +00:00
|
|
|
}
|
1998-06-24 17:52:42 +00:00
|
|
|
|
1999-01-16 00:00:50 +00:00
|
|
|
// Output the flow linkage
|
2006-02-21 21:33:47 +00:00
|
|
|
if (nsnull != GetPrevInFlow()) {
|
2007-07-08 07:08:04 +00:00
|
|
|
fprintf(out, " prev-in-flow=%p", static_cast<void*>(GetPrevInFlow()));
|
1999-01-16 00:00:50 +00:00
|
|
|
}
|
2006-02-21 21:33:47 +00:00
|
|
|
if (nsnull != GetNextInFlow()) {
|
2007-07-08 07:08:04 +00:00
|
|
|
fprintf(out, " next-in-flow=%p", static_cast<void*>(GetNextInFlow()));
|
1999-01-16 00:00:50 +00:00
|
|
|
}
|
|
|
|
|
2010-03-29 01:46:55 +00:00
|
|
|
void* IBsibling = Properties().Get(IBSplitSpecialSibling());
|
2009-10-16 02:47:03 +00:00
|
|
|
if (IBsibling) {
|
|
|
|
fprintf(out, " IBSplitSpecialSibling=%p", IBsibling);
|
|
|
|
}
|
2010-03-29 01:46:55 +00:00
|
|
|
void* IBprevsibling = Properties().Get(IBSplitSpecialPrevSibling());
|
2009-10-16 02:47:03 +00:00
|
|
|
if (IBprevsibling) {
|
|
|
|
fprintf(out, " IBSplitSpecialPrevSibling=%p", IBprevsibling);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nsnull != mContent) {
|
|
|
|
fprintf(out, " [content=%p]", static_cast<void*>(mContent));
|
|
|
|
}
|
|
|
|
|
1999-01-16 00:00:50 +00:00
|
|
|
// Output the rect and state
|
1999-03-05 04:21:32 +00:00
|
|
|
fprintf(out, " {%d,%d,%d,%d}", mRect.x, mRect.y, mRect.width, mRect.height);
|
1999-01-16 00:00:50 +00:00
|
|
|
if (0 != mState) {
|
2010-06-10 18:26:57 +00:00
|
|
|
fprintf(out, " [state=%016llx]", mState);
|
1998-06-24 17:52:42 +00:00
|
|
|
}
|
2007-07-08 07:08:04 +00:00
|
|
|
nsBlockFrame* f = const_cast<nsBlockFrame*>(this);
|
2010-10-07 04:25:47 +00:00
|
|
|
if (f->HasOverflowAreas()) {
|
|
|
|
nsRect overflowArea = f->GetVisualOverflowRect();
|
|
|
|
fprintf(out, " [vis-overflow=%d,%d,%d,%d]", overflowArea.x, overflowArea.y,
|
|
|
|
overflowArea.width, overflowArea.height);
|
|
|
|
overflowArea = f->GetScrollableOverflowRect();
|
|
|
|
fprintf(out, " [scr-overflow=%d,%d,%d,%d]", overflowArea.x, overflowArea.y,
|
2008-02-20 07:08:55 +00:00
|
|
|
overflowArea.width, overflowArea.height);
|
2004-07-27 18:22:14 +00:00
|
|
|
}
|
1999-09-01 01:02:16 +00:00
|
|
|
PRInt32 numInlineLines = 0;
|
|
|
|
PRInt32 numBlockLines = 0;
|
2008-10-12 22:33:20 +00:00
|
|
|
if (!mLines.empty()) {
|
|
|
|
const_line_iterator line = begin_lines(), line_end = end_lines();
|
|
|
|
for ( ; line != line_end; ++line) {
|
2001-10-25 01:08:40 +00:00
|
|
|
if (line->IsBlock())
|
1999-09-01 01:02:16 +00:00
|
|
|
numBlockLines++;
|
2001-10-25 01:08:40 +00:00
|
|
|
else
|
1999-09-01 01:02:16 +00:00
|
|
|
numInlineLines++;
|
|
|
|
}
|
|
|
|
}
|
2004-11-11 17:48:09 +00:00
|
|
|
fprintf(out, " sc=%p(i=%d,b=%d)",
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<void*>(mStyleContext), numInlineLines, numBlockLines);
|
2009-10-29 21:17:56 +00:00
|
|
|
nsIAtom* pseudoTag = mStyleContext->GetPseudo();
|
2004-11-11 17:48:09 +00:00
|
|
|
if (pseudoTag) {
|
|
|
|
nsAutoString atomString;
|
|
|
|
pseudoTag->ToString(atomString);
|
|
|
|
fprintf(out, " pst=%s",
|
2006-02-03 14:18:39 +00:00
|
|
|
NS_LossyConvertUTF16toASCII(atomString).get());
|
2004-11-11 17:48:09 +00:00
|
|
|
}
|
|
|
|
fputs("<\n", out);
|
|
|
|
|
1999-01-16 00:00:50 +00:00
|
|
|
aIndent++;
|
1998-06-24 17:52:42 +00:00
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
// Output the lines
|
2008-10-12 22:33:20 +00:00
|
|
|
if (!mLines.empty()) {
|
|
|
|
const_line_iterator line = begin_lines(), line_end = end_lines();
|
|
|
|
for ( ; line != line_end; ++line) {
|
2005-09-06 21:34:50 +00:00
|
|
|
line->List(out, aIndent);
|
1998-06-24 17:52:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-12 22:33:20 +00:00
|
|
|
// Output the overflow lines.
|
|
|
|
const nsLineList* overflowLines = GetOverflowLines();
|
|
|
|
if (overflowLines && !overflowLines->empty()) {
|
|
|
|
IndentBy(out, aIndent);
|
|
|
|
fputs("Overflow-lines<\n", out);
|
2009-01-08 21:17:53 +00:00
|
|
|
const_line_iterator line = overflowLines->begin(),
|
|
|
|
line_end = overflowLines->end();
|
2008-10-12 22:33:20 +00:00
|
|
|
for ( ; line != line_end; ++line) {
|
|
|
|
line->List(out, aIndent + 1);
|
|
|
|
}
|
|
|
|
IndentBy(out, aIndent);
|
|
|
|
fputs(">\n", out);
|
|
|
|
}
|
|
|
|
|
1999-01-16 00:19:10 +00:00
|
|
|
nsIAtom* listName = nsnull;
|
|
|
|
PRInt32 listIndex = 0;
|
|
|
|
for (;;) {
|
2004-01-09 14:20:53 +00:00
|
|
|
listName = GetAdditionalChildListName(listIndex++);
|
2008-10-12 22:33:20 +00:00
|
|
|
if (nsGkAtoms::overflowList == listName) {
|
|
|
|
continue; // skip the overflow list - we printed the overflow lines above
|
|
|
|
}
|
1999-01-16 00:19:10 +00:00
|
|
|
if (nsnull == listName) {
|
|
|
|
break;
|
|
|
|
}
|
2004-01-09 14:20:53 +00:00
|
|
|
nsIFrame* kid = GetFirstChild(listName);
|
2003-06-26 11:30:17 +00:00
|
|
|
if (kid) {
|
1999-01-16 00:19:10 +00:00
|
|
|
IndentBy(out, aIndent);
|
|
|
|
nsAutoString tmp;
|
|
|
|
if (nsnull != listName) {
|
|
|
|
listName->ToString(tmp);
|
2006-02-03 14:18:39 +00:00
|
|
|
fputs(NS_LossyConvertUTF16toASCII(tmp).get(), out);
|
1999-01-16 00:19:10 +00:00
|
|
|
}
|
|
|
|
fputs("<\n", out);
|
2003-06-26 11:30:17 +00:00
|
|
|
while (kid) {
|
2009-08-20 21:52:48 +00:00
|
|
|
kid->List(out, aIndent + 1);
|
2003-06-26 11:30:17 +00:00
|
|
|
kid = kid->GetNextSibling();
|
1999-01-16 00:19:10 +00:00
|
|
|
}
|
|
|
|
IndentBy(out, aIndent);
|
|
|
|
fputs(">\n", out);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-01-16 00:00:50 +00:00
|
|
|
aIndent--;
|
1999-03-05 04:21:32 +00:00
|
|
|
IndentBy(out, aIndent);
|
1999-01-16 00:00:50 +00:00
|
|
|
fputs(">\n", out);
|
1998-06-30 23:51:26 +00:00
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-06-30 23:51:26 +00:00
|
|
|
|
2004-04-04 01:48:16 +00:00
|
|
|
NS_IMETHODIMP_(nsFrameState)
|
|
|
|
nsBlockFrame::GetDebugStateBits() const
|
|
|
|
{
|
|
|
|
// We don't want to include our cursor flag in the bits the
|
|
|
|
// regression tester looks at
|
|
|
|
return nsBlockFrameSuper::GetDebugStateBits() & ~NS_BLOCK_HAS_LINE_CURSOR;
|
|
|
|
}
|
|
|
|
|
1999-02-09 17:31:33 +00:00
|
|
|
NS_IMETHODIMP
|
2001-11-14 01:33:42 +00:00
|
|
|
nsBlockFrame::GetFrameName(nsAString& aResult) const
|
1999-02-09 17:31:33 +00:00
|
|
|
{
|
2001-11-14 01:33:42 +00:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("Block"), aResult);
|
1999-02-09 17:31:33 +00:00
|
|
|
}
|
1999-11-01 22:12:45 +00:00
|
|
|
#endif
|
1999-02-09 17:31:33 +00:00
|
|
|
|
2003-10-31 20:19:18 +00:00
|
|
|
nsIAtom*
|
|
|
|
nsBlockFrame::GetType() const
|
1999-02-12 17:45:58 +00:00
|
|
|
{
|
2006-12-26 17:47:52 +00:00
|
|
|
return nsGkAtoms::blockFrame;
|
1999-02-12 17:45:58 +00:00
|
|
|
}
|
|
|
|
|
2006-06-08 01:11:43 +00:00
|
|
|
void
|
|
|
|
nsBlockFrame::InvalidateInternal(const nsRect& aDamageRect,
|
|
|
|
nscoord aX, nscoord aY, nsIFrame* aForChild,
|
2008-09-18 09:47:21 +00:00
|
|
|
PRUint32 aFlags)
|
2006-06-08 01:11:43 +00:00
|
|
|
{
|
|
|
|
// Optimize by suppressing invalidation of areas that are clipped out
|
2010-09-02 18:07:37 +00:00
|
|
|
// with CSS 'clip'. Don't suppress invalidation of *this* frame directly,
|
|
|
|
// because when 'clip' shrinks we need to invalidate this frame and
|
|
|
|
// be able to invalidate areas outside the 'clip'.
|
|
|
|
if (aForChild) {
|
|
|
|
const nsStyleDisplay* disp = GetStyleDisplay();
|
|
|
|
nsRect absPosClipRect;
|
|
|
|
if (GetAbsPosClipRect(disp, &absPosClipRect, GetSize())) {
|
|
|
|
// Restrict the invalidated area to abs-pos clip rect
|
|
|
|
// abs-pos clipping clips everything in the frame
|
|
|
|
nsRect r;
|
|
|
|
if (r.IntersectRect(aDamageRect, absPosClipRect - nsPoint(aX, aY))) {
|
|
|
|
nsBlockFrameSuper::InvalidateInternal(r, aX, aY, this, aFlags);
|
|
|
|
}
|
|
|
|
return;
|
2006-06-08 01:11:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-18 09:47:21 +00:00
|
|
|
nsBlockFrameSuper::InvalidateInternal(aDamageRect, aX, aY, this, aFlags);
|
2006-06-08 01:11:43 +00:00
|
|
|
}
|
|
|
|
|
2007-01-23 04:06:56 +00:00
|
|
|
nscoord
|
|
|
|
nsBlockFrame::GetBaseline() const
|
|
|
|
{
|
|
|
|
nscoord result;
|
|
|
|
if (nsLayoutUtils::GetLastLineBaseline(this, &result))
|
|
|
|
return result;
|
|
|
|
return nsFrame::GetBaseline();
|
|
|
|
}
|
|
|
|
|
2010-08-31 18:54:44 +00:00
|
|
|
nscoord
|
|
|
|
nsBlockFrame::GetCaretBaseline() const
|
|
|
|
{
|
|
|
|
nsRect contentRect = GetContentRect();
|
|
|
|
nsMargin bp = GetUsedBorderAndPadding();
|
|
|
|
|
|
|
|
if (!mLines.empty()) {
|
|
|
|
const_line_iterator line = begin_lines();
|
|
|
|
const nsLineBox* firstLine = line;
|
|
|
|
if (firstLine->GetChildCount()) {
|
|
|
|
return bp.top + firstLine->mFirstChild->GetCaretBaseline();
|
|
|
|
}
|
|
|
|
}
|
2011-04-08 01:05:49 +00:00
|
|
|
nsRefPtr<nsFontMetrics> fm;
|
2010-08-31 18:54:44 +00:00
|
|
|
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm));
|
|
|
|
return nsLayoutUtils::GetCenteredFontBaseline(fm, nsHTMLReflowState::
|
|
|
|
CalcLineHeight(GetStyleContext(), contentRect.height)) +
|
|
|
|
bp.top;
|
|
|
|
}
|
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Child frame enumeration
|
1998-08-03 17:07:44 +00:00
|
|
|
|
2009-07-28 12:51:09 +00:00
|
|
|
nsFrameList
|
|
|
|
nsBlockFrame::GetChildList(nsIAtom* aListName) const
|
1998-12-05 16:02:08 +00:00
|
|
|
{
|
2011-04-29 23:02:33 +00:00
|
|
|
if (nsnull == aListName) {
|
2009-09-29 19:47:05 +00:00
|
|
|
return mFrames;
|
1998-08-03 17:07:44 +00:00
|
|
|
}
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (aListName == nsGkAtoms::overflowList) {
|
2009-09-29 19:47:05 +00:00
|
|
|
// XXXbz once we start using nsFrameList for our overflow list, we
|
|
|
|
// could switch GetChildList to returning a |const nsFrameList&|.
|
2004-06-01 06:20:16 +00:00
|
|
|
nsLineList* overflowLines = GetOverflowLines();
|
2009-09-18 11:09:36 +00:00
|
|
|
return overflowLines ? nsFrameList(overflowLines->front()->mFirstChild,
|
|
|
|
overflowLines->back()->LastChild())
|
|
|
|
: nsFrameList::EmptyList();
|
2000-01-22 01:16:50 +00:00
|
|
|
}
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (aListName == nsGkAtoms::overflowOutOfFlowList) {
|
2009-09-24 02:39:21 +00:00
|
|
|
const nsFrameList* list = GetOverflowOutOfFlows();
|
|
|
|
return list ? *list : nsFrameList::EmptyList();
|
2004-05-05 02:30:33 +00:00
|
|
|
}
|
2010-08-19 13:37:59 +00:00
|
|
|
else if (aListName == nsGkAtoms::pushedFloatsList) {
|
2010-08-06 04:59:20 +00:00
|
|
|
const nsFrameList* list = GetPushedFloats();
|
2010-08-06 04:59:19 +00:00
|
|
|
return list ? *list : nsFrameList::EmptyList();
|
|
|
|
}
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (aListName == nsGkAtoms::floatList) {
|
2009-07-28 12:51:09 +00:00
|
|
|
return mFloats;
|
1999-02-09 17:31:33 +00:00
|
|
|
}
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (aListName == nsGkAtoms::bulletList) {
|
2009-09-18 11:09:36 +00:00
|
|
|
return HaveOutsideBullet() ? nsFrameList(mBullet, mBullet)
|
|
|
|
: nsFrameList::EmptyList();
|
1999-02-09 17:31:33 +00:00
|
|
|
}
|
2009-07-28 12:51:09 +00:00
|
|
|
return nsContainerFrame::GetChildList(aListName);
|
1998-12-05 16:02:08 +00:00
|
|
|
}
|
1998-08-03 17:07:44 +00:00
|
|
|
|
2007-07-26 04:03:29 +00:00
|
|
|
#define NS_BLOCK_FRAME_OVERFLOW_OOF_LIST_INDEX (NS_CONTAINER_LIST_COUNT_INCL_OC + 0)
|
|
|
|
#define NS_BLOCK_FRAME_FLOAT_LIST_INDEX (NS_CONTAINER_LIST_COUNT_INCL_OC + 1)
|
|
|
|
#define NS_BLOCK_FRAME_BULLET_LIST_INDEX (NS_CONTAINER_LIST_COUNT_INCL_OC + 2)
|
2011-04-29 23:02:33 +00:00
|
|
|
#define NS_BLOCK_FRAME_PUSHED_FLOATS_LIST_INDEX (NS_CONTAINER_LIST_COUNT_INCL_OC + 3)
|
2007-07-26 04:03:29 +00:00
|
|
|
// If adding/removing lists, don't forget to update the count in nsBlockFrame.h
|
|
|
|
|
2004-01-09 14:20:53 +00:00
|
|
|
nsIAtom*
|
|
|
|
nsBlockFrame::GetAdditionalChildListName(PRInt32 aIndex) const
|
1999-02-09 17:31:33 +00:00
|
|
|
{
|
2007-07-26 04:03:29 +00:00
|
|
|
if (aIndex < NS_CONTAINER_LIST_COUNT_INCL_OC)
|
|
|
|
return nsContainerFrame::GetAdditionalChildListName(aIndex);
|
|
|
|
|
1999-02-09 17:31:33 +00:00
|
|
|
switch (aIndex) {
|
2003-10-13 21:51:02 +00:00
|
|
|
case NS_BLOCK_FRAME_FLOAT_LIST_INDEX:
|
2006-12-26 17:47:52 +00:00
|
|
|
return nsGkAtoms::floatList;
|
1999-02-09 17:31:33 +00:00
|
|
|
case NS_BLOCK_FRAME_BULLET_LIST_INDEX:
|
2006-12-26 17:47:52 +00:00
|
|
|
return nsGkAtoms::bulletList;
|
2004-05-05 02:30:33 +00:00
|
|
|
case NS_BLOCK_FRAME_OVERFLOW_OOF_LIST_INDEX:
|
2006-12-26 17:47:52 +00:00
|
|
|
return nsGkAtoms::overflowOutOfFlowList;
|
2010-08-06 04:59:20 +00:00
|
|
|
case NS_BLOCK_FRAME_PUSHED_FLOATS_LIST_INDEX:
|
2010-08-19 13:37:59 +00:00
|
|
|
return nsGkAtoms::pushedFloatsList;
|
2004-01-09 14:20:53 +00:00
|
|
|
default:
|
|
|
|
return nsnull;
|
1999-02-09 17:31:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-12 04:40:17 +00:00
|
|
|
/* virtual */ PRBool
|
|
|
|
nsBlockFrame::IsContainingBlock() const
|
1999-02-09 17:31:33 +00:00
|
|
|
{
|
2008-06-05 23:06:34 +00:00
|
|
|
// The block wrappers we use to wrap blocks inside inlines aren't
|
|
|
|
// described in the CSS spec. We need to make them not be containing
|
|
|
|
// blocks for the cases where we care about the 'direction' property
|
|
|
|
// of an element's containing block.
|
|
|
|
// Since the parent of such a block is either a normal block or
|
|
|
|
// another such pseudo, this shouldn't cause anything bad to happen.
|
2010-03-03 23:53:18 +00:00
|
|
|
// Also the anonymous blocks inside table cells are not containing blocks.
|
2009-10-29 21:17:56 +00:00
|
|
|
nsIAtom *pseudoType = GetStyleContext()->GetPseudo();
|
2008-06-05 23:06:34 +00:00
|
|
|
return pseudoType != nsCSSAnonBoxes::mozAnonymousBlock &&
|
2010-03-03 23:53:18 +00:00
|
|
|
pseudoType != nsCSSAnonBoxes::mozAnonymousPositionedBlock &&
|
|
|
|
pseudoType != nsCSSAnonBoxes::cellContent;
|
1999-02-09 17:31:33 +00:00
|
|
|
}
|
|
|
|
|
2005-03-18 04:13:05 +00:00
|
|
|
/* virtual */ PRBool
|
|
|
|
nsBlockFrame::IsFloatContainingBlock() const
|
|
|
|
{
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
2005-03-23 03:35:08 +00:00
|
|
|
static void ReparentFrame(nsIFrame* aFrame, nsIFrame* aOldParent,
|
|
|
|
nsIFrame* aNewParent) {
|
|
|
|
NS_ASSERTION(aOldParent == aFrame->GetParent(),
|
2009-08-26 04:50:41 +00:00
|
|
|
"Parent not consistent with expectations");
|
2005-03-23 03:35:08 +00:00
|
|
|
|
|
|
|
aFrame->SetParent(aNewParent);
|
|
|
|
|
|
|
|
// When pushing and pulling frames we need to check for whether any
|
|
|
|
// views need to be reparented
|
2011-04-19 11:55:11 +00:00
|
|
|
nsContainerFrame::ReparentFrameView(aFrame->PresContext(), aFrame,
|
|
|
|
aOldParent, aNewParent);
|
2005-03-23 03:35:08 +00:00
|
|
|
}
|
|
|
|
|
1999-01-12 16:42:03 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// Frame structure methods
|
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// Reflow methods
|
1998-08-03 17:07:44 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
/* virtual */ void
|
|
|
|
nsBlockFrame::MarkIntrinsicWidthsDirty()
|
|
|
|
{
|
2007-09-05 06:41:35 +00:00
|
|
|
nsBlockFrame* dirtyBlock = static_cast<nsBlockFrame*>(GetFirstContinuation());
|
2007-07-23 21:40:10 +00:00
|
|
|
dirtyBlock->mMinWidth = NS_INTRINSIC_WIDTH_UNKNOWN;
|
|
|
|
dirtyBlock->mPrefWidth = NS_INTRINSIC_WIDTH_UNKNOWN;
|
2007-10-11 11:41:04 +00:00
|
|
|
if (!(GetStateBits() & NS_BLOCK_NEEDS_BIDI_RESOLUTION)) {
|
|
|
|
for (nsIFrame* frame = dirtyBlock; frame;
|
|
|
|
frame = frame->GetNextContinuation()) {
|
|
|
|
frame->AddStateBits(NS_BLOCK_NEEDS_BIDI_RESOLUTION);
|
|
|
|
}
|
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
|
|
|
nsBlockFrameSuper::MarkIntrinsicWidthsDirty();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nscoord
|
2011-04-08 01:04:40 +00:00
|
|
|
nsBlockFrame::GetMinWidth(nsRenderingContext *aRenderingContext)
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
{
|
2007-07-23 21:40:10 +00:00
|
|
|
nsIFrame* firstInFlow = GetFirstContinuation();
|
|
|
|
if (firstInFlow != this)
|
|
|
|
return firstInFlow->GetMinWidth(aRenderingContext);
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
DISPLAY_MIN_WIDTH(this, mMinWidth);
|
|
|
|
if (mMinWidth != NS_INTRINSIC_WIDTH_UNKNOWN)
|
|
|
|
return mMinWidth;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (gNoisyIntrinsic) {
|
|
|
|
IndentBy(stdout, gNoiseIndent);
|
|
|
|
ListTag(stdout);
|
|
|
|
printf(": GetMinWidth\n");
|
|
|
|
}
|
2008-01-29 07:40:05 +00:00
|
|
|
AutoNoisyIndenter indenter(gNoisyIntrinsic);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
#endif
|
|
|
|
|
2007-10-11 11:41:04 +00:00
|
|
|
if (GetStateBits() & NS_BLOCK_NEEDS_BIDI_RESOLUTION)
|
|
|
|
ResolveBidi();
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
InlineMinWidthData data;
|
2007-07-23 21:40:10 +00:00
|
|
|
for (nsBlockFrame* curFrame = this; curFrame;
|
2007-09-05 06:41:35 +00:00
|
|
|
curFrame = static_cast<nsBlockFrame*>(curFrame->GetNextContinuation())) {
|
2007-07-23 21:40:10 +00:00
|
|
|
for (line_iterator line = curFrame->begin_lines(), line_end = curFrame->end_lines();
|
|
|
|
line != line_end; ++line)
|
|
|
|
{
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
#ifdef DEBUG
|
2007-07-23 21:40:10 +00:00
|
|
|
if (gNoisyIntrinsic) {
|
|
|
|
IndentBy(stdout, gNoiseIndent);
|
|
|
|
printf("line (%s%s)\n",
|
|
|
|
line->IsBlock() ? "block" : "inline",
|
|
|
|
line->IsEmpty() ? ", empty" : "");
|
2007-06-21 22:32:47 +00:00
|
|
|
}
|
2007-07-23 21:40:10 +00:00
|
|
|
AutoNoisyIndenter lineindent(gNoisyIntrinsic);
|
|
|
|
#endif
|
|
|
|
if (line->IsBlock()) {
|
|
|
|
data.ForceBreak(aRenderingContext);
|
|
|
|
data.currentLine = nsLayoutUtils::IntrinsicForContainer(aRenderingContext,
|
|
|
|
line->mFirstChild, nsLayoutUtils::MIN_WIDTH);
|
|
|
|
data.ForceBreak(aRenderingContext);
|
|
|
|
} else {
|
2007-11-15 06:12:17 +00:00
|
|
|
if (!curFrame->GetPrevContinuation() &&
|
|
|
|
line == curFrame->begin_lines()) {
|
2010-08-31 16:05:12 +00:00
|
|
|
// Only add text-indent if it has no percentages; using a
|
|
|
|
// percentage basis of 0 unconditionally would give strange
|
|
|
|
// behavior for calc(10%-3px).
|
2007-07-23 21:40:10 +00:00
|
|
|
const nsStyleCoord &indent = GetStyleText()->mTextIndent;
|
2010-08-31 16:05:12 +00:00
|
|
|
if (indent.ConvertsToLength())
|
|
|
|
data.currentLine += nsRuleNode::ComputeCoordPercentCalc(indent, 0);
|
2007-07-23 21:40:10 +00:00
|
|
|
}
|
|
|
|
// XXX Bug NNNNNN Should probably handle percentage text-indent.
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
2007-12-13 00:24:32 +00:00
|
|
|
data.line = &line;
|
2009-02-10 09:23:05 +00:00
|
|
|
data.lineContainer = curFrame;
|
2007-07-23 21:40:10 +00:00
|
|
|
nsIFrame *kid = line->mFirstChild;
|
|
|
|
for (PRInt32 i = 0, i_end = line->GetChildCount(); i != i_end;
|
|
|
|
++i, kid = kid->GetNextSibling()) {
|
|
|
|
kid->AddInlineMinWidth(aRenderingContext, &data);
|
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
}
|
|
|
|
#ifdef DEBUG
|
2007-07-23 21:40:10 +00:00
|
|
|
if (gNoisyIntrinsic) {
|
|
|
|
IndentBy(stdout, gNoiseIndent);
|
|
|
|
printf("min: [prevLines=%d currentLine=%d]\n",
|
|
|
|
data.prevLines, data.currentLine);
|
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
#endif
|
2007-07-23 21:40:10 +00:00
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
}
|
2007-06-21 22:32:47 +00:00
|
|
|
data.ForceBreak(aRenderingContext);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
|
|
|
mMinWidth = data.prevLines;
|
|
|
|
return mMinWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nscoord
|
2011-04-08 01:04:40 +00:00
|
|
|
nsBlockFrame::GetPrefWidth(nsRenderingContext *aRenderingContext)
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
{
|
2007-07-23 21:40:10 +00:00
|
|
|
nsIFrame* firstInFlow = GetFirstContinuation();
|
|
|
|
if (firstInFlow != this)
|
|
|
|
return firstInFlow->GetPrefWidth(aRenderingContext);
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
DISPLAY_PREF_WIDTH(this, mPrefWidth);
|
2007-07-23 21:40:10 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
if (mPrefWidth != NS_INTRINSIC_WIDTH_UNKNOWN)
|
|
|
|
return mPrefWidth;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (gNoisyIntrinsic) {
|
|
|
|
IndentBy(stdout, gNoiseIndent);
|
|
|
|
ListTag(stdout);
|
|
|
|
printf(": GetPrefWidth\n");
|
|
|
|
}
|
2008-01-29 07:40:05 +00:00
|
|
|
AutoNoisyIndenter indenter(gNoisyIntrinsic);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
#endif
|
|
|
|
|
2007-10-11 11:41:04 +00:00
|
|
|
if (GetStateBits() & NS_BLOCK_NEEDS_BIDI_RESOLUTION)
|
|
|
|
ResolveBidi();
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
InlinePrefWidthData data;
|
2007-07-23 21:40:10 +00:00
|
|
|
for (nsBlockFrame* curFrame = this; curFrame;
|
2007-09-05 06:41:35 +00:00
|
|
|
curFrame = static_cast<nsBlockFrame*>(curFrame->GetNextContinuation())) {
|
2007-07-23 21:40:10 +00:00
|
|
|
for (line_iterator line = curFrame->begin_lines(), line_end = curFrame->end_lines();
|
|
|
|
line != line_end; ++line)
|
|
|
|
{
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
#ifdef DEBUG
|
2007-07-23 21:40:10 +00:00
|
|
|
if (gNoisyIntrinsic) {
|
|
|
|
IndentBy(stdout, gNoiseIndent);
|
|
|
|
printf("line (%s%s)\n",
|
|
|
|
line->IsBlock() ? "block" : "inline",
|
|
|
|
line->IsEmpty() ? ", empty" : "");
|
2007-06-21 22:32:47 +00:00
|
|
|
}
|
2007-07-23 21:40:10 +00:00
|
|
|
AutoNoisyIndenter lineindent(gNoisyIntrinsic);
|
|
|
|
#endif
|
|
|
|
if (line->IsBlock()) {
|
|
|
|
data.ForceBreak(aRenderingContext);
|
|
|
|
data.currentLine = nsLayoutUtils::IntrinsicForContainer(aRenderingContext,
|
|
|
|
line->mFirstChild, nsLayoutUtils::PREF_WIDTH);
|
|
|
|
data.ForceBreak(aRenderingContext);
|
|
|
|
} else {
|
2007-11-15 06:12:17 +00:00
|
|
|
if (!curFrame->GetPrevContinuation() &&
|
|
|
|
line == curFrame->begin_lines()) {
|
2010-08-31 16:05:12 +00:00
|
|
|
// Only add text-indent if it has no percentages; using a
|
|
|
|
// percentage basis of 0 unconditionally would give strange
|
|
|
|
// behavior for calc(10%-3px).
|
2007-07-23 21:40:10 +00:00
|
|
|
const nsStyleCoord &indent = GetStyleText()->mTextIndent;
|
2010-08-31 16:05:12 +00:00
|
|
|
if (indent.ConvertsToLength())
|
|
|
|
data.currentLine += nsRuleNode::ComputeCoordPercentCalc(indent, 0);
|
2007-07-23 21:40:10 +00:00
|
|
|
}
|
|
|
|
// XXX Bug NNNNNN Should probably handle percentage text-indent.
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
2007-12-13 00:24:32 +00:00
|
|
|
data.line = &line;
|
2009-02-10 09:23:05 +00:00
|
|
|
data.lineContainer = curFrame;
|
2007-07-23 21:40:10 +00:00
|
|
|
nsIFrame *kid = line->mFirstChild;
|
|
|
|
for (PRInt32 i = 0, i_end = line->GetChildCount(); i != i_end;
|
|
|
|
++i, kid = kid->GetNextSibling()) {
|
|
|
|
kid->AddInlinePrefWidth(aRenderingContext, &data);
|
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
}
|
|
|
|
#ifdef DEBUG
|
2007-07-23 21:40:10 +00:00
|
|
|
if (gNoisyIntrinsic) {
|
|
|
|
IndentBy(stdout, gNoiseIndent);
|
|
|
|
printf("pref: [prevLines=%d currentLine=%d]\n",
|
|
|
|
data.prevLines, data.currentLine);
|
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
#endif
|
2007-07-23 21:40:10 +00:00
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
}
|
2007-06-21 22:32:47 +00:00
|
|
|
data.ForceBreak(aRenderingContext);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
|
|
|
mPrefWidth = data.prevLines;
|
|
|
|
return mPrefWidth;
|
|
|
|
}
|
|
|
|
|
2007-10-12 08:30:54 +00:00
|
|
|
nsRect
|
|
|
|
nsBlockFrame::ComputeTightBounds(gfxContext* aContext) const
|
|
|
|
{
|
|
|
|
// be conservative
|
2011-04-23 05:16:41 +00:00
|
|
|
if (GetStyleContext()->HasTextDecorationLines()) {
|
2010-10-07 04:25:46 +00:00
|
|
|
return GetVisualOverflowRect();
|
2011-04-23 05:16:41 +00:00
|
|
|
}
|
2007-10-12 08:30:54 +00:00
|
|
|
return ComputeSimpleTightBounds(aContext);
|
|
|
|
}
|
|
|
|
|
2009-05-20 11:21:34 +00:00
|
|
|
static PRBool
|
|
|
|
AvailableSpaceShrunk(const nsRect& aOldAvailableSpace,
|
|
|
|
const nsRect& aNewAvailableSpace)
|
|
|
|
{
|
|
|
|
if (aNewAvailableSpace.width == 0) {
|
|
|
|
// Positions are not significant if the width is zero.
|
|
|
|
return aOldAvailableSpace.width != 0;
|
|
|
|
}
|
|
|
|
NS_ASSERTION(aOldAvailableSpace.x <= aNewAvailableSpace.x &&
|
|
|
|
aOldAvailableSpace.XMost() >= aNewAvailableSpace.XMost(),
|
|
|
|
"available space should never grow");
|
|
|
|
return aOldAvailableSpace.width != aNewAvailableSpace.width;
|
|
|
|
}
|
|
|
|
|
2005-02-08 02:15:26 +00:00
|
|
|
static nsSize
|
|
|
|
CalculateContainingBlockSizeForAbsolutes(const nsHTMLReflowState& aReflowState,
|
|
|
|
nsSize aFrameSize)
|
2000-05-09 05:06:16 +00:00
|
|
|
{
|
2005-02-08 02:15:26 +00:00
|
|
|
// The issue here is that for a 'height' of 'auto' the reflow state
|
|
|
|
// code won't know how to calculate the containing block height
|
2005-03-21 21:43:01 +00:00
|
|
|
// because it's calculated bottom up. So we use our own computed
|
2007-12-05 03:05:57 +00:00
|
|
|
// size as the dimensions.
|
2005-03-21 21:43:01 +00:00
|
|
|
nsIFrame* frame = aReflowState.frame;
|
2000-05-09 05:06:16 +00:00
|
|
|
|
2005-02-08 02:15:26 +00:00
|
|
|
nsSize cbSize(aFrameSize);
|
2000-05-09 05:06:16 +00:00
|
|
|
// Containing block is relative to the padding edge
|
2008-07-17 13:32:49 +00:00
|
|
|
const nsMargin& border =
|
|
|
|
aReflowState.mComputedBorderPadding - aReflowState.mComputedPadding;
|
|
|
|
cbSize.width -= border.LeftRight();
|
|
|
|
cbSize.height -= border.TopBottom();
|
2005-03-21 21:43:01 +00:00
|
|
|
|
2008-09-08 08:13:17 +00:00
|
|
|
if (frame->GetParent()->GetContent() == frame->GetContent() &&
|
|
|
|
frame->GetParent()->GetType() != nsGkAtoms::canvasFrame) {
|
|
|
|
// We are a wrapped frame for the content (and the wrapper is not the
|
|
|
|
// canvas frame, whose size is not meaningful here).
|
|
|
|
// Use the container's dimensions, if they have been precomputed.
|
2005-03-21 21:43:01 +00:00
|
|
|
// XXX This is a hack! We really should be waiting until the outermost
|
|
|
|
// frame is fully reflowed and using the resulting dimensions, even
|
|
|
|
// if they're intrinsic.
|
|
|
|
// In fact we should be attaching absolute children to the outermost
|
|
|
|
// frame and not always sticking them in block frames.
|
|
|
|
|
|
|
|
// First, find the reflow state for the outermost frame for this
|
|
|
|
// content.
|
|
|
|
const nsHTMLReflowState* aLastRS = &aReflowState;
|
2005-10-18 05:00:24 +00:00
|
|
|
const nsHTMLReflowState* lastButOneRS = &aReflowState;
|
2005-03-21 21:43:01 +00:00
|
|
|
while (aLastRS->parentReflowState &&
|
|
|
|
aLastRS->parentReflowState->frame->GetContent() == frame->GetContent()) {
|
2005-10-18 05:00:24 +00:00
|
|
|
lastButOneRS = aLastRS;
|
2005-03-21 21:43:01 +00:00
|
|
|
aLastRS = aLastRS->parentReflowState;
|
|
|
|
}
|
|
|
|
if (aLastRS != &aReflowState) {
|
2005-10-18 05:00:24 +00:00
|
|
|
// Scrollbars need to be specifically excluded, if present, because they are outside the
|
|
|
|
// padding-edge. We need better APIs for getting the various boxes from a frame.
|
2009-01-12 19:20:59 +00:00
|
|
|
nsIScrollableFrame* scrollFrame = do_QueryFrame(aLastRS->frame);
|
2005-10-18 05:00:24 +00:00
|
|
|
nsMargin scrollbars(0,0,0,0);
|
|
|
|
if (scrollFrame) {
|
2008-04-10 04:39:41 +00:00
|
|
|
scrollbars =
|
|
|
|
scrollFrame->GetDesiredScrollbarSizes(aLastRS->frame->PresContext(),
|
|
|
|
aLastRS->rendContext);
|
2007-12-05 03:05:57 +00:00
|
|
|
if (!lastButOneRS->mFlags.mAssumingHScrollbar) {
|
2005-10-18 05:00:24 +00:00
|
|
|
scrollbars.top = scrollbars.bottom = 0;
|
2007-12-05 03:05:57 +00:00
|
|
|
}
|
2005-10-18 05:00:24 +00:00
|
|
|
if (!lastButOneRS->mFlags.mAssumingVScrollbar) {
|
|
|
|
scrollbars.left = scrollbars.right = 0;
|
|
|
|
}
|
|
|
|
}
|
2005-03-21 21:43:01 +00:00
|
|
|
// We found a reflow state for the outermost wrapping frame, so use
|
|
|
|
// its computed metrics if available
|
2008-09-08 08:13:17 +00:00
|
|
|
if (aLastRS->ComputedWidth() != NS_UNCONSTRAINEDSIZE) {
|
2009-09-16 15:01:36 +00:00
|
|
|
cbSize.width = NS_MAX(0,
|
2007-01-26 00:05:12 +00:00
|
|
|
aLastRS->ComputedWidth() + aLastRS->mComputedPadding.LeftRight() - scrollbars.LeftRight());
|
2005-03-21 21:43:01 +00:00
|
|
|
}
|
2007-08-02 18:08:05 +00:00
|
|
|
if (aLastRS->ComputedHeight() != NS_UNCONSTRAINEDSIZE) {
|
2009-09-16 15:01:36 +00:00
|
|
|
cbSize.height = NS_MAX(0,
|
2007-08-02 18:08:05 +00:00
|
|
|
aLastRS->ComputedHeight() + aLastRS->mComputedPadding.TopBottom() - scrollbars.TopBottom());
|
2005-03-21 21:43:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-02-08 02:15:26 +00:00
|
|
|
return cbSize;
|
2000-05-09 05:06:16 +00:00
|
|
|
}
|
|
|
|
|
2011-01-19 22:39:31 +00:00
|
|
|
static inline PRBool IsClippingChildren(nsIFrame* aFrame,
|
|
|
|
const nsHTMLReflowState& aReflowState)
|
|
|
|
{
|
|
|
|
return aReflowState.mStyleDisplay->mOverflowX == NS_STYLE_OVERFLOW_CLIP ||
|
|
|
|
nsFrame::ApplyPaginatedOverflowClipping(aFrame);
|
|
|
|
}
|
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
NS_IMETHODIMP
|
2007-07-26 04:03:29 +00:00
|
|
|
nsBlockFrame::Reflow(nsPresContext* aPresContext,
|
1999-03-05 04:21:32 +00:00
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-12-05 16:02:08 +00:00
|
|
|
{
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsBlockFrame");
|
2001-11-14 13:40:03 +00:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aMetrics, aStatus);
|
1999-10-15 23:35:10 +00:00
|
|
|
#ifdef DEBUG
|
1999-10-19 23:04:19 +00:00
|
|
|
if (gNoisyReflow) {
|
1999-10-15 23:35:10 +00:00
|
|
|
IndentBy(stdout, gNoiseIndent);
|
|
|
|
ListTag(stdout);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
printf(": begin reflow availSize=%d,%d computedSize=%d,%d\n",
|
2001-09-05 20:27:19 +00:00
|
|
|
aReflowState.availableWidth, aReflowState.availableHeight,
|
2007-08-02 18:08:05 +00:00
|
|
|
aReflowState.ComputedWidth(), aReflowState.ComputedHeight());
|
1999-10-19 23:04:19 +00:00
|
|
|
}
|
2005-03-23 03:35:08 +00:00
|
|
|
AutoNoisyIndenter indent(gNoisy);
|
2000-11-27 23:23:28 +00:00
|
|
|
PRTime start = LL_ZERO; // Initialize these variablies to silence the compiler.
|
|
|
|
PRInt32 ctc = 0; // We only use these if they are set (gLameReflowMetrics).
|
1999-10-19 23:04:19 +00:00
|
|
|
if (gLameReflowMetrics) {
|
|
|
|
start = PR_Now();
|
|
|
|
ctc = nsLineBox::GetCtorCount();
|
|
|
|
}
|
1999-10-15 23:35:10 +00:00
|
|
|
#endif
|
|
|
|
|
2011-01-19 22:39:31 +00:00
|
|
|
const nsHTMLReflowState *reflowState = &aReflowState;
|
|
|
|
nsAutoPtr<nsHTMLReflowState> mutableReflowState;
|
|
|
|
// If we have non-auto height, we're clipping our kids and we fit,
|
|
|
|
// make sure our kids fit too.
|
|
|
|
if (aReflowState.availableHeight != NS_UNCONSTRAINEDSIZE &&
|
|
|
|
aReflowState.ComputedHeight() != NS_AUTOHEIGHT &&
|
|
|
|
IsClippingChildren(this, aReflowState)) {
|
|
|
|
nsMargin heightExtras = aReflowState.mComputedBorderPadding;
|
|
|
|
if (GetSkipSides() & NS_SIDE_TOP) {
|
|
|
|
heightExtras.top = 0;
|
|
|
|
} else {
|
|
|
|
// Bottom margin never causes us to create continuations, so we
|
|
|
|
// don't need to worry about whether it fits in its entirety.
|
|
|
|
heightExtras.top += aReflowState.mComputedMargin.top;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GetEffectiveComputedHeight(aReflowState) + heightExtras.TopBottom() <=
|
|
|
|
aReflowState.availableHeight) {
|
|
|
|
mutableReflowState = new nsHTMLReflowState(aReflowState);
|
|
|
|
mutableReflowState->availableHeight = NS_UNCONSTRAINEDSIZE;
|
|
|
|
reflowState = mutableReflowState;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-05 02:57:53 +00:00
|
|
|
// See comment below about oldSize. Use *only* for the
|
|
|
|
// abs-pos-containing-block-size-change optimization!
|
2004-11-14 20:22:58 +00:00
|
|
|
nsSize oldSize = GetSize();
|
2002-06-12 03:21:00 +00:00
|
|
|
|
2009-01-05 00:39:54 +00:00
|
|
|
// Should we create a float manager?
|
2011-01-19 22:39:31 +00:00
|
|
|
nsAutoFloatManager autoFloatManager(const_cast<nsHTMLReflowState&>(*reflowState));
|
2002-05-03 13:49:44 +00:00
|
|
|
|
2009-01-05 00:39:54 +00:00
|
|
|
// XXXldb If we start storing the float manager in the frame rather
|
2002-04-18 23:37:51 +00:00
|
|
|
// than keeping it around only during reflow then we should create it
|
|
|
|
// only when there are actually floats to manage. Otherwise things
|
|
|
|
// like tables will gain significant bloat.
|
2009-01-05 00:39:54 +00:00
|
|
|
PRBool needFloatManager = nsBlockFrame::BlockNeedsFloatManager(this);
|
|
|
|
if (needFloatManager)
|
|
|
|
autoFloatManager.CreateFloatManager(aPresContext);
|
2002-04-18 23:37:51 +00:00
|
|
|
|
2010-10-07 04:25:45 +00:00
|
|
|
// OK, some lines may be reflowed. Blow away any saved line cursor
|
|
|
|
// because we may invalidate the nondecreasing
|
|
|
|
// overflowArea.VisualOverflow().y/yMost invariant, and we may even
|
|
|
|
// delete the line with the line cursor.
|
2004-03-07 18:04:24 +00:00
|
|
|
ClearLineCursor();
|
|
|
|
|
2011-01-19 22:39:31 +00:00
|
|
|
if (IsFrameTreeTooDeep(*reflowState, aMetrics, aStatus)) {
|
1999-08-27 21:45:37 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-02-18 23:53:25 +00:00
|
|
|
PRBool marginRoot = BlockIsMarginRoot(this);
|
2011-01-19 22:39:31 +00:00
|
|
|
nsBlockReflowState state(*reflowState, aPresContext, this, aMetrics,
|
2009-01-05 00:39:54 +00:00
|
|
|
marginRoot, marginRoot, needFloatManager);
|
1999-02-23 19:32:00 +00:00
|
|
|
|
2001-03-09 03:29:00 +00:00
|
|
|
#ifdef IBMBIDI
|
2007-10-11 11:41:04 +00:00
|
|
|
if (GetStateBits() & NS_BLOCK_NEEDS_BIDI_RESOLUTION)
|
|
|
|
static_cast<nsBlockFrame*>(GetFirstContinuation())->ResolveBidi();
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
#endif // IBMBIDI
|
|
|
|
|
2007-05-06 19:16:51 +00:00
|
|
|
if (RenumberLists(aPresContext)) {
|
|
|
|
AddStateBits(NS_FRAME_HAS_DIRTY_CHILDREN);
|
|
|
|
}
|
1999-03-05 19:25:44 +00:00
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
nsresult rv = NS_OK;
|
2001-05-03 20:11:50 +00:00
|
|
|
|
2004-08-26 12:38:50 +00:00
|
|
|
// ALWAYS drain overflow. We never want to leave the previnflow's
|
|
|
|
// overflow lines hanging around; block reflow depends on the
|
|
|
|
// overflow line lists being cleared out between reflow passes.
|
2005-03-23 03:35:08 +00:00
|
|
|
DrainOverflowLines(state);
|
2009-08-31 18:25:36 +00:00
|
|
|
|
2009-09-14 00:26:01 +00:00
|
|
|
// Handle paginated overflow (see nsContainerFrame.h)
|
2010-10-07 04:25:45 +00:00
|
|
|
nsOverflowAreas ocBounds;
|
2009-09-14 00:26:01 +00:00
|
|
|
nsReflowStatus ocStatus = NS_FRAME_COMPLETE;
|
|
|
|
if (GetPrevInFlow()) {
|
2011-01-19 22:39:31 +00:00
|
|
|
ReflowOverflowContainerChildren(aPresContext, *reflowState, ocBounds, 0,
|
2009-09-14 00:26:01 +00:00
|
|
|
ocStatus);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now that we're done cleaning up our overflow container lists, we can
|
|
|
|
// give |state| its nsOverflowContinuationTracker.
|
|
|
|
nsOverflowContinuationTracker tracker(aPresContext, this, PR_FALSE);
|
|
|
|
state.mOverflowTracker = &tracker;
|
|
|
|
|
2010-08-06 04:59:20 +00:00
|
|
|
// Drain & handle pushed floats
|
|
|
|
DrainPushedFloats(state);
|
2010-10-07 04:25:45 +00:00
|
|
|
nsOverflowAreas fcBounds;
|
2009-08-31 18:25:36 +00:00
|
|
|
nsReflowStatus fcStatus = NS_FRAME_COMPLETE;
|
2010-08-06 04:59:20 +00:00
|
|
|
rv = ReflowPushedFloats(state, fcBounds, fcStatus);
|
2009-08-31 18:25:36 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
// If we're not dirty (which means we'll mark everything dirty later)
|
|
|
|
// and our width has changed, mark the lines dirty that we need to
|
|
|
|
// mark dirty for a resize reflow.
|
2011-01-19 22:39:31 +00:00
|
|
|
if (reflowState->mFlags.mHResize)
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
PrepareResizeReflow(state);
|
1998-10-16 20:22:39 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
mState &= ~NS_FRAME_FIRST_REFLOW;
|
2000-02-22 22:06:19 +00:00
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
// Now reflow...
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
rv = ReflowDirtyLines(state);
|
2001-05-03 20:11:50 +00:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "reflow dirty lines failed");
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2009-06-29 03:56:13 +00:00
|
|
|
NS_MergeReflowStatusInto(&state.mReflowStatus, ocStatus);
|
2009-08-31 18:25:36 +00:00
|
|
|
NS_MergeReflowStatusInto(&state.mReflowStatus, fcStatus);
|
2007-07-26 04:03:29 +00:00
|
|
|
|
2009-08-31 18:25:36 +00:00
|
|
|
// If we end in a BR with clear and affected floats continue,
|
|
|
|
// we need to continue, too.
|
2011-01-19 22:39:31 +00:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != reflowState->availableHeight &&
|
2009-08-31 18:25:36 +00:00
|
|
|
NS_FRAME_IS_COMPLETE(state.mReflowStatus) &&
|
|
|
|
state.mFloatManager->ClearContinues(FindTrailingClear())) {
|
|
|
|
NS_FRAME_SET_INCOMPLETE(state.mReflowStatus);
|
|
|
|
}
|
|
|
|
|
2009-07-13 16:50:54 +00:00
|
|
|
if (!NS_FRAME_IS_FULLY_COMPLETE(state.mReflowStatus)) {
|
2010-08-06 04:59:20 +00:00
|
|
|
if (GetOverflowLines() || GetPushedFloats()) {
|
2004-10-08 12:17:10 +00:00
|
|
|
state.mReflowStatus |= NS_FRAME_REFLOW_NEXTINFLOW;
|
|
|
|
}
|
|
|
|
|
1999-03-05 19:25:44 +00:00
|
|
|
#ifdef DEBUG_kipp
|
2009-07-13 16:50:54 +00:00
|
|
|
ListTag(stdout); printf(": block is not fully complete\n");
|
1999-03-05 19:25:44 +00:00
|
|
|
#endif
|
2001-05-03 20:11:50 +00:00
|
|
|
}
|
2002-04-11 01:13:41 +00:00
|
|
|
|
2006-04-09 22:56:27 +00:00
|
|
|
CheckFloats(state);
|
2004-09-13 13:35:46 +00:00
|
|
|
|
2007-01-23 04:06:56 +00:00
|
|
|
// Place the "marker" (bullet) frame if it is placed next to a block
|
|
|
|
// child.
|
|
|
|
//
|
|
|
|
// According to the CSS2 spec, section 12.6.1, the "marker" box
|
|
|
|
// participates in the height calculation of the list-item box's
|
|
|
|
// first line box.
|
|
|
|
//
|
|
|
|
// There are exactly two places a bullet can be placed: near the
|
|
|
|
// first or second line. It's only placed on the second line in a
|
|
|
|
// rare case: an empty first line followed by a second line that
|
|
|
|
// contains a block (example: <LI>\n<P>... ). This is where
|
|
|
|
// the second case can happen.
|
2008-02-10 21:49:24 +00:00
|
|
|
if (mBullet && HaveOutsideBullet() && !mLines.empty() &&
|
|
|
|
(mLines.front()->IsBlock() ||
|
|
|
|
(0 == mLines.front()->mBounds.height &&
|
|
|
|
mLines.front() != mLines.back() &&
|
|
|
|
mLines.begin().next()->IsBlock()))) {
|
2007-01-23 04:06:56 +00:00
|
|
|
// Reflow the bullet
|
|
|
|
nsHTMLReflowMetrics metrics;
|
2009-04-08 20:52:36 +00:00
|
|
|
// XXX Use the entire line when we fix bug 25888.
|
|
|
|
nsLayoutUtils::LinePosition position;
|
|
|
|
PRBool havePosition = nsLayoutUtils::GetFirstLinePosition(this, &position);
|
|
|
|
nscoord lineTop = havePosition ? position.mTop
|
2011-01-19 22:39:31 +00:00
|
|
|
: reflowState->mComputedBorderPadding.top;
|
2009-04-08 20:52:36 +00:00
|
|
|
ReflowBullet(state, metrics, lineTop);
|
2009-09-11 10:46:36 +00:00
|
|
|
NS_ASSERTION(!BulletIsEmpty() || metrics.height == 0,
|
|
|
|
"empty bullet took up space");
|
2009-04-08 20:52:36 +00:00
|
|
|
|
2009-09-11 10:46:36 +00:00
|
|
|
if (havePosition && !BulletIsEmpty()) {
|
2007-12-03 21:31:26 +00:00
|
|
|
// We have some lines to align the bullet with.
|
|
|
|
|
|
|
|
// Doing the alignment using the baseline will also cater for
|
|
|
|
// bullets that are placed next to a child block (bug 92896)
|
2007-12-03 18:32:51 +00:00
|
|
|
|
2007-12-03 21:31:26 +00:00
|
|
|
// Tall bullets won't look particularly nice here...
|
|
|
|
nsRect bbox = mBullet->GetRect();
|
2009-04-08 20:52:36 +00:00
|
|
|
bbox.y = position.mBaseline - metrics.ascent;
|
2007-12-03 21:31:26 +00:00
|
|
|
mBullet->SetRect(bbox);
|
|
|
|
}
|
|
|
|
// Otherwise just leave the bullet where it is, up against our top padding.
|
2007-01-23 04:06:56 +00:00
|
|
|
}
|
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
// Compute our final size
|
2008-12-29 08:18:40 +00:00
|
|
|
nscoord bottomEdgeOfChildren;
|
2011-01-19 22:39:31 +00:00
|
|
|
ComputeFinalSize(*reflowState, state, aMetrics, &bottomEdgeOfChildren);
|
|
|
|
ComputeOverflowAreas(*reflowState, aMetrics, bottomEdgeOfChildren);
|
2007-07-26 04:03:29 +00:00
|
|
|
// Factor overflow container child bounds into the overflow area
|
2010-10-07 04:25:45 +00:00
|
|
|
aMetrics.mOverflowAreas.UnionWith(ocBounds);
|
2010-08-06 04:59:20 +00:00
|
|
|
// Factor pushed float child bounds into the overflow area
|
2010-10-07 04:25:45 +00:00
|
|
|
aMetrics.mOverflowAreas.UnionWith(fcBounds);
|
1998-06-24 17:52:42 +00:00
|
|
|
|
2000-05-09 05:06:16 +00:00
|
|
|
// Let the absolutely positioned container reflow any absolutely positioned
|
|
|
|
// child frames that need to be reflowed, e.g., elements with a percentage
|
|
|
|
// based width/height
|
2002-06-12 03:21:00 +00: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.
|
2007-12-05 02:57:53 +00:00
|
|
|
// XXX checking oldSize is bogus, there are various reasons we might have
|
|
|
|
// reflowed but our size might not have been changed to what we
|
|
|
|
// asked for (e.g., we ended up being pushed to a new page)
|
|
|
|
// When WillReflowAgainForClearance is true, we will reflow again without
|
|
|
|
// resetting the size. Because of this, we must not reflow our abs-pos children
|
|
|
|
// in that situation --- what we think is our "new size"
|
|
|
|
// will not be our real new size. This also happens to be more efficient.
|
2011-04-29 23:02:33 +00:00
|
|
|
if (HasAbsolutelyPositionedChildren()) {
|
|
|
|
nsAbsoluteContainingBlock* absoluteContainer = GetAbsoluteContainingBlock();
|
2009-04-21 23:53:52 +00:00
|
|
|
PRBool haveInterrupt = aPresContext->HasPendingInterrupt();
|
2011-01-19 22:39:31 +00:00
|
|
|
if (reflowState->WillReflowAgainForClearance() ||
|
2009-04-21 23:53:52 +00:00
|
|
|
haveInterrupt) {
|
2008-10-15 20:30:42 +00:00
|
|
|
// Make sure that when we reflow again we'll actually reflow all the abs
|
2009-04-21 23:53:52 +00:00
|
|
|
// pos frames that might conceivably depend on our size (or all of them,
|
|
|
|
// if we're dirty right now and interrupted; in that case we also need
|
|
|
|
// to mark them all with NS_FRAME_IS_DIRTY). Sadly, we can't do much
|
|
|
|
// better than that, because we don't really know what our size will be,
|
|
|
|
// and it might in fact not change on the followup reflow!
|
|
|
|
if (haveInterrupt && (GetStateBits() & NS_FRAME_IS_DIRTY)) {
|
2011-04-29 23:02:33 +00:00
|
|
|
absoluteContainer->MarkAllFramesDirty();
|
2009-04-21 23:53:52 +00:00
|
|
|
} else {
|
2011-04-29 23:02:33 +00:00
|
|
|
absoluteContainer->MarkSizeDependentFramesDirty();
|
2009-04-21 23:53:52 +00:00
|
|
|
}
|
2008-10-15 20:30:42 +00:00
|
|
|
} else {
|
|
|
|
nsSize containingBlockSize =
|
2011-01-19 22:39:31 +00:00
|
|
|
CalculateContainingBlockSizeForAbsolutes(*reflowState,
|
2008-10-15 20:30:42 +00:00
|
|
|
nsSize(aMetrics.width,
|
|
|
|
aMetrics.height));
|
|
|
|
|
|
|
|
// Mark frames that depend on changes we just made to this frame as dirty:
|
|
|
|
// Now we can assume that the padding edge hasn't moved.
|
|
|
|
// We need to reflow the absolutes if one of them depends on
|
|
|
|
// its placeholder position, or the containing block size in a
|
|
|
|
// direction in which the containing block size might have
|
|
|
|
// changed.
|
|
|
|
PRBool cbWidthChanged = aMetrics.width != oldSize.width;
|
|
|
|
PRBool isRoot = !GetContent()->GetParent();
|
|
|
|
// If isRoot and we have auto height, then we are the initial
|
|
|
|
// containing block and the containing block height is the
|
|
|
|
// viewport height, which can't change during incremental
|
|
|
|
// reflow.
|
|
|
|
PRBool cbHeightChanged =
|
2011-01-19 22:39:31 +00:00
|
|
|
!(isRoot && NS_UNCONSTRAINEDSIZE == reflowState->ComputedHeight()) &&
|
2008-10-15 20:30:42 +00:00
|
|
|
aMetrics.height != oldSize.height;
|
|
|
|
|
2011-04-29 23:02:33 +00:00
|
|
|
absoluteContainer->Reflow(this, aPresContext, *reflowState,
|
|
|
|
state.mReflowStatus,
|
|
|
|
containingBlockSize.width,
|
|
|
|
containingBlockSize.height, PR_TRUE,
|
|
|
|
cbWidthChanged, cbHeightChanged,
|
|
|
|
&aMetrics.mOverflowAreas);
|
2008-10-15 20:30:42 +00:00
|
|
|
|
|
|
|
//XXXfr Why isn't this rv (and others in this file) checked/returned?
|
|
|
|
}
|
2002-12-22 05:40:51 +00:00
|
|
|
}
|
2004-10-08 12:17:10 +00:00
|
|
|
|
|
|
|
// Determine if we need to repaint our border, background or outline
|
2008-08-20 06:45:29 +00:00
|
|
|
CheckInvalidateSizeChange(aMetrics);
|
2004-10-08 12:17:10 +00:00
|
|
|
|
2007-05-21 10:06:08 +00:00
|
|
|
FinishAndStoreOverflow(&aMetrics);
|
|
|
|
|
2009-01-05 00:39:54 +00:00
|
|
|
// Clear the float manager pointer in the block reflow state so we
|
2002-05-03 13:49:44 +00:00
|
|
|
// don't waste time translating the coordinate system back on a dead
|
2009-01-05 00:39:54 +00:00
|
|
|
// float manager.
|
|
|
|
if (needFloatManager)
|
|
|
|
state.mFloatManager = nsnull;
|
2002-04-18 23:37:51 +00:00
|
|
|
|
2002-10-21 14:54:00 +00:00
|
|
|
aStatus = state.mReflowStatus;
|
|
|
|
|
1999-10-15 23:35:10 +00:00
|
|
|
#ifdef DEBUG
|
2011-01-12 01:09:21 +00:00
|
|
|
// Between when we drain pushed floats and when we complete reflow,
|
|
|
|
// we're allowed to have multiple continuations of the same float on
|
|
|
|
// our floats list, since a first-in-flow might get pushed to a later
|
|
|
|
// continuation of its containing block. But it's not permitted
|
|
|
|
// outside that time.
|
|
|
|
nsLayoutUtils::AssertNoDuplicateContinuations(this, mFloats);
|
|
|
|
|
1999-10-19 23:04:19 +00:00
|
|
|
if (gNoisyReflow) {
|
1999-10-15 23:35:10 +00:00
|
|
|
IndentBy(stdout, gNoiseIndent);
|
|
|
|
ListTag(stdout);
|
2000-10-28 22:17:53 +00:00
|
|
|
printf(": status=%x (%scomplete) metrics=%d,%d carriedMargin=%d",
|
1999-10-15 23:35:10 +00:00
|
|
|
aStatus, NS_FRAME_IS_COMPLETE(aStatus) ? "" : "not ",
|
|
|
|
aMetrics.width, aMetrics.height,
|
2001-10-25 01:08:40 +00:00
|
|
|
aMetrics.mCarriedOutBottomMargin.get());
|
2010-10-07 04:25:45 +00:00
|
|
|
if (HasOverflowAreas()) {
|
|
|
|
printf(" overflow-vis={%d,%d,%d,%d}",
|
|
|
|
aMetrics.VisualOverflow().x,
|
|
|
|
aMetrics.VisualOverflow().y,
|
|
|
|
aMetrics.VisualOverflow().width,
|
|
|
|
aMetrics.VisualOverflow().height);
|
|
|
|
printf(" overflow-scr={%d,%d,%d,%d}",
|
|
|
|
aMetrics.ScrollableOverflow().x,
|
|
|
|
aMetrics.ScrollableOverflow().y,
|
|
|
|
aMetrics.ScrollableOverflow().width,
|
|
|
|
aMetrics.ScrollableOverflow().height);
|
1999-10-15 23:35:10 +00:00
|
|
|
}
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("\n");
|
1999-10-14 23:10:03 +00:00
|
|
|
}
|
1999-10-19 23:04:19 +00:00
|
|
|
|
|
|
|
if (gLameReflowMetrics) {
|
|
|
|
PRTime end = PR_Now();
|
|
|
|
|
|
|
|
PRInt32 ectc = nsLineBox::GetCtorCount();
|
2001-10-25 01:08:40 +00:00
|
|
|
PRInt32 numLines = mLines.size();
|
1999-10-19 23:04:19 +00:00
|
|
|
if (!numLines) numLines = 1;
|
|
|
|
PRTime delta, perLineDelta, lines;
|
|
|
|
LL_I2L(lines, numLines);
|
|
|
|
LL_SUB(delta, end, start);
|
|
|
|
LL_DIV(perLineDelta, delta, lines);
|
|
|
|
|
|
|
|
ListTag(stdout);
|
|
|
|
char buf[400];
|
|
|
|
PR_snprintf(buf, sizeof(buf),
|
|
|
|
": %lld elapsed (%lld per line) (%d lines; %d new lines)",
|
|
|
|
delta, perLineDelta, numLines, ectc - ctc);
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("%s\n", buf);
|
1999-10-19 23:04:19 +00:00
|
|
|
}
|
2000-05-14 04:56:25 +00:00
|
|
|
#endif
|
|
|
|
|
2011-01-19 22:39:31 +00:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, (*reflowState), aMetrics);
|
1998-12-05 16:02:08 +00:00
|
|
|
return rv;
|
1998-06-24 17:52:42 +00:00
|
|
|
}
|
|
|
|
|
2004-11-25 14:51:00 +00:00
|
|
|
PRBool
|
|
|
|
nsBlockFrame::CheckForCollapsedBottomMarginFromClearanceLine()
|
|
|
|
{
|
|
|
|
line_iterator begin = begin_lines();
|
|
|
|
line_iterator line = end_lines();
|
|
|
|
|
|
|
|
while (PR_TRUE) {
|
|
|
|
if (begin == line) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
--line;
|
|
|
|
if (line->mBounds.height != 0 || !line->CachedIsEmpty()) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
if (line->HasClearance()) {
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// not reached
|
|
|
|
}
|
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
void
|
1999-03-05 04:21:32 +00:00
|
|
|
nsBlockFrame::ComputeFinalSize(const nsHTMLReflowState& aReflowState,
|
2002-10-21 14:54:00 +00:00
|
|
|
nsBlockReflowState& aState,
|
2008-12-29 08:18:40 +00:00
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
nscoord* aBottomEdgeOfChildren)
|
1998-06-25 16:33:10 +00:00
|
|
|
{
|
1999-03-05 04:21:32 +00:00
|
|
|
const nsMargin& borderPadding = aState.BorderPadding();
|
1999-09-15 00:28:10 +00:00
|
|
|
#ifdef NOISY_FINAL_SIZE
|
|
|
|
ListTag(stdout);
|
2000-10-28 22:17:53 +00:00
|
|
|
printf(": mY=%d mIsBottomMarginRoot=%s mPrevBottomMargin=%d bp=%d,%d\n",
|
2000-04-17 14:40:46 +00:00
|
|
|
aState.mY, aState.GetFlag(BRS_ISBOTTOMMARGINROOT) ? "yes" : "no",
|
1999-09-15 00:28:10 +00:00
|
|
|
aState.mPrevBottomMargin,
|
|
|
|
borderPadding.top, borderPadding.bottom);
|
|
|
|
#endif
|
1999-03-19 23:05:56 +00:00
|
|
|
|
2000-06-29 22:03:42 +00:00
|
|
|
// Compute final width
|
2010-04-14 19:35:36 +00:00
|
|
|
aMetrics.width =
|
|
|
|
NSCoordSaturatingAdd(NSCoordSaturatingAdd(borderPadding.left,
|
|
|
|
aReflowState.ComputedWidth()),
|
|
|
|
borderPadding.right);
|
2000-06-29 22:03:42 +00:00
|
|
|
|
2004-11-25 14:51:00 +00:00
|
|
|
// Return bottom margin information
|
|
|
|
// rbs says he hit this assertion occasionally (see bug 86947), so
|
|
|
|
// just set the margin to zero and we'll figure out why later
|
|
|
|
//NS_ASSERTION(aMetrics.mCarriedOutBottomMargin.IsZero(),
|
|
|
|
// "someone else set the margin");
|
|
|
|
nscoord nonCarriedOutVerticalMargin = 0;
|
|
|
|
if (!aState.GetFlag(BRS_ISBOTTOMMARGINROOT)) {
|
|
|
|
// Apply rule from CSS 2.1 section 8.3.1. If we have some empty
|
|
|
|
// line with clearance and a non-zero top margin and all
|
2005-11-20 22:05:24 +00:00
|
|
|
// subsequent lines are empty, then we do not allow our children's
|
2004-11-25 14:51:00 +00:00
|
|
|
// carried out bottom margin to be carried out of us and collapse
|
|
|
|
// with our own bottom margin.
|
|
|
|
if (CheckForCollapsedBottomMarginFromClearanceLine()) {
|
|
|
|
// Convert the children's carried out margin to something that
|
|
|
|
// we will include in our height
|
|
|
|
nonCarriedOutVerticalMargin = aState.mPrevBottomMargin.get();
|
|
|
|
aState.mPrevBottomMargin.Zero();
|
|
|
|
}
|
|
|
|
aMetrics.mCarriedOutBottomMargin = aState.mPrevBottomMargin;
|
|
|
|
} else {
|
|
|
|
aMetrics.mCarriedOutBottomMargin.Zero();
|
|
|
|
}
|
|
|
|
|
2008-12-29 08:18:40 +00:00
|
|
|
nscoord bottomEdgeOfChildren = aState.mY + nonCarriedOutVerticalMargin;
|
|
|
|
// Shrink wrap our height around our contents.
|
|
|
|
if (aState.GetFlag(BRS_ISBOTTOMMARGINROOT) ||
|
|
|
|
NS_UNCONSTRAINEDSIZE != aReflowState.ComputedHeight()) {
|
|
|
|
// When we are a bottom-margin root make sure that our last
|
|
|
|
// childs bottom margin is fully applied. We also do this when
|
|
|
|
// we have a computed height, since in that case the carried out
|
|
|
|
// margin is not going to be applied anywhere, so we should note it
|
|
|
|
// here to be included in the overflow area.
|
|
|
|
// Apply the margin only if there's space for it.
|
|
|
|
if (bottomEdgeOfChildren < aState.mReflowState.availableHeight)
|
|
|
|
{
|
|
|
|
// Truncate bottom margin if it doesn't fit to our available height.
|
|
|
|
bottomEdgeOfChildren =
|
2009-09-16 15:01:36 +00:00
|
|
|
NS_MIN(bottomEdgeOfChildren + aState.mPrevBottomMargin.get(),
|
2008-12-29 08:18:40 +00:00
|
|
|
aState.mReflowState.availableHeight);
|
|
|
|
}
|
|
|
|
}
|
2009-01-05 00:39:54 +00:00
|
|
|
if (aState.GetFlag(BRS_FLOAT_MGR)) {
|
|
|
|
// Include the float manager's state to properly account for the
|
2008-12-29 08:18:40 +00:00
|
|
|
// bottom margin of any floated elements; e.g., inside a table cell.
|
|
|
|
nscoord floatHeight =
|
2010-08-06 04:59:19 +00:00
|
|
|
aState.ClearFloats(bottomEdgeOfChildren, NS_STYLE_CLEAR_LEFT_AND_RIGHT,
|
|
|
|
nsnull, nsFloatManager::DONT_CLEAR_PUSHED_FLOATS);
|
2009-09-16 15:01:36 +00:00
|
|
|
bottomEdgeOfChildren = NS_MAX(bottomEdgeOfChildren, floatHeight);
|
2008-12-29 08:18:40 +00:00
|
|
|
}
|
|
|
|
|
2000-06-29 22:03:42 +00:00
|
|
|
// Compute final height
|
2007-08-02 18:08:05 +00:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != aReflowState.ComputedHeight()) {
|
2006-09-22 01:53:13 +00:00
|
|
|
// Figure out how much of the computed height should be
|
|
|
|
// applied to this frame.
|
2011-01-19 22:39:31 +00:00
|
|
|
nscoord computedHeightLeftOver = GetEffectiveComputedHeight(aReflowState);
|
2007-10-02 05:57:45 +00:00
|
|
|
NS_ASSERTION(!( IS_TRUE_OVERFLOW_CONTAINER(this)
|
2007-07-26 04:03:29 +00:00
|
|
|
&& computedHeightLeftOver ),
|
|
|
|
"overflow container must not have computedHeightLeftOver");
|
|
|
|
|
2010-04-14 19:35:36 +00:00
|
|
|
aMetrics.height =
|
|
|
|
NSCoordSaturatingAdd(NSCoordSaturatingAdd(borderPadding.top,
|
|
|
|
computedHeightLeftOver),
|
|
|
|
borderPadding.bottom);
|
|
|
|
|
2007-07-26 04:03:29 +00:00
|
|
|
if (NS_FRAME_IS_NOT_COMPLETE(aState.mReflowStatus)
|
|
|
|
&& aMetrics.height < aReflowState.availableHeight) {
|
|
|
|
// We ran out of height on this page but we're incomplete
|
|
|
|
// Set status to complete except for overflow
|
|
|
|
NS_FRAME_SET_OVERFLOW_INCOMPLETE(aState.mReflowStatus);
|
|
|
|
}
|
2005-04-26 02:26:12 +00:00
|
|
|
|
2006-09-22 01:53:13 +00:00
|
|
|
if (NS_FRAME_IS_COMPLETE(aState.mReflowStatus)) {
|
2005-04-26 02:26:12 +00:00
|
|
|
if (computedHeightLeftOver > 0 &&
|
2007-08-04 09:40:00 +00:00
|
|
|
NS_UNCONSTRAINEDSIZE != aReflowState.availableHeight &&
|
2005-04-26 02:26:12 +00:00
|
|
|
aMetrics.height > aReflowState.availableHeight) {
|
|
|
|
// We don't fit and we consumed some of the computed height,
|
|
|
|
// so we should consume all the available height and then
|
|
|
|
// break. If our bottom border/padding straddles the break
|
|
|
|
// point, then this will increase our height and push the
|
|
|
|
// border/padding to the next page/column.
|
2009-09-16 15:01:36 +00:00
|
|
|
aMetrics.height = NS_MAX(aReflowState.availableHeight,
|
2007-07-02 21:00:31 +00:00
|
|
|
aState.mY + nonCarriedOutVerticalMargin);
|
2007-07-26 04:03:29 +00:00
|
|
|
NS_FRAME_SET_INCOMPLETE(aState.mReflowStatus);
|
|
|
|
if (!GetNextInFlow())
|
|
|
|
aState.mReflowStatus |= NS_FRAME_REFLOW_NEXTINFLOW;
|
2002-10-21 14:54:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Use the current height; continuations will take up the rest.
|
2005-04-26 02:26:12 +00:00
|
|
|
// Do extend the height to at least consume the available
|
|
|
|
// height, otherwise our left/right borders (for example) won't
|
|
|
|
// extend all the way to the break.
|
2009-09-16 15:01:36 +00:00
|
|
|
aMetrics.height = NS_MAX(aReflowState.availableHeight,
|
2005-04-26 02:26:12 +00:00
|
|
|
aState.mY + nonCarriedOutVerticalMargin);
|
2006-09-22 01:53:13 +00:00
|
|
|
// ... but don't take up more height than is available
|
2009-09-16 15:01:36 +00:00
|
|
|
aMetrics.height = NS_MIN(aMetrics.height,
|
2006-09-22 01:53:13 +00:00
|
|
|
borderPadding.top + computedHeightLeftOver);
|
|
|
|
// XXX It's pretty wrong that our bottom border still gets drawn on
|
|
|
|
// on its own on the last-in-flow, even if we ran out of height
|
|
|
|
// here. We need GetSkipSides to check whether we ran out of content
|
|
|
|
// height in the current frame, not whether it's last-in-flow.
|
2002-10-21 14:54:00 +00:00
|
|
|
}
|
2000-06-29 22:03:42 +00:00
|
|
|
|
2002-10-08 01:52:34 +00:00
|
|
|
// Don't carry out a bottom margin when our height is fixed.
|
2004-11-25 14:51:00 +00:00
|
|
|
aMetrics.mCarriedOutBottomMargin.Zero();
|
2000-06-29 22:03:42 +00:00
|
|
|
}
|
2008-01-24 00:28:42 +00:00
|
|
|
else if (NS_FRAME_IS_COMPLETE(aState.mReflowStatus)) {
|
2008-12-29 08:18:40 +00:00
|
|
|
nscoord autoHeight = bottomEdgeOfChildren;
|
2005-04-28 21:57:22 +00:00
|
|
|
autoHeight -= borderPadding.top;
|
2005-08-02 14:32:46 +00:00
|
|
|
nscoord oldAutoHeight = autoHeight;
|
2005-04-28 21:57:22 +00:00
|
|
|
aReflowState.ApplyMinMaxConstraints(nsnull, &autoHeight);
|
2005-08-02 14:32:46 +00:00
|
|
|
if (autoHeight != oldAutoHeight) {
|
|
|
|
// Our min-height or max-height made our height change. Don't carry out
|
|
|
|
// our kids' bottom margins.
|
|
|
|
aMetrics.mCarriedOutBottomMargin.Zero();
|
|
|
|
}
|
2005-04-28 21:57:22 +00:00
|
|
|
autoHeight += borderPadding.top + borderPadding.bottom;
|
2000-06-29 22:03:42 +00:00
|
|
|
aMetrics.height = autoHeight;
|
|
|
|
}
|
2008-01-24 00:28:42 +00:00
|
|
|
else {
|
|
|
|
NS_ASSERTION(aReflowState.availableHeight != NS_UNCONSTRAINEDSIZE,
|
|
|
|
"Shouldn't be incomplete if availableHeight is UNCONSTRAINED.");
|
2009-09-16 15:01:36 +00:00
|
|
|
aMetrics.height = NS_MAX(aState.mY, aReflowState.availableHeight);
|
2008-01-30 05:48:42 +00:00
|
|
|
if (aReflowState.availableHeight == NS_UNCONSTRAINEDSIZE)
|
|
|
|
// This should never happen, but it does. See bug 414255
|
|
|
|
aMetrics.height = aState.mY;
|
2008-01-24 00:28:42 +00:00
|
|
|
}
|
1999-03-20 19:40:13 +00:00
|
|
|
|
2007-10-02 05:57:45 +00:00
|
|
|
if (IS_TRUE_OVERFLOW_CONTAINER(this) &&
|
|
|
|
NS_FRAME_IS_NOT_COMPLETE(aState.mReflowStatus)) {
|
|
|
|
// Overflow containers can only be overflow complete.
|
|
|
|
// Note that auto height overflow containers have no normal children
|
|
|
|
NS_ASSERTION(aMetrics.height == 0, "overflow containers must be zero-height");
|
|
|
|
NS_FRAME_SET_OVERFLOW_INCOMPLETE(aState.mReflowStatus);
|
|
|
|
}
|
|
|
|
|
2008-11-25 22:57:28 +00:00
|
|
|
// Screen out negative heights --- can happen due to integer overflows :-(
|
2009-09-16 15:01:36 +00:00
|
|
|
aMetrics.height = NS_MAX(0, aMetrics.height);
|
2008-12-29 08:18:40 +00:00
|
|
|
*aBottomEdgeOfChildren = bottomEdgeOfChildren;
|
2008-11-25 22:57:28 +00:00
|
|
|
|
2000-06-04 09:44:08 +00:00
|
|
|
#ifdef DEBUG_blocks
|
2000-06-29 22:03:42 +00:00
|
|
|
if (CRAZY_WIDTH(aMetrics.width) || CRAZY_HEIGHT(aMetrics.height)) {
|
|
|
|
ListTag(stdout);
|
2000-10-28 22:17:53 +00:00
|
|
|
printf(": WARNING: desired:%d,%d\n", aMetrics.width, aMetrics.height);
|
2000-06-29 22:03:42 +00:00
|
|
|
}
|
2000-05-14 04:56:25 +00:00
|
|
|
#endif
|
2002-09-24 11:43:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-10-07 04:25:45 +00:00
|
|
|
nsBlockFrame::ComputeOverflowAreas(const nsHTMLReflowState& aReflowState,
|
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
nscoord aBottomEdgeOfChildren)
|
2002-09-24 11:43:48 +00:00
|
|
|
{
|
2010-10-07 04:25:45 +00:00
|
|
|
// Compute the overflow areas of our children
|
2002-02-21 01:36:16 +00:00
|
|
|
// XXX_perf: This can be done incrementally. It is currently one of
|
|
|
|
// the things that makes incremental reflow O(N^2).
|
2010-10-07 04:25:45 +00:00
|
|
|
nsRect bounds(0, 0, aMetrics.width, aMetrics.height);
|
|
|
|
nsOverflowAreas areas(bounds, bounds);
|
2008-06-12 22:02:32 +00:00
|
|
|
|
2011-01-19 22:39:31 +00:00
|
|
|
if (!IsClippingChildren(this, aReflowState)) {
|
2008-06-12 22:02:32 +00:00
|
|
|
PRBool inQuirks = (PresContext()->CompatibilityMode() == eCompatibility_NavQuirks);
|
2001-10-25 01:08:40 +00:00
|
|
|
for (line_iterator line = begin_lines(), line_end = end_lines();
|
|
|
|
line != line_end;
|
2004-08-25 13:10:06 +00:00
|
|
|
++line) {
|
2008-06-12 22:02:32 +00:00
|
|
|
|
|
|
|
// Text-shadow overflows
|
|
|
|
if (!inQuirks && line->IsInline()) {
|
2010-10-07 04:25:45 +00:00
|
|
|
nsRect shadowRect = nsLayoutUtils::GetTextShadowRectsUnion(
|
|
|
|
line->GetVisualOverflowArea(), this);
|
|
|
|
areas.VisualOverflow().UnionRect(areas.VisualOverflow(), shadowRect);
|
2008-06-12 22:02:32 +00:00
|
|
|
}
|
|
|
|
|
2010-10-07 04:25:45 +00:00
|
|
|
areas.UnionWith(line->GetOverflowAreas());
|
1999-05-03 20:51:02 +00:00
|
|
|
}
|
1999-09-15 00:28:10 +00:00
|
|
|
|
|
|
|
// Factor the bullet in; normally the bullet will be factored into
|
2010-10-07 04:25:45 +00:00
|
|
|
// the line-box's overflow areas. However, if the line is a block
|
1999-09-15 00:28:10 +00:00
|
|
|
// line then it won't; if there are no lines, it won't. So just
|
|
|
|
// factor it in anyway (it can't hurt if it was already done).
|
2010-10-07 04:25:45 +00:00
|
|
|
// XXXldb Can we just fix GetOverflowArea instead?
|
1999-09-15 00:28:10 +00:00
|
|
|
if (mBullet) {
|
2010-10-07 04:25:45 +00:00
|
|
|
areas.UnionAllWith(mBullet->GetRect());
|
1999-03-20 21:57:03 +00:00
|
|
|
}
|
2008-12-29 08:18:40 +00:00
|
|
|
|
|
|
|
// Factor in the bottom edge of the children. Child frames
|
|
|
|
// will be added to the overflow area as we iterate through the lines,
|
|
|
|
// but their margins won't, so we need to account for bottom margins
|
|
|
|
// here. If we're a scrolled block then we also need to account
|
|
|
|
// for the scrollframe's padding, which is logically below the
|
|
|
|
// bottom margins of the children.
|
|
|
|
nscoord bottomEdgeOfContents = aBottomEdgeOfChildren;
|
2009-10-29 21:17:56 +00:00
|
|
|
if (GetStyleContext()->GetPseudo() == nsCSSAnonBoxes::scrolledContent) {
|
2008-12-29 08:18:40 +00:00
|
|
|
// We're a scrolled frame; the scrollframe's padding should be added
|
|
|
|
// to the bottom edge of the children
|
|
|
|
bottomEdgeOfContents += aReflowState.mComputedPadding.bottom;
|
|
|
|
}
|
2010-10-07 04:25:45 +00:00
|
|
|
// REVIEW: For now, we do this for both visual and scrollable area,
|
|
|
|
// although when we make scrollable overflow area not be a subset of
|
|
|
|
// visual, we can change this.
|
|
|
|
NS_FOR_FRAME_OVERFLOW_TYPES(otype) {
|
|
|
|
nsRect& o = areas.Overflow(otype);
|
|
|
|
o.height = NS_MAX(o.YMost(), bottomEdgeOfContents) - o.y;
|
|
|
|
}
|
1999-07-14 17:26:20 +00:00
|
|
|
}
|
1999-03-22 22:42:30 +00:00
|
|
|
#ifdef NOISY_COMBINED_AREA
|
|
|
|
ListTag(stdout);
|
2004-08-25 13:10:06 +00:00
|
|
|
printf(": ca=%d,%d,%d,%d\n", area.x, area.y, area.width, area.height);
|
1999-03-22 22:42:30 +00:00
|
|
|
#endif
|
1998-06-18 16:25:41 +00:00
|
|
|
|
2010-10-07 04:25:45 +00:00
|
|
|
aMetrics.mOverflowAreas = areas;
|
1998-12-05 16:02:08 +00:00
|
|
|
}
|
1998-06-18 16:25:41 +00:00
|
|
|
|
2000-01-12 08:28:24 +00:00
|
|
|
nsresult
|
2008-10-12 19:26:06 +00:00
|
|
|
nsBlockFrame::MarkLineDirty(line_iterator aLine, const nsLineList* aLineList)
|
2000-01-12 08:28:24 +00:00
|
|
|
{
|
2000-02-07 15:36:08 +00:00
|
|
|
// Mark aLine dirty
|
|
|
|
aLine->MarkDirty();
|
2007-11-09 06:55:32 +00:00
|
|
|
aLine->SetInvalidateTextRuns(PR_TRUE);
|
2000-02-07 15:36:08 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (gNoisyReflow) {
|
|
|
|
IndentBy(stdout, gNoiseIndent);
|
|
|
|
ListTag(stdout);
|
2007-07-08 07:08:04 +00:00
|
|
|
printf(": mark line %p dirty\n", static_cast<void*>(aLine.get()));
|
2000-02-07 15:36:08 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2005-11-20 22:05:24 +00:00
|
|
|
// Mark previous line dirty if it's an inline line so that it can
|
2000-02-07 15:36:08 +00:00
|
|
|
// maybe pullup something from the line just affected.
|
|
|
|
// XXX We don't need to do this if aPrevLine ends in a break-after...
|
2008-10-12 19:26:06 +00:00
|
|
|
if (aLine != (aLineList ? aLineList : &mLines)->front() &&
|
2001-10-25 01:08:40 +00:00
|
|
|
aLine->IsInline() &&
|
|
|
|
aLine.prev()->IsInline()) {
|
|
|
|
aLine.prev()->MarkDirty();
|
2007-11-09 06:55:32 +00:00
|
|
|
aLine.prev()->SetInvalidateTextRuns(PR_TRUE);
|
1999-10-15 23:35:10 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (gNoisyReflow) {
|
|
|
|
IndentBy(stdout, gNoiseIndent);
|
|
|
|
ListTag(stdout);
|
2001-10-25 01:08:40 +00:00
|
|
|
printf(": mark prev-line %p dirty\n",
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<void*>(aLine.prev().get()));
|
1999-10-15 23:35:10 +00:00
|
|
|
}
|
1999-04-21 19:58:38 +00:00
|
|
|
#endif
|
1998-12-05 16:02:08 +00:00
|
|
|
}
|
1999-04-21 19:58:38 +00:00
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
return NS_OK;
|
1998-06-24 17:52:42 +00:00
|
|
|
}
|
1998-06-18 16:25:41 +00:00
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
nsresult
|
1999-02-09 17:31:33 +00:00
|
|
|
nsBlockFrame::PrepareResizeReflow(nsBlockReflowState& aState)
|
1998-11-05 19:33:01 +00:00
|
|
|
{
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
const nsStyleText* styleText = GetStyleText();
|
|
|
|
// See if we can try and avoid marking all the lines as dirty
|
|
|
|
PRBool tryAndSkipLines =
|
|
|
|
// The text must be left-aligned.
|
|
|
|
(NS_STYLE_TEXT_ALIGN_LEFT == styleText->mTextAlign ||
|
|
|
|
(NS_STYLE_TEXT_ALIGN_DEFAULT == styleText->mTextAlign &&
|
|
|
|
NS_STYLE_DIRECTION_LTR ==
|
2009-02-06 03:48:30 +00:00
|
|
|
aState.mReflowState.mStyleVisibility->mDirection) ||
|
|
|
|
(NS_STYLE_TEXT_ALIGN_END == styleText->mTextAlign &&
|
|
|
|
NS_STYLE_DIRECTION_RTL ==
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
aState.mReflowState.mStyleVisibility->mDirection)) &&
|
|
|
|
// The left content-edge must be a constant distance from the left
|
|
|
|
// border-edge.
|
2010-08-31 16:05:12 +00:00
|
|
|
!GetStylePadding()->mPadding.GetLeft().HasPercent();
|
1999-09-25 16:50:45 +00:00
|
|
|
|
1999-10-15 23:35:10 +00:00
|
|
|
#ifdef DEBUG
|
1999-10-29 14:34:53 +00:00
|
|
|
if (gDisableResizeOpt) {
|
|
|
|
tryAndSkipLines = PR_FALSE;
|
|
|
|
}
|
1999-10-15 23:35:10 +00:00
|
|
|
if (gNoisyReflow) {
|
|
|
|
if (!tryAndSkipLines) {
|
|
|
|
IndentBy(stdout, gNoiseIndent);
|
|
|
|
ListTag(stdout);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
printf(": marking all lines dirty: availWidth=%d textAlign=%d\n",
|
1999-10-15 23:35:10 +00:00
|
|
|
aState.mReflowState.availableWidth,
|
2003-05-15 03:42:21 +00:00
|
|
|
styleText->mTextAlign);
|
1999-10-15 23:35:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1999-09-25 16:50:45 +00:00
|
|
|
if (tryAndSkipLines) {
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nscoord newAvailWidth = aState.mReflowState.mComputedBorderPadding.left +
|
2007-01-26 00:05:12 +00:00
|
|
|
aState.mReflowState.ComputedWidth();
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
NS_ASSERTION(NS_UNCONSTRAINEDSIZE != aState.mReflowState.mComputedBorderPadding.left &&
|
2007-01-26 00:05:12 +00:00
|
|
|
NS_UNCONSTRAINEDSIZE != aState.mReflowState.ComputedWidth(),
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
"math on NS_UNCONSTRAINEDSIZE");
|
2000-01-03 04:32:13 +00:00
|
|
|
|
1999-10-15 23:35:10 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (gNoisyReflow) {
|
|
|
|
IndentBy(stdout, gNoiseIndent);
|
|
|
|
ListTag(stdout);
|
2000-10-28 22:17:53 +00:00
|
|
|
printf(": trying to avoid marking all lines dirty\n");
|
1999-10-15 23:35:10 +00:00
|
|
|
}
|
|
|
|
#endif
|
2001-10-08 21:51:48 +00:00
|
|
|
|
2001-10-25 01:08:40 +00:00
|
|
|
for (line_iterator line = begin_lines(), line_end = end_lines();
|
|
|
|
line != line_end;
|
|
|
|
++line)
|
|
|
|
{
|
2001-10-08 21:51:48 +00:00
|
|
|
// We let child blocks make their own decisions the same
|
|
|
|
// way we are here.
|
|
|
|
if (line->IsBlock() ||
|
2003-10-13 21:51:02 +00:00
|
|
|
line->HasFloats() ||
|
2009-07-13 16:50:54 +00:00
|
|
|
((line != mLines.back() || GetNextInFlow()) // not the last line
|
|
|
|
&& !line->HasBreakAfter()) ||
|
2003-11-11 19:24:01 +00:00
|
|
|
line->ResizeReflowOptimizationDisabled() ||
|
|
|
|
line->IsImpactedByFloat() ||
|
|
|
|
(line->mBounds.XMost() > newAvailWidth)) {
|
1999-10-29 14:34:53 +00:00
|
|
|
line->MarkDirty();
|
|
|
|
}
|
2001-10-08 21:51:48 +00:00
|
|
|
|
2000-03-22 23:19:10 +00:00
|
|
|
#ifdef REALLY_NOISY_REFLOW
|
2001-10-08 21:51:48 +00:00
|
|
|
if (!line->IsBlock()) {
|
2003-10-13 21:51:02 +00:00
|
|
|
printf("PrepareResizeReflow thinks line %p is %simpacted by floats\n",
|
2005-03-23 03:35:08 +00:00
|
|
|
line.get(), line->IsImpactedByFloat() ? "" : "not ");
|
2001-10-08 21:51:48 +00:00
|
|
|
}
|
2000-03-22 23:19:10 +00:00
|
|
|
#endif
|
1999-10-15 23:35:10 +00:00
|
|
|
#ifdef DEBUG
|
2003-11-11 19:24:01 +00:00
|
|
|
if (gNoisyReflow && !line->IsDirty()) {
|
2001-10-08 21:51:48 +00:00
|
|
|
IndentBy(stdout, gNoiseIndent + 1);
|
2004-11-25 14:51:00 +00:00
|
|
|
printf("skipped: line=%p next=%p %s %s%s%s breakTypeBefore/After=%d/%d xmost=%d\n",
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<void*>(line.get()),
|
|
|
|
static_cast<void*>((line.next() != end_lines() ? line.next().get() : nsnull)),
|
2001-10-08 21:51:48 +00:00
|
|
|
line->IsBlock() ? "block" : "inline",
|
2004-11-25 14:51:00 +00:00
|
|
|
line->HasBreakAfter() ? "has-break-after " : "",
|
2003-10-13 21:51:02 +00:00
|
|
|
line->HasFloats() ? "has-floats " : "",
|
|
|
|
line->IsImpactedByFloat() ? "impacted " : "",
|
2004-11-25 14:51:00 +00:00
|
|
|
line->GetBreakTypeBefore(), line->GetBreakTypeAfter(),
|
2001-10-08 21:51:48 +00:00
|
|
|
line->mBounds.XMost());
|
1999-09-25 16:50:45 +00:00
|
|
|
}
|
2001-10-08 21:51:48 +00:00
|
|
|
#endif
|
1999-09-25 16:50:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Mark everything dirty
|
2001-10-25 01:08:40 +00:00
|
|
|
for (line_iterator line = begin_lines(), line_end = end_lines();
|
|
|
|
line != line_end;
|
|
|
|
++line)
|
|
|
|
{
|
1999-09-25 16:50:45 +00:00
|
|
|
line->MarkDirty();
|
|
|
|
}
|
1998-11-05 19:33:01 +00:00
|
|
|
}
|
1998-12-05 16:02:08 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-11-05 19:33:01 +00:00
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
//----------------------------------------
|
1998-11-05 19:33:01 +00:00
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
/**
|
2001-10-25 01:08:40 +00:00
|
|
|
* Propagate reflow "damage" from from earlier lines to the current
|
|
|
|
* line. The reflow damage comes from the following sources:
|
2003-10-13 21:51:02 +00:00
|
|
|
* 1. The regions of float damage remembered during reflow.
|
|
|
|
* 2. The combination of nonzero |aDeltaY| and any impact by a float,
|
2001-10-25 01:08:40 +00:00
|
|
|
* either the previous reflow or now.
|
2001-07-04 02:00:05 +00:00
|
|
|
*
|
2001-10-25 01:08:40 +00:00
|
|
|
* When entering this function, |aLine| is still at its old position and
|
|
|
|
* |aDeltaY| indicates how much it will later be slid (assuming it
|
|
|
|
* doesn't get marked dirty and reflowed entirely).
|
1998-12-05 16:02:08 +00:00
|
|
|
*/
|
|
|
|
void
|
2003-10-13 21:51:02 +00:00
|
|
|
nsBlockFrame::PropagateFloatDamage(nsBlockReflowState& aState,
|
|
|
|
nsLineBox* aLine,
|
|
|
|
nscoord aDeltaY)
|
1998-08-28 03:02:39 +00:00
|
|
|
{
|
2009-01-05 00:39:54 +00:00
|
|
|
nsFloatManager *floatManager = aState.mReflowState.mFloatManager;
|
2007-08-20 20:07:50 +00:00
|
|
|
NS_ASSERTION((aState.mReflowState.parentReflowState &&
|
2009-01-05 00:39:54 +00:00
|
|
|
aState.mReflowState.parentReflowState->mFloatManager == floatManager) ||
|
2007-08-20 20:07:50 +00:00
|
|
|
aState.mReflowState.mBlockDelta == 0, "Bad block delta passed in");
|
|
|
|
|
|
|
|
// Check to see if there are any floats; if there aren't, there can't
|
|
|
|
// be any float damage
|
2009-01-05 00:39:54 +00:00
|
|
|
if (!floatManager->HasAnyFloats())
|
2007-08-20 20:07:50 +00:00
|
|
|
return;
|
2001-10-25 01:08:40 +00:00
|
|
|
|
|
|
|
// Check the damage region recorded in the float damage.
|
2009-01-05 00:39:54 +00:00
|
|
|
if (floatManager->HasFloatDamage()) {
|
2007-11-07 20:07:54 +00:00
|
|
|
// Need to check mBounds *and* mCombinedArea to find intersections
|
|
|
|
// with aLine's floats
|
2001-10-25 01:08:40 +00:00
|
|
|
nscoord lineYA = aLine->mBounds.y + aDeltaY;
|
|
|
|
nscoord lineYB = lineYA + aLine->mBounds.height;
|
2010-10-07 04:25:45 +00:00
|
|
|
// Scrollable overflow should be sufficient for things that affect
|
|
|
|
// layout.
|
|
|
|
nsRect overflow = aLine->GetOverflowArea(eScrollableOverflow);
|
|
|
|
nscoord lineYCombinedA = overflow.y + aDeltaY;
|
|
|
|
nscoord lineYCombinedB = lineYCombinedA + overflow.height;
|
2009-01-05 00:39:54 +00:00
|
|
|
if (floatManager->IntersectsDamage(lineYA, lineYB) ||
|
|
|
|
floatManager->IntersectsDamage(lineYCombinedA, lineYCombinedB)) {
|
2001-10-25 01:08:40 +00:00
|
|
|
aLine->MarkDirty();
|
1999-09-15 00:28:10 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
1998-08-28 03:02:39 +00:00
|
|
|
|
2009-01-05 00:39:54 +00:00
|
|
|
// Check if the line is moving relative to the float manager
|
2007-08-20 20:07:50 +00:00
|
|
|
if (aDeltaY + aState.mReflowState.mBlockDelta != 0) {
|
|
|
|
if (aLine->IsBlock()) {
|
|
|
|
// Unconditionally reflow sliding blocks; we only really need to reflow
|
2009-01-05 00:39:54 +00:00
|
|
|
// if there's a float impacting this block, but the current float manager
|
2007-08-20 20:07:50 +00:00
|
|
|
// makes it difficult to check that. Therefore, we let the child block
|
|
|
|
// decide what it needs to reflow.
|
|
|
|
aLine->MarkDirty();
|
|
|
|
} else {
|
|
|
|
PRBool wasImpactedByFloat = aLine->IsImpactedByFloat();
|
2009-04-08 20:52:37 +00:00
|
|
|
nsFlowAreaRect floatAvailableSpace =
|
2009-05-20 11:21:34 +00:00
|
|
|
aState.GetFloatAvailableSpaceForHeight(aLine->mBounds.y + aDeltaY,
|
|
|
|
aLine->mBounds.height,
|
|
|
|
nsnull);
|
2007-08-20 20:07:50 +00:00
|
|
|
|
2000-03-22 23:19:10 +00:00
|
|
|
#ifdef REALLY_NOISY_REFLOW
|
2003-10-13 21:51:02 +00:00
|
|
|
printf("nsBlockFrame::PropagateFloatDamage %p was = %d, is=%d\n",
|
2009-04-08 20:52:37 +00:00
|
|
|
this, wasImpactedByFloat, floatAvailableSpace.mHasFloats);
|
2000-03-22 23:19:10 +00:00
|
|
|
#endif
|
2007-08-20 20:07:50 +00:00
|
|
|
|
|
|
|
// Mark the line dirty if it was or is affected by a float
|
|
|
|
// We actually only really need to reflow if the amount of impact
|
|
|
|
// changes, but that's not straightforward to check
|
2009-04-08 20:52:37 +00:00
|
|
|
if (wasImpactedByFloat || floatAvailableSpace.mHasFloats) {
|
2007-08-20 20:07:50 +00:00
|
|
|
aLine->MarkDirty();
|
|
|
|
}
|
1998-12-05 16:02:08 +00:00
|
|
|
}
|
|
|
|
}
|
1998-06-24 17:52:42 +00:00
|
|
|
}
|
1998-06-18 16:25:41 +00:00
|
|
|
|
2004-12-27 15:05:18 +00:00
|
|
|
static void PlaceFrameView(nsIFrame* aFrame);
|
2004-10-08 12:17:10 +00:00
|
|
|
|
2004-11-25 14:51:00 +00:00
|
|
|
static PRBool LineHasClear(nsLineBox* aLine) {
|
2008-01-29 07:40:05 +00:00
|
|
|
return aLine->IsBlock()
|
|
|
|
? (aLine->GetBreakTypeBefore() ||
|
|
|
|
(aLine->mFirstChild->GetStateBits() & NS_BLOCK_HAS_CLEAR_CHILDREN) ||
|
|
|
|
!nsBlockFrame::BlockCanIntersectFloats(aLine->mFirstChild))
|
|
|
|
: aLine->HasFloatBreakAfter();
|
2004-11-25 14:51:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-08 12:17:10 +00:00
|
|
|
/**
|
|
|
|
* Reparent a whole list of floats from aOldParent to this block. The
|
2005-03-23 03:35:08 +00:00
|
|
|
* floats might be taken from aOldParent's overflow list. They will be
|
|
|
|
* removed from the list. They end up appended to our mFloats list.
|
2004-10-08 12:17:10 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
nsBlockFrame::ReparentFloats(nsIFrame* aFirstFrame,
|
2007-04-21 00:42:58 +00:00
|
|
|
nsBlockFrame* aOldParent, PRBool aFromOverflow,
|
|
|
|
PRBool aReparentSiblings) {
|
2005-03-23 03:35:08 +00:00
|
|
|
nsFrameList list;
|
2009-09-18 11:09:36 +00:00
|
|
|
aOldParent->CollectFloats(aFirstFrame, list, aFromOverflow, aReparentSiblings);
|
2005-03-23 03:35:08 +00:00
|
|
|
if (list.NotEmpty()) {
|
|
|
|
for (nsIFrame* f = list.FirstChild(); f; f = f->GetNextSibling()) {
|
2004-10-08 12:17:10 +00:00
|
|
|
ReparentFrame(f, aOldParent, this);
|
|
|
|
}
|
2009-09-18 11:09:36 +00:00
|
|
|
mFloats.AppendFrames(nsnull, list);
|
2005-03-23 03:35:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void DumpLine(const nsBlockReflowState& aState, nsLineBox* aLine,
|
|
|
|
nscoord aDeltaY, PRInt32 aDeltaIndent) {
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (nsBlockFrame::gNoisyReflow) {
|
2010-10-07 04:25:45 +00:00
|
|
|
nsRect ovis(aLine->GetVisualOverflowArea());
|
|
|
|
nsRect oscr(aLine->GetScrollableOverflowArea());
|
2005-03-23 03:35:08 +00:00
|
|
|
nsBlockFrame::IndentBy(stdout, nsBlockFrame::gNoiseIndent + aDeltaIndent);
|
2010-10-07 04:25:45 +00:00
|
|
|
printf("line=%p mY=%d dirty=%s oldBounds={%d,%d,%d,%d} oldoverflow-vis={%d,%d,%d,%d} oldoverflow-scr={%d,%d,%d,%d} deltaY=%d mPrevBottomMargin=%d childCount=%d\n",
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<void*>(aLine), aState.mY,
|
2005-03-23 03:35:08 +00:00
|
|
|
aLine->IsDirty() ? "yes" : "no",
|
|
|
|
aLine->mBounds.x, aLine->mBounds.y,
|
|
|
|
aLine->mBounds.width, aLine->mBounds.height,
|
2010-10-07 04:25:45 +00:00
|
|
|
ovis.x, ovis.y, ovis.width, ovis.height,
|
|
|
|
oscr.x, oscr.y, oscr.width, oscr.height,
|
2005-03-23 03:35:08 +00:00
|
|
|
aDeltaY, aState.mPrevBottomMargin.get(), aLine->GetChildCount());
|
2004-10-08 12:17:10 +00:00
|
|
|
}
|
2005-03-23 03:35:08 +00:00
|
|
|
#endif
|
2004-10-08 12:17:10 +00:00
|
|
|
}
|
2001-10-25 01:08:40 +00:00
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
/**
|
|
|
|
* Reflow the dirty lines
|
|
|
|
*/
|
|
|
|
nsresult
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState)
|
1998-06-24 17:52:42 +00:00
|
|
|
{
|
1998-12-05 16:02:08 +00:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
PRBool keepGoing = PR_TRUE;
|
2002-04-08 23:57:37 +00:00
|
|
|
PRBool repositionViews = PR_FALSE; // should we really need this?
|
2009-08-31 18:25:36 +00:00
|
|
|
PRBool foundAnyClears = aState.mFloatBreakType != NS_STYLE_CLEAR_NONE;
|
2007-11-30 01:49:01 +00:00
|
|
|
PRBool willReflowAgain = PR_FALSE;
|
1998-06-18 16:25:41 +00:00
|
|
|
|
1999-10-15 23:35:10 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (gNoisyReflow) {
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
IndentBy(stdout, gNoiseIndent);
|
|
|
|
ListTag(stdout);
|
|
|
|
printf(": reflowing dirty lines");
|
2007-01-26 00:05:12 +00:00
|
|
|
printf(" computedWidth=%d\n", aState.mReflowState.ComputedWidth());
|
1999-09-17 23:16:43 +00:00
|
|
|
}
|
2005-03-23 03:35:08 +00:00
|
|
|
AutoNoisyIndenter indent(gNoisyReflow);
|
1998-12-05 16:02:08 +00:00
|
|
|
#endif
|
1998-11-14 19:28:11 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
PRBool selfDirty = (GetStateBits() & NS_FRAME_IS_DIRTY) ||
|
|
|
|
(aState.mReflowState.mFlags.mVResize &&
|
|
|
|
(GetStateBits() & NS_FRAME_CONTAINS_RELATIVE_HEIGHT));
|
2009-07-07 01:23:24 +00:00
|
|
|
|
|
|
|
// Reflow our last line if our availableHeight has increased
|
|
|
|
// so that we (and our last child) pull up content as necessary
|
|
|
|
if (aState.mReflowState.availableHeight != NS_UNCONSTRAINEDSIZE
|
|
|
|
&& GetNextInFlow() && aState.mReflowState.availableHeight > mRect.height) {
|
|
|
|
line_iterator lastLine = end_lines();
|
|
|
|
if (lastLine != begin_lines()) {
|
|
|
|
--lastLine;
|
|
|
|
lastLine->MarkDirty();
|
|
|
|
}
|
|
|
|
}
|
2001-10-25 01:08:40 +00:00
|
|
|
// the amount by which we will slide the current line if it is not
|
|
|
|
// dirty
|
2000-02-22 22:06:19 +00:00
|
|
|
nscoord deltaY = 0;
|
|
|
|
|
2001-10-25 01:08:40 +00:00
|
|
|
// whether we did NOT reflow the previous line and thus we need to
|
|
|
|
// recompute the carried out margin before the line if we want to
|
|
|
|
// reflow it or if its previous margin is dirty
|
2001-12-06 00:30:06 +00:00
|
|
|
PRBool needToRecoverState = PR_FALSE;
|
2010-08-06 04:59:20 +00:00
|
|
|
// Float continuations were reflowed in ReflowPushedFloats
|
2010-08-06 04:59:19 +00:00
|
|
|
PRBool reflowedFloat = mFloats.NotEmpty() &&
|
2010-08-06 04:59:20 +00:00
|
|
|
(mFloats.FirstChild()->GetStateBits() & NS_FRAME_IS_PUSHED_FLOAT);
|
2004-10-08 12:17:10 +00:00
|
|
|
PRBool lastLineMovedUp = PR_FALSE;
|
2004-11-25 14:51:00 +00:00
|
|
|
// We save up information about BR-clearance here
|
2009-08-31 18:25:36 +00:00
|
|
|
PRUint8 inlineFloatBreakType = aState.mFloatBreakType;
|
2004-11-25 14:51:00 +00:00
|
|
|
|
2001-10-25 01:08:40 +00:00
|
|
|
line_iterator line = begin_lines(), line_end = end_lines();
|
2004-11-29 22:02:11 +00:00
|
|
|
|
|
|
|
// Reflow the lines that are already ours
|
2001-10-25 01:08:40 +00:00
|
|
|
for ( ; line != line_end; ++line, aState.AdvanceToNextLine()) {
|
2005-03-23 03:35:08 +00:00
|
|
|
DumpLine(aState, line, deltaY, 0);
|
1999-10-15 23:35:10 +00:00
|
|
|
#ifdef DEBUG
|
2005-03-23 03:35:08 +00:00
|
|
|
AutoNoisyIndenter indent2(gNoisyReflow);
|
1998-12-05 16:02:08 +00:00
|
|
|
#endif
|
1999-10-15 23:35:10 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
if (selfDirty)
|
|
|
|
line->MarkDirty();
|
|
|
|
|
2004-11-25 14:51:00 +00:00
|
|
|
// This really sucks, but we have to look inside any blocks that have clear
|
|
|
|
// elements inside them.
|
|
|
|
// XXX what can we do smarter here?
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
if (!line->IsDirty() && line->IsBlock() &&
|
2004-11-25 14:51:00 +00:00
|
|
|
(line->mFirstChild->GetStateBits() & NS_BLOCK_HAS_CLEAR_CHILDREN)) {
|
|
|
|
line->MarkDirty();
|
|
|
|
}
|
|
|
|
|
2008-05-03 23:33:36 +00:00
|
|
|
nsIFrame *replacedBlock = nsnull;
|
2008-01-29 07:40:05 +00:00
|
|
|
if (line->IsBlock() &&
|
|
|
|
!nsBlockFrame::BlockCanIntersectFloats(line->mFirstChild)) {
|
2008-05-03 23:33:36 +00:00
|
|
|
replacedBlock = line->mFirstChild;
|
2008-01-29 07:40:05 +00:00
|
|
|
}
|
|
|
|
|
2004-11-25 14:51:00 +00:00
|
|
|
// We have to reflow the line if it's a block whose clearance
|
|
|
|
// might have changed, so detect that.
|
2008-01-29 07:40:05 +00:00
|
|
|
if (!line->IsDirty() &&
|
|
|
|
(line->GetBreakTypeBefore() != NS_STYLE_CLEAR_NONE ||
|
2008-05-03 23:33:36 +00:00
|
|
|
replacedBlock)) {
|
2004-11-25 14:51:00 +00:00
|
|
|
nscoord curY = aState.mY;
|
|
|
|
// See where we would be after applying any clearance due to
|
|
|
|
// BRs.
|
|
|
|
if (inlineFloatBreakType != NS_STYLE_CLEAR_NONE) {
|
|
|
|
curY = aState.ClearFloats(curY, inlineFloatBreakType);
|
|
|
|
}
|
|
|
|
|
2008-01-29 07:40:05 +00:00
|
|
|
nscoord newY =
|
2008-05-03 23:33:36 +00:00
|
|
|
aState.ClearFloats(curY, line->GetBreakTypeBefore(), replacedBlock);
|
2004-11-25 14:51:00 +00:00
|
|
|
|
|
|
|
if (line->HasClearance()) {
|
|
|
|
// Reflow the line if it might not have clearance anymore.
|
|
|
|
if (newY == curY
|
|
|
|
// aState.mY is the clearance point which should be the
|
|
|
|
// top border-edge of the block frame. If sliding the
|
|
|
|
// block by deltaY isn't going to put it in the predicted
|
|
|
|
// position, then we'd better reflow the line.
|
|
|
|
|| newY != line->mBounds.y + deltaY) {
|
|
|
|
line->MarkDirty();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Reflow the line if the line might have clearance now.
|
|
|
|
if (curY != newY) {
|
|
|
|
line->MarkDirty();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// We might have to reflow a line that is after a clearing BR.
|
|
|
|
if (inlineFloatBreakType != NS_STYLE_CLEAR_NONE) {
|
|
|
|
aState.mY = aState.ClearFloats(aState.mY, inlineFloatBreakType);
|
|
|
|
if (aState.mY != line->mBounds.y + deltaY) {
|
|
|
|
// SlideLine is not going to put the line where the clearance
|
|
|
|
// put it. Reflow the line to be sure.
|
|
|
|
line->MarkDirty();
|
|
|
|
}
|
|
|
|
inlineFloatBreakType = NS_STYLE_CLEAR_NONE;
|
|
|
|
}
|
|
|
|
|
2004-09-18 14:39:07 +00:00
|
|
|
PRBool previousMarginWasDirty = line->IsPreviousMarginDirty();
|
2004-10-08 12:17:10 +00:00
|
|
|
if (previousMarginWasDirty) {
|
2004-09-18 14:39:07 +00:00
|
|
|
// If the previous margin is dirty, reflow the current line
|
|
|
|
line->MarkDirty();
|
2004-10-08 12:17:10 +00:00
|
|
|
line->ClearPreviousMarginDirty();
|
|
|
|
} else if (line->mBounds.YMost() + deltaY > aState.mBottomEdge) {
|
|
|
|
// Lines that aren't dirty but get slid past our height constraint must
|
|
|
|
// be reflowed.
|
|
|
|
line->MarkDirty();
|
2005-02-02 01:33:20 +00:00
|
|
|
}
|
|
|
|
|
2010-08-06 04:59:20 +00:00
|
|
|
// If we have a constrained height (i.e., breaking columns/pages),
|
|
|
|
// and the distance to the bottom might have changed, then we need
|
|
|
|
// to reflow any line that might have floats in it, both because the
|
|
|
|
// breakpoints within those floats may have changed and because we
|
|
|
|
// might have to push/pull the floats in their entirety.
|
|
|
|
// FIXME: What about a deltaY or height change that forces us to
|
|
|
|
// push lines? Why does that work?
|
|
|
|
if (!line->IsDirty() &&
|
|
|
|
aState.mReflowState.availableHeight != NS_UNCONSTRAINEDSIZE &&
|
|
|
|
(deltaY != 0 || aState.mReflowState.mFlags.mVResize) &&
|
|
|
|
(line->IsBlock() || line->HasFloats() || line->HadFloatPushed())) {
|
|
|
|
line->MarkDirty();
|
|
|
|
}
|
|
|
|
|
2005-04-20 21:45:24 +00:00
|
|
|
if (!line->IsDirty()) {
|
|
|
|
// See if there's any reflow damage that requires that we mark the
|
|
|
|
// line dirty.
|
|
|
|
PropagateFloatDamage(aState, line, deltaY);
|
|
|
|
}
|
|
|
|
|
2005-02-02 01:33:20 +00:00
|
|
|
if (needToRecoverState && line->IsDirty()) {
|
|
|
|
// We need to reconstruct the bottom margin only if we didn't
|
|
|
|
// reflow the previous line and we do need to reflow (or repair
|
|
|
|
// the top position of) the next line.
|
|
|
|
aState.ReconstructMarginAbove(line);
|
|
|
|
}
|
|
|
|
|
2009-07-24 13:32:32 +00:00
|
|
|
PRBool reflowedPrevLine = !needToRecoverState;
|
2001-12-06 00:30:06 +00:00
|
|
|
if (needToRecoverState) {
|
|
|
|
needToRecoverState = PR_FALSE;
|
|
|
|
|
|
|
|
// Update aState.mPrevChild as if we had reflowed all of the frames in
|
|
|
|
// this line. This is expensive in some cases, since it requires
|
|
|
|
// walking |GetNextSibling|.
|
|
|
|
if (line->IsDirty())
|
|
|
|
aState.mPrevChild = line.prev()->LastChild();
|
|
|
|
}
|
|
|
|
|
2001-10-25 01:08:40 +00:00
|
|
|
// Now repair the line and update |aState.mY| by calling
|
|
|
|
// |ReflowLine| or |SlideLine|.
|
2007-12-01 08:29:02 +00:00
|
|
|
// If we're going to reflow everything again, then no need to reflow
|
|
|
|
// the dirty line ... unless the line has floats, in which case we'd
|
|
|
|
// better reflow it now to refresh its float cache, which may contain
|
|
|
|
// dangling frame pointers! Ugh! This reflow of the line may be
|
|
|
|
// incorrect because we skipped reflowing previous lines (e.g., floats
|
|
|
|
// may be placed incorrectly), but that's OK because we'll mark the
|
|
|
|
// line dirty below under "if (aState.mReflowState.mDiscoveredClearance..."
|
|
|
|
if (line->IsDirty() && (line->HasFloats() || !willReflowAgain)) {
|
2004-10-08 12:17:10 +00:00
|
|
|
lastLineMovedUp = PR_TRUE;
|
|
|
|
|
2004-10-10 01:56:00 +00:00
|
|
|
PRBool maybeReflowingForFirstTime =
|
|
|
|
line->mBounds.x == 0 && line->mBounds.y == 0 &&
|
|
|
|
line->mBounds.width == 0 && line->mBounds.height == 0;
|
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
// Compute the dirty lines "before" YMost, after factoring in
|
|
|
|
// the running deltaY value - the running value is implicit in
|
|
|
|
// aState.mY.
|
2001-10-25 01:08:40 +00:00
|
|
|
nscoord oldY = line->mBounds.y;
|
|
|
|
nscoord oldYMost = line->mBounds.YMost();
|
1998-12-05 16:02:08 +00:00
|
|
|
|
2007-12-05 02:57:53 +00:00
|
|
|
NS_ASSERTION(!willReflowAgain || !line->IsBlock(),
|
|
|
|
"Don't reflow blocks while willReflowAgain is true, reflow of block abs-pos children depends on this");
|
|
|
|
|
2000-06-11 22:14:33 +00:00
|
|
|
// Reflow the dirty line. If it's an incremental reflow, then force
|
|
|
|
// it to invalidate the dirty area if necessary
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
rv = ReflowLine(aState, line, &keepGoing);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2007-11-30 01:49:01 +00:00
|
|
|
|
2007-12-05 02:57:53 +00:00
|
|
|
if (aState.mReflowState.WillReflowAgainForClearance()) {
|
2007-11-30 01:49:01 +00:00
|
|
|
line->MarkDirty();
|
|
|
|
willReflowAgain = PR_TRUE;
|
2007-12-01 08:29:02 +00:00
|
|
|
// Note that once we've entered this state, every line that gets here
|
|
|
|
// (e.g. because it has floats) gets marked dirty and reflowed again.
|
|
|
|
// in the next pass. This is important, see above.
|
2007-11-30 01:49:01 +00:00
|
|
|
}
|
|
|
|
|
2005-03-23 03:35:08 +00:00
|
|
|
if (line->HasFloats()) {
|
|
|
|
reflowedFloat = PR_TRUE;
|
|
|
|
}
|
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
if (!keepGoing) {
|
2005-03-23 03:35:08 +00:00
|
|
|
DumpLine(aState, line, deltaY, -1);
|
1999-10-14 23:10:03 +00:00
|
|
|
if (0 == line->GetChildCount()) {
|
2001-10-25 01:08:40 +00:00
|
|
|
DeleteLine(aState, line, line_end);
|
1998-12-07 22:28:55 +00:00
|
|
|
}
|
1998-12-05 16:02:08 +00:00
|
|
|
break;
|
|
|
|
}
|
2004-09-18 14:39:07 +00:00
|
|
|
|
2005-08-21 23:18:11 +00:00
|
|
|
// Test to see whether the margin that should be carried out
|
|
|
|
// to the next line (NL) might have changed. In ReflowBlockFrame
|
|
|
|
// we call nextLine->MarkPreviousMarginDirty if the block's
|
|
|
|
// actual carried-out bottom margin changed. So here we only
|
|
|
|
// need to worry about the following effects:
|
|
|
|
// 1) the line was just created, and it might now be blocking
|
|
|
|
// a carried-out bottom margin from previous lines that
|
|
|
|
// used to reach NL from reaching NL
|
|
|
|
// 2) the line used to be empty, and is now not empty,
|
|
|
|
// thus blocking a carried-out bottom margin from previous lines
|
|
|
|
// that used to reach NL from reaching NL
|
|
|
|
// 3) the line wasn't empty, but now is, so a carried-out
|
|
|
|
// bottom margin from previous lines that didn't used to reach NL
|
|
|
|
// now does
|
|
|
|
// 4) the line might have changed in a way that affects NL's
|
|
|
|
// ShouldApplyTopMargin decision. The three things that matter
|
|
|
|
// are the line's emptiness, its adjacency to the top of the block,
|
|
|
|
// and whether it has clearance (the latter only matters if the block
|
|
|
|
// was and is adjacent to the top and empty).
|
|
|
|
//
|
|
|
|
// If the line is empty now, we can't reliably tell if the line was empty
|
|
|
|
// before, so we just assume it was and do nextLine->MarkPreviousMarginDirty.
|
|
|
|
// This means the checks in 4) are redundant; if the line is empty now
|
|
|
|
// we don't need to check 4), but if the line is not empty now and we're sure
|
|
|
|
// it wasn't empty before, any adjacency and clearance changes are irrelevant
|
|
|
|
// to the result of nextLine->ShouldApplyTopMargin.
|
|
|
|
if (line.next() != end_lines()) {
|
2007-11-15 19:07:04 +00:00
|
|
|
PRBool maybeWasEmpty = oldY == line.next()->mBounds.y;
|
2008-03-14 07:21:15 +00:00
|
|
|
PRBool isEmpty = line->CachedIsEmpty();
|
2005-08-21 23:18:11 +00:00
|
|
|
if (maybeReflowingForFirstTime /*1*/ ||
|
|
|
|
(isEmpty || maybeWasEmpty) /*2/3/4*/) {
|
|
|
|
line.next()->MarkPreviousMarginDirty();
|
|
|
|
// since it's marked dirty, nobody will care about |deltaY|
|
|
|
|
}
|
1999-07-14 15:16:56 +00:00
|
|
|
}
|
2004-10-10 01:56:00 +00:00
|
|
|
|
|
|
|
// If the line was just reflowed for the first time, then its
|
|
|
|
// old mBounds cannot be trusted so this deltaY computation is
|
|
|
|
// bogus. But that's OK because we just did
|
|
|
|
// MarkPreviousMarginDirty on the next line which will force it
|
|
|
|
// to be reflowed, so this computation of deltaY will not be
|
|
|
|
// used.
|
2004-10-08 12:17:10 +00:00
|
|
|
deltaY = line->mBounds.YMost() - oldYMost;
|
2009-07-30 15:53:36 +00:00
|
|
|
|
|
|
|
// Now do an interrupt check. We want to do this only in the case when we
|
|
|
|
// actually reflow the line, so that if we get back in here we'll get
|
|
|
|
// further on the reflow before interrupting.
|
|
|
|
aState.mPresContext->CheckForInterrupt(this);
|
2001-10-25 01:08:40 +00:00
|
|
|
} else {
|
2009-09-14 00:26:01 +00:00
|
|
|
aState.mOverflowTracker->Skip(line->mFirstChild, aState.mReflowStatus);
|
2007-07-26 04:03:29 +00:00
|
|
|
// Nop except for blocks (we don't create overflow container
|
|
|
|
// continuations for any inlines atm), so only checking mFirstChild
|
|
|
|
// is enough
|
|
|
|
|
2004-10-08 12:17:10 +00:00
|
|
|
lastLineMovedUp = deltaY < 0;
|
|
|
|
|
2001-10-25 01:08:40 +00:00
|
|
|
if (deltaY != 0)
|
|
|
|
SlideLine(aState, line, deltaY);
|
2002-04-08 23:57:37 +00:00
|
|
|
else
|
|
|
|
repositionViews = PR_TRUE;
|
2001-10-25 01:08:40 +00:00
|
|
|
|
2007-12-04 01:30:49 +00:00
|
|
|
NS_ASSERTION(!line->IsDirty() || !line->HasFloats(),
|
|
|
|
"Possibly stale float cache here!");
|
|
|
|
if (willReflowAgain && line->IsBlock()) {
|
|
|
|
// If we're going to reflow everything again, and this line is a block,
|
|
|
|
// then there is no need to recover float state. The line may contain
|
|
|
|
// other lines with floats, but in that case RecoverStateFrom would only
|
2009-01-05 00:39:54 +00:00
|
|
|
// add floats to the float manager. We don't need to do that because
|
2007-12-04 01:30:49 +00:00
|
|
|
// everything's going to get reflowed again "for real". Calling
|
|
|
|
// RecoverStateFrom in this situation could be lethal because the
|
|
|
|
// block's descendant lines may have float caches containing dangling
|
|
|
|
// frame pointers. Ugh!
|
|
|
|
// If this line is inline, then we need to recover its state now
|
|
|
|
// to make sure that we don't forget to move its floats by deltaY.
|
2007-12-01 08:29:02 +00:00
|
|
|
} else {
|
|
|
|
// XXX EVIL O(N^2) EVIL
|
|
|
|
aState.RecoverStateFrom(line, deltaY);
|
|
|
|
}
|
2001-10-25 01:08:40 +00:00
|
|
|
|
2004-08-25 13:10:06 +00:00
|
|
|
// Keep mY up to date in case we're propagating reflow damage
|
2004-11-25 14:51:00 +00:00
|
|
|
// and also because our final height may depend on it. If the
|
|
|
|
// line is inlines, then only update mY if the line is not
|
|
|
|
// empty, because that's what PlaceLine does. (Empty blocks may
|
|
|
|
// want to update mY, e.g. if they have clearance.)
|
|
|
|
if (line->IsBlock() || !line->CachedIsEmpty()) {
|
2004-08-25 13:10:06 +00:00
|
|
|
aState.mY = line->mBounds.YMost();
|
2004-09-13 02:21:35 +00:00
|
|
|
}
|
|
|
|
|
2001-12-06 00:30:06 +00:00
|
|
|
needToRecoverState = PR_TRUE;
|
2009-07-24 13:32:32 +00:00
|
|
|
|
|
|
|
if (reflowedPrevLine && !line->IsBlock() &&
|
|
|
|
aState.mPresContext->HasPendingInterrupt()) {
|
|
|
|
// Need to make sure to pull overflows from any prev-in-flows
|
|
|
|
for (nsIFrame* inlineKid = line->mFirstChild; inlineKid;
|
|
|
|
inlineKid = inlineKid->GetFirstChild(nsnull)) {
|
|
|
|
inlineKid->PullOverflowsFromPrevInFlow();
|
|
|
|
}
|
|
|
|
}
|
1998-09-02 21:59:54 +00:00
|
|
|
}
|
1999-10-15 23:35:10 +00:00
|
|
|
|
2005-07-28 19:50:04 +00:00
|
|
|
// Record if we need to clear floats before reflowing the next
|
|
|
|
// line. Note that inlineFloatBreakType will be handled and
|
|
|
|
// cleared before the next line is processed, so there is no
|
|
|
|
// need to combine break types here.
|
|
|
|
if (line->HasFloatBreakAfter()) {
|
|
|
|
inlineFloatBreakType = line->GetBreakTypeAfter();
|
|
|
|
}
|
|
|
|
|
2004-11-25 14:51:00 +00:00
|
|
|
if (LineHasClear(line.get())) {
|
|
|
|
foundAnyClears = PR_TRUE;
|
|
|
|
}
|
|
|
|
|
2005-03-23 03:35:08 +00:00
|
|
|
DumpLine(aState, line, deltaY, -1);
|
2009-04-21 23:53:52 +00:00
|
|
|
|
2009-07-30 15:53:36 +00:00
|
|
|
if (aState.mPresContext->HasPendingInterrupt()) {
|
2009-04-21 23:53:52 +00:00
|
|
|
willReflowAgain = PR_TRUE;
|
|
|
|
// Another option here might be to leave |line| clean if
|
|
|
|
// !HasPendingInterrupt() before the CheckForInterrupt() call, since in
|
|
|
|
// that case the line really did reflow as it should have. Not sure
|
|
|
|
// whether that would be safe, so doing this for now instead. Also not
|
|
|
|
// sure whether we really want to mark all lines dirty after an
|
|
|
|
// interrupt, but until we get better at propagating float damage we
|
|
|
|
// really do need to do it this way; see comments inside MarkLineDirty.
|
|
|
|
MarkLineDirtyForInterrupt(line);
|
|
|
|
}
|
2001-10-25 01:08:40 +00:00
|
|
|
}
|
1998-06-18 16:25:41 +00:00
|
|
|
|
2006-09-22 01:53:13 +00:00
|
|
|
// Handle BR-clearance from the last line of the block
|
|
|
|
if (inlineFloatBreakType != NS_STYLE_CLEAR_NONE) {
|
|
|
|
aState.mY = aState.ClearFloats(aState.mY, inlineFloatBreakType);
|
|
|
|
}
|
|
|
|
|
2001-12-06 00:30:06 +00:00
|
|
|
if (needToRecoverState) {
|
2001-10-25 01:08:40 +00:00
|
|
|
// Is this expensive?
|
|
|
|
aState.ReconstructMarginAbove(line);
|
2001-12-06 00:30:06 +00:00
|
|
|
|
|
|
|
// Update aState.mPrevChild as if we had reflowed all of the frames in
|
2004-07-27 18:22:14 +00:00
|
|
|
// the last line. This is expensive in some cases, since it requires
|
2001-12-06 00:30:06 +00:00
|
|
|
// walking |GetNextSibling|.
|
|
|
|
aState.mPrevChild = line.prev()->LastChild();
|
1998-06-25 16:33:10 +00:00
|
|
|
}
|
|
|
|
|
2002-04-08 23:57:37 +00:00
|
|
|
// Should we really have to do this?
|
|
|
|
if (repositionViews)
|
2004-12-27 15:05:18 +00:00
|
|
|
::PlaceFrameView(this);
|
2002-04-08 23:57:37 +00:00
|
|
|
|
2009-04-21 23:53:52 +00:00
|
|
|
// We can skip trying to pull up the next line if our height is constrained
|
|
|
|
// (so we can report being incomplete) and there is no next in flow or we
|
|
|
|
// were told not to or we know it will be futile, i.e.,
|
2005-03-23 03:35:08 +00:00
|
|
|
// -- the next in flow is not changing
|
|
|
|
// -- and we cannot have added more space for its first line to be
|
|
|
|
// pulled up into,
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
// -- it's an incremental reflow of a descendant
|
2005-03-23 03:35:08 +00:00
|
|
|
// -- and we didn't reflow any floats (so the available space
|
|
|
|
// didn't change)
|
2007-09-24 19:52:09 +00:00
|
|
|
// -- my chain of next-in-flows either has no first line, or its first
|
|
|
|
// line isn't dirty.
|
2009-04-21 23:53:52 +00:00
|
|
|
PRBool heightConstrained =
|
|
|
|
aState.mReflowState.availableHeight != NS_UNCONSTRAINEDSIZE;
|
|
|
|
PRBool skipPull = willReflowAgain && heightConstrained;
|
|
|
|
if (!skipPull && heightConstrained && aState.mNextInFlow &&
|
2005-03-23 03:35:08 +00:00
|
|
|
(aState.mReflowState.mFlags.mNextInFlowUntouched &&
|
|
|
|
!lastLineMovedUp &&
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
!(GetStateBits() & NS_FRAME_IS_DIRTY) &&
|
2005-03-23 03:35:08 +00:00
|
|
|
!reflowedFloat)) {
|
2007-09-24 19:52:09 +00:00
|
|
|
// We'll place lineIter at the last line of this block, so that
|
|
|
|
// nsBlockInFlowLineIterator::Next() will take us to the first
|
|
|
|
// line of my next-in-flow-chain. (But first, check that I
|
|
|
|
// have any lines -- if I don't, just bail out of this
|
|
|
|
// optimization.)
|
|
|
|
line_iterator lineIter = this->end_lines();
|
|
|
|
if (lineIter != this->begin_lines()) {
|
|
|
|
lineIter--; // I have lines; step back from dummy iterator to last line.
|
|
|
|
nsBlockInFlowLineIterator bifLineIter(this, lineIter, PR_FALSE);
|
|
|
|
|
|
|
|
// Check for next-in-flow-chain's first line.
|
|
|
|
// (First, see if there is such a line, and second, see if it's clean)
|
|
|
|
if (!bifLineIter.Next() ||
|
|
|
|
!bifLineIter.GetLine()->IsDirty()) {
|
|
|
|
skipPull=PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
2007-07-26 04:03:29 +00:00
|
|
|
}
|
2009-04-21 23:53:52 +00:00
|
|
|
|
|
|
|
if (skipPull && aState.mNextInFlow) {
|
|
|
|
NS_ASSERTION(heightConstrained, "Height should be constrained here\n");
|
|
|
|
if (IS_TRUE_OVERFLOW_CONTAINER(aState.mNextInFlow))
|
|
|
|
NS_FRAME_SET_OVERFLOW_INCOMPLETE(aState.mReflowStatus);
|
|
|
|
else
|
|
|
|
NS_FRAME_SET_INCOMPLETE(aState.mReflowStatus);
|
|
|
|
}
|
2007-09-24 19:52:09 +00:00
|
|
|
|
|
|
|
if (!skipPull && aState.mNextInFlow) {
|
2004-10-08 12:17:10 +00:00
|
|
|
// Pull data from a next-in-flow if there's still room for more
|
|
|
|
// content here.
|
|
|
|
while (keepGoing && (nsnull != aState.mNextInFlow)) {
|
|
|
|
// Grab first line from our next-in-flow
|
|
|
|
nsBlockFrame* nextInFlow = aState.mNextInFlow;
|
|
|
|
line_iterator nifLine = nextInFlow->begin_lines();
|
|
|
|
nsLineBox *toMove;
|
2009-09-29 19:47:05 +00:00
|
|
|
PRBool toMoveIsOverflowLine;
|
2004-10-08 12:17:10 +00:00
|
|
|
if (nifLine != nextInFlow->end_lines()) {
|
|
|
|
toMove = nifLine;
|
|
|
|
nextInFlow->mLines.erase(nifLine);
|
2009-09-29 19:47:05 +00:00
|
|
|
toMoveIsOverflowLine = PR_FALSE;
|
2004-10-08 12:17:10 +00:00
|
|
|
} else {
|
|
|
|
// Grab an overflow line if there are any
|
2005-03-23 03:35:08 +00:00
|
|
|
nsLineList* overflowLines = nextInFlow->GetOverflowLines();
|
2004-10-08 12:17:10 +00:00
|
|
|
if (!overflowLines) {
|
|
|
|
aState.mNextInFlow =
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<nsBlockFrame*>(nextInFlow->GetNextInFlow());
|
2004-10-08 12:17:10 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
nifLine = overflowLines->begin();
|
|
|
|
NS_ASSERTION(nifLine != overflowLines->end(),
|
|
|
|
"Stored overflow line list should not be empty");
|
|
|
|
toMove = nifLine;
|
2005-03-23 03:35:08 +00:00
|
|
|
nextInFlow->RemoveOverflowLines();
|
2004-10-08 12:17:10 +00:00
|
|
|
nifLine = overflowLines->erase(nifLine);
|
|
|
|
if (nifLine != overflowLines->end()) {
|
|
|
|
// We need to this remove-and-put-back dance because we want
|
|
|
|
// to avoid making the overflow line list empty while it's
|
|
|
|
// stored in the property (because the property has the
|
|
|
|
// invariant that the list is never empty).
|
|
|
|
nextInFlow->SetOverflowLines(overflowLines);
|
2009-09-29 01:23:33 +00:00
|
|
|
} else {
|
|
|
|
delete overflowLines;
|
2004-10-08 12:17:10 +00:00
|
|
|
}
|
2009-09-29 19:47:05 +00:00
|
|
|
toMoveIsOverflowLine = PR_TRUE;
|
2004-10-08 12:17:10 +00:00
|
|
|
}
|
2004-08-26 12:38:50 +00:00
|
|
|
|
2004-10-08 12:17:10 +00:00
|
|
|
if (0 == toMove->GetChildCount()) {
|
|
|
|
// The line is empty. Try the next one.
|
|
|
|
NS_ASSERTION(nsnull == toMove->mFirstChild, "bad empty line");
|
|
|
|
aState.FreeLineBox(toMove);
|
|
|
|
continue;
|
|
|
|
}
|
1998-06-18 16:25:41 +00:00
|
|
|
|
2004-10-08 12:17:10 +00:00
|
|
|
// XXX move to a subroutine: run-in, overflow, pullframe and this do this
|
|
|
|
// Make the children in the line ours.
|
|
|
|
nsIFrame* frame = toMove->mFirstChild;
|
|
|
|
nsIFrame* lastFrame = nsnull;
|
|
|
|
PRInt32 n = toMove->GetChildCount();
|
|
|
|
while (--n >= 0) {
|
|
|
|
ReparentFrame(frame, nextInFlow, this);
|
|
|
|
lastFrame = frame;
|
|
|
|
frame = frame->GetNextSibling();
|
|
|
|
}
|
1998-11-14 19:28:11 +00:00
|
|
|
|
2009-09-29 19:47:05 +00:00
|
|
|
NS_ASSERTION(lastFrame == toMove->LastChild(), "Unexpected lastFrame");
|
2005-03-23 03:35:08 +00:00
|
|
|
|
2009-09-10 22:26:30 +00:00
|
|
|
NS_ASSERTION(aState.mPrevChild || mLines.empty(), "should have a prevchild here");
|
|
|
|
|
2009-09-29 19:47:05 +00:00
|
|
|
NS_ASSERTION(aState.mPrevChild == mFrames.LastChild(),
|
|
|
|
"Incorrect aState.mPrevChild before inserting line at end");
|
|
|
|
|
|
|
|
// Shift toMove's frames into our mFrames list.
|
|
|
|
if (toMoveIsOverflowLine) {
|
|
|
|
// Pulling from an overflow list
|
|
|
|
// XXXbz If we switch overflow lines to nsFrameList, we should
|
|
|
|
// change this SetNextSibling call.
|
|
|
|
lastFrame->SetNextSibling(nsnull);
|
|
|
|
} else {
|
|
|
|
// Pulling from nextInFlow->mFrames
|
|
|
|
nsFrameList::FrameLinkEnumerator linkToBreak(nextInFlow->mFrames, lastFrame);
|
|
|
|
nextInFlow->mFrames.ExtractHead(linkToBreak);
|
2004-10-08 12:17:10 +00:00
|
|
|
}
|
2009-09-29 19:47:05 +00:00
|
|
|
nsFrameList newFrames(toMove->mFirstChild, lastFrame);
|
|
|
|
mFrames.AppendFrames(nsnull, newFrames);
|
1998-06-18 16:25:41 +00:00
|
|
|
|
2009-09-29 19:47:05 +00:00
|
|
|
// Add line to our line list, and set its last child as our new prev-child
|
2004-10-08 12:17:10 +00:00
|
|
|
line = mLines.before_insert(end_lines(), toMove);
|
2009-09-29 19:47:05 +00:00
|
|
|
aState.mPrevChild = lastFrame;
|
|
|
|
|
|
|
|
NS_ASSERTION(aState.mPrevChild == mFrames.LastChild(),
|
|
|
|
"Incorrect aState.mPrevChild after inserting line at end");
|
|
|
|
|
|
|
|
// Reparent floats whose placeholders are in the line.
|
|
|
|
ReparentFloats(toMove->mFirstChild, nextInFlow, toMoveIsOverflowLine, PR_TRUE);
|
2001-09-21 13:41:52 +00:00
|
|
|
|
2005-03-23 03:35:08 +00:00
|
|
|
DumpLine(aState, toMove, deltaY, 0);
|
|
|
|
#ifdef DEBUG
|
|
|
|
AutoNoisyIndenter indent2(gNoisyReflow);
|
|
|
|
#endif
|
2001-09-21 13:41:52 +00:00
|
|
|
|
2009-04-21 23:53:52 +00:00
|
|
|
if (aState.mPresContext->HasPendingInterrupt()) {
|
|
|
|
MarkLineDirtyForInterrupt(line);
|
|
|
|
} else {
|
|
|
|
// Now reflow it and any lines that it makes during it's reflow
|
2009-06-13 01:28:41 +00:00
|
|
|
// (we have to loop here because reflowing the line may cause a new
|
2009-04-21 23:53:52 +00:00
|
|
|
// line to be created; see SplitLine's callers for examples of
|
|
|
|
// when this happens).
|
|
|
|
while (line != end_lines()) {
|
|
|
|
rv = ReflowLine(aState, line, &keepGoing);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2010-05-13 00:56:08 +00:00
|
|
|
|
|
|
|
if (aState.mReflowState.WillReflowAgainForClearance()) {
|
|
|
|
line->MarkDirty();
|
|
|
|
keepGoing = PR_FALSE;
|
2010-08-06 04:59:20 +00:00
|
|
|
NS_FRAME_SET_INCOMPLETE(aState.mReflowStatus);
|
2010-05-13 00:56:08 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-04-21 23:53:52 +00:00
|
|
|
DumpLine(aState, line, deltaY, -1);
|
|
|
|
if (!keepGoing) {
|
|
|
|
if (0 == line->GetChildCount()) {
|
|
|
|
DeleteLine(aState, line, line_end);
|
|
|
|
}
|
|
|
|
break;
|
2009-04-21 23:53:52 +00:00
|
|
|
}
|
2004-11-25 14:51:00 +00:00
|
|
|
|
2009-04-21 23:53:52 +00:00
|
|
|
if (LineHasClear(line.get())) {
|
|
|
|
foundAnyClears = PR_TRUE;
|
|
|
|
}
|
2009-04-22 03:02:17 +00:00
|
|
|
|
2009-04-21 23:53:52 +00:00
|
|
|
if (aState.mPresContext->CheckForInterrupt(this)) {
|
|
|
|
MarkLineDirtyForInterrupt(line);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If this is an inline frame then its time to stop
|
|
|
|
++line;
|
|
|
|
aState.AdvanceToNextLine();
|
|
|
|
}
|
1998-12-05 16:02:08 +00:00
|
|
|
}
|
2004-10-08 12:17:10 +00:00
|
|
|
}
|
1998-11-14 19:28:11 +00:00
|
|
|
|
2004-10-08 12:17:10 +00:00
|
|
|
if (NS_FRAME_IS_NOT_COMPLETE(aState.mReflowStatus)) {
|
|
|
|
aState.mReflowStatus |= NS_FRAME_REFLOW_NEXTINFLOW;
|
2007-07-26 04:03:29 +00:00
|
|
|
} //XXXfr shouldn't set this flag when nextinflow has no lines
|
1998-12-05 16:02:08 +00:00
|
|
|
}
|
1998-11-14 19:28:11 +00:00
|
|
|
|
1999-07-14 17:26:20 +00:00
|
|
|
// Handle an odd-ball case: a list-item with no lines
|
2001-10-25 01:08:40 +00:00
|
|
|
if (mBullet && HaveOutsideBullet() && mLines.empty()) {
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsHTMLReflowMetrics metrics;
|
2008-02-10 21:49:24 +00:00
|
|
|
ReflowBullet(aState, metrics,
|
|
|
|
aState.mReflowState.mComputedBorderPadding.top);
|
2009-09-11 10:46:36 +00:00
|
|
|
NS_ASSERTION(!BulletIsEmpty() || metrics.height == 0,
|
|
|
|
"empty bullet took up space");
|
1999-08-27 21:45:37 +00:00
|
|
|
|
2009-09-11 10:46:36 +00:00
|
|
|
if (!BulletIsEmpty()) {
|
|
|
|
// There are no lines so we have to fake up some y motion so that
|
|
|
|
// we end up with *some* height.
|
2009-08-11 02:48:42 +00:00
|
|
|
|
2009-09-11 10:46:36 +00:00
|
|
|
if (metrics.ascent == nsHTMLReflowMetrics::ASK_FOR_BASELINE &&
|
|
|
|
!nsLayoutUtils::GetFirstLineBaseline(mBullet, &metrics.ascent)) {
|
|
|
|
metrics.ascent = metrics.height;
|
|
|
|
}
|
2009-08-11 02:48:42 +00:00
|
|
|
|
2011-04-08 01:04:40 +00:00
|
|
|
nsRenderingContext *rc = aState.mReflowState.rendContext;
|
2009-09-11 10:46:36 +00:00
|
|
|
nsLayoutUtils::SetFontFromStyle(rc, GetStyleContext());
|
2009-08-11 02:48:42 +00:00
|
|
|
|
2009-09-11 10:46:36 +00:00
|
|
|
nscoord minAscent =
|
2011-04-08 01:04:40 +00:00
|
|
|
nsLayoutUtils::GetCenteredFontBaseline(rc->FontMetrics(),
|
|
|
|
aState.mMinLineHeight);
|
2009-09-11 10:46:36 +00:00
|
|
|
nscoord minDescent = aState.mMinLineHeight - minAscent;
|
2009-08-11 02:48:42 +00:00
|
|
|
|
2009-09-16 15:01:36 +00:00
|
|
|
aState.mY += NS_MAX(minAscent, metrics.ascent) +
|
|
|
|
NS_MAX(minDescent, metrics.height - metrics.ascent);
|
2009-08-11 02:48:42 +00:00
|
|
|
|
2009-09-11 10:46:36 +00:00
|
|
|
nscoord offset = minAscent - metrics.ascent;
|
|
|
|
if (offset > 0) {
|
|
|
|
mBullet->SetRect(mBullet->GetRect() + nsPoint(0, offset));
|
|
|
|
}
|
2009-08-11 02:48:42 +00:00
|
|
|
}
|
1999-07-14 17:26:20 +00:00
|
|
|
}
|
|
|
|
|
2004-11-25 14:51:00 +00:00
|
|
|
if (foundAnyClears) {
|
|
|
|
AddStateBits(NS_BLOCK_HAS_CLEAR_CHILDREN);
|
|
|
|
} else {
|
|
|
|
RemoveStateBits(NS_BLOCK_HAS_CLEAR_CHILDREN);
|
|
|
|
}
|
|
|
|
|
1999-10-15 23:35:10 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (gNoisyReflow) {
|
2005-03-23 03:35:08 +00:00
|
|
|
IndentBy(stdout, gNoiseIndent - 1);
|
1999-10-15 23:35:10 +00:00
|
|
|
ListTag(stdout);
|
2000-10-28 22:17:53 +00:00
|
|
|
printf(": done reflowing dirty lines (status=%x)\n",
|
1999-10-15 23:35:10 +00:00
|
|
|
aState.mReflowStatus);
|
|
|
|
}
|
1998-12-05 16:02:08 +00:00
|
|
|
#endif
|
1998-06-27 22:56:09 +00:00
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
return rv;
|
1998-06-24 17:52:42 +00:00
|
|
|
}
|
1998-06-18 16:25:41 +00:00
|
|
|
|
2009-04-21 23:53:52 +00:00
|
|
|
static void MarkAllDescendantLinesDirty(nsBlockFrame* aBlock)
|
|
|
|
{
|
|
|
|
nsLineList::iterator line = aBlock->begin_lines();
|
|
|
|
nsLineList::iterator endLine = aBlock->end_lines();
|
|
|
|
while (line != endLine) {
|
|
|
|
if (line->IsBlock()) {
|
|
|
|
nsIFrame* f = line->mFirstChild;
|
|
|
|
nsBlockFrame* bf = nsLayoutUtils::GetAsBlock(f);
|
|
|
|
if (bf) {
|
|
|
|
MarkAllDescendantLinesDirty(bf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
line->MarkDirty();
|
|
|
|
++line;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBlockFrame::MarkLineDirtyForInterrupt(nsLineBox* aLine)
|
|
|
|
{
|
|
|
|
aLine->MarkDirty();
|
|
|
|
|
|
|
|
// Just checking NS_FRAME_IS_DIRTY is ok, because we've already
|
|
|
|
// marked the lines that need to be marked dirty based on our
|
|
|
|
// vertical resize stuff. So we'll definitely reflow all those kids;
|
|
|
|
// the only question is how they should behave.
|
|
|
|
if (GetStateBits() & NS_FRAME_IS_DIRTY) {
|
|
|
|
// Mark all our child frames dirty so we make sure to reflow them
|
|
|
|
// later.
|
|
|
|
PRInt32 n = aLine->GetChildCount();
|
|
|
|
for (nsIFrame* f = aLine->mFirstChild; n > 0;
|
|
|
|
f = f->GetNextSibling(), --n) {
|
|
|
|
f->AddStateBits(NS_FRAME_IS_DIRTY);
|
2009-05-10 03:51:34 +00:00
|
|
|
}
|
|
|
|
// And mark all the floats whose reflows we might be skipping dirty too.
|
|
|
|
if (aLine->HasFloats()) {
|
|
|
|
for (nsFloatCache* fc = aLine->GetFirstFloat(); fc; fc = fc->Next()) {
|
2009-08-31 18:25:35 +00:00
|
|
|
fc->mFloat->AddStateBits(NS_FRAME_IS_DIRTY);
|
2009-04-21 23:53:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Dirty all the descendant lines of block kids to handle float damage,
|
|
|
|
// since our nsFloatManager will go away by the next time we're reflowing.
|
|
|
|
// XXXbz Can we do something more like what PropagateFloatDamage does?
|
|
|
|
// Would need to sort out the exact business with mBlockDelta for that....
|
|
|
|
// This marks way too much dirty. If we ever make this better, revisit
|
|
|
|
// which lines we mark dirty in the interrupt case in ReflowDirtyLines.
|
|
|
|
nsBlockFrame* bf = nsLayoutUtils::GetAsBlock(aLine->mFirstChild);
|
|
|
|
if (bf) {
|
|
|
|
MarkAllDescendantLinesDirty(bf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-07 22:28:55 +00:00
|
|
|
void
|
1999-02-09 17:31:33 +00:00
|
|
|
nsBlockFrame::DeleteLine(nsBlockReflowState& aState,
|
2001-10-25 01:08:40 +00:00
|
|
|
nsLineList::iterator aLine,
|
|
|
|
nsLineList::iterator aLineEnd)
|
1998-12-07 22:28:55 +00:00
|
|
|
{
|
1999-10-14 23:10:03 +00:00
|
|
|
NS_PRECONDITION(0 == aLine->GetChildCount(), "can't delete !empty line");
|
|
|
|
if (0 == aLine->GetChildCount()) {
|
2001-10-25 01:08:40 +00:00
|
|
|
NS_ASSERTION(aState.mCurrentLine == aLine,
|
|
|
|
"using function more generally than designed, "
|
|
|
|
"but perhaps OK now");
|
|
|
|
nsLineBox *line = aLine;
|
|
|
|
aLine = mLines.erase(aLine);
|
|
|
|
aState.FreeLineBox(line);
|
|
|
|
// Mark the previous margin of the next line dirty since we need to
|
|
|
|
// recompute its top position.
|
|
|
|
if (aLine != aLineEnd)
|
|
|
|
aLine->MarkPreviousMarginDirty();
|
1998-12-07 22:28:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-12 14:59:15 +00:00
|
|
|
static void
|
|
|
|
InvalidateThebesLayersInLineBox(nsIFrame* aBlock, nsLineBox* aLine)
|
|
|
|
{
|
|
|
|
if (aBlock->GetStateBits() & NS_FRAME_HAS_CONTAINER_LAYER_DESCENDANT) {
|
|
|
|
PRInt32 childCount = aLine->GetChildCount();
|
|
|
|
for (nsIFrame* f = aLine->mFirstChild; childCount;
|
|
|
|
--childCount, f = f->GetNextSibling()) {
|
|
|
|
FrameLayerBuilder::InvalidateThebesLayersInSubtree(f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
/**
|
|
|
|
* Reflow a line. The line will either contain a single block frame
|
2000-03-22 23:19:10 +00:00
|
|
|
* or contain 1 or more inline frames. aKeepReflowGoing indicates
|
1998-12-05 16:02:08 +00:00
|
|
|
* whether or not the caller should continue to reflow more lines.
|
|
|
|
*/
|
|
|
|
nsresult
|
1999-02-09 17:31:33 +00:00
|
|
|
nsBlockFrame::ReflowLine(nsBlockReflowState& aState,
|
2001-10-25 01:08:40 +00:00
|
|
|
line_iterator aLine,
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
PRBool* aKeepReflowGoing)
|
1998-11-19 18:09:57 +00:00
|
|
|
{
|
1998-12-05 16:02:08 +00:00
|
|
|
nsresult rv = NS_OK;
|
1998-11-11 03:55:55 +00:00
|
|
|
|
1999-10-14 23:10:03 +00:00
|
|
|
NS_ABORT_IF_FALSE(aLine->GetChildCount(), "reflowing empty line");
|
1998-11-11 03:55:55 +00:00
|
|
|
|
1999-02-09 17:31:33 +00:00
|
|
|
// Setup the line-layout for the new line
|
1998-12-05 16:02:08 +00:00
|
|
|
aState.mCurrentLine = aLine;
|
|
|
|
aLine->ClearDirty();
|
2004-11-24 13:22:10 +00:00
|
|
|
aLine->InvalidateCachedIsEmpty();
|
2010-08-06 04:59:20 +00:00
|
|
|
aLine->ClearHadFloatPushed();
|
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
// Now that we know what kind of line we have, reflow it
|
|
|
|
if (aLine->IsBlock()) {
|
2004-06-29 12:46:46 +00:00
|
|
|
nsRect oldBounds = aLine->mFirstChild->GetRect();
|
2010-10-07 04:25:45 +00:00
|
|
|
nsRect oldVisOverflow(aLine->GetVisualOverflowArea());
|
1999-03-18 21:03:25 +00:00
|
|
|
rv = ReflowBlockFrame(aState, aLine, aKeepReflowGoing);
|
2004-06-29 12:46:46 +00:00
|
|
|
nsRect newBounds = aLine->mFirstChild->GetRect();
|
2002-03-26 20:03:41 +00:00
|
|
|
|
1999-07-14 15:16:56 +00:00
|
|
|
// We expect blocks to damage any area inside their bounds that is
|
|
|
|
// dirty; however, if the frame changes size or position then we
|
2004-06-29 12:46:46 +00:00
|
|
|
// need to do some repainting.
|
|
|
|
// XXX roc --- the above statement is ambiguous about whether 'bounds'
|
|
|
|
// means the frame's bounds or overflowArea, and in fact this is a source
|
|
|
|
// of much confusion and bugs. Thus the following hack considers *both*
|
|
|
|
// overflowArea and bounds. This should be considered a temporary hack
|
|
|
|
// until we decide how it's really supposed to work.
|
2008-03-16 20:32:48 +00:00
|
|
|
// Note that we have a similar hack in nsTableFrame::InvalidateFrame.
|
2010-10-07 04:25:45 +00:00
|
|
|
nsRect visOverflow(aLine->GetVisualOverflowArea());
|
|
|
|
if (oldVisOverflow.TopLeft() != visOverflow.TopLeft() ||
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
oldBounds.TopLeft() != newBounds.TopLeft()) {
|
|
|
|
// The block has moved, and so to be safe we need to repaint
|
|
|
|
// XXX We need to improve on this...
|
|
|
|
nsRect dirtyRect;
|
2010-10-07 04:25:45 +00:00
|
|
|
dirtyRect.UnionRect(oldVisOverflow, visOverflow);
|
2000-04-17 14:40:46 +00:00
|
|
|
#ifdef NOISY_BLOCK_INVALIDATE
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
printf("%p invalidate 6 (%d, %d, %d, %d)\n",
|
|
|
|
this, dirtyRect.x, dirtyRect.y, dirtyRect.width, dirtyRect.height);
|
2000-04-17 14:40:46 +00:00
|
|
|
#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 05:38:33 +00:00
|
|
|
Invalidate(dirtyRect);
|
2010-08-31 00:49:13 +00:00
|
|
|
FrameLayerBuilder::InvalidateThebesLayersInSubtree(aLine->mFirstChild);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
} else {
|
|
|
|
nsRect combinedAreaHStrip, combinedAreaVStrip;
|
|
|
|
nsRect boundsHStrip, boundsVStrip;
|
2008-02-08 09:36:32 +00:00
|
|
|
nsLayoutUtils::GetRectDifferenceStrips(oldBounds, newBounds,
|
|
|
|
&boundsHStrip, &boundsVStrip);
|
2010-10-07 04:25:45 +00:00
|
|
|
nsLayoutUtils::GetRectDifferenceStrips(oldVisOverflow, visOverflow,
|
2008-02-08 09:36:32 +00:00
|
|
|
&combinedAreaHStrip,
|
|
|
|
&combinedAreaVStrip);
|
2004-06-29 12:46:46 +00:00
|
|
|
|
2000-04-17 14:40:46 +00:00
|
|
|
#ifdef NOISY_BLOCK_INVALIDATE
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
printf("%p invalidate boundsVStrip (%d, %d, %d, %d)\n",
|
|
|
|
this, boundsVStrip.x, boundsVStrip.y, boundsVStrip.width, boundsVStrip.height);
|
|
|
|
printf("%p invalidate boundsHStrip (%d, %d, %d, %d)\n",
|
|
|
|
this, boundsHStrip.x, boundsHStrip.y, boundsHStrip.width, boundsHStrip.height);
|
|
|
|
printf("%p invalidate combinedAreaVStrip (%d, %d, %d, %d)\n",
|
|
|
|
this, combinedAreaVStrip.x, combinedAreaVStrip.y, combinedAreaVStrip.width, combinedAreaVStrip.height);
|
|
|
|
printf("%p invalidate combinedAreaHStrip (%d, %d, %d, %d)\n",
|
|
|
|
this, combinedAreaHStrip.x, combinedAreaHStrip.y, combinedAreaHStrip.width, combinedAreaHStrip.height);
|
2000-04-17 14:40:46 +00:00
|
|
|
#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 05:38:33 +00:00
|
|
|
// The first thing Invalidate does is check if the rect is empty, so
|
|
|
|
// don't bother doing that here.
|
|
|
|
Invalidate(boundsVStrip);
|
|
|
|
Invalidate(boundsHStrip);
|
|
|
|
Invalidate(combinedAreaVStrip);
|
|
|
|
Invalidate(combinedAreaHStrip);
|
1999-07-14 15:16:56 +00:00
|
|
|
}
|
1998-06-18 16:25:41 +00:00
|
|
|
}
|
|
|
|
else {
|
2010-10-07 04:25:45 +00:00
|
|
|
nsRect oldVisOverflow(aLine->GetVisualOverflowArea());
|
2000-01-03 04:32:13 +00:00
|
|
|
aLine->SetLineWrapped(PR_FALSE);
|
2000-01-08 03:58:27 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
rv = ReflowInlineFrames(aState, aLine, aKeepReflowGoing);
|
1999-07-14 15:16:56 +00:00
|
|
|
|
|
|
|
// We don't really know what changed in the line, so use the union
|
|
|
|
// of the old and new combined areas
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsRect dirtyRect;
|
2010-10-07 04:25:45 +00:00
|
|
|
dirtyRect.UnionRect(oldVisOverflow, aLine->GetVisualOverflowArea());
|
2000-04-17 14:40:46 +00:00
|
|
|
#ifdef NOISY_BLOCK_INVALIDATE
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
printf("%p invalidate (%d, %d, %d, %d)\n",
|
|
|
|
this, dirtyRect.x, dirtyRect.y, dirtyRect.width, dirtyRect.height);
|
|
|
|
if (aLine->IsForceInvalidate())
|
2010-08-31 16:05:12 +00:00
|
|
|
printf(" dirty line is %p\n", static_cast<void*>(aLine.get()));
|
2000-04-17 14:40:46 +00:00
|
|
|
#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 05:38:33 +00:00
|
|
|
Invalidate(dirtyRect);
|
2011-05-12 14:59:15 +00:00
|
|
|
InvalidateThebesLayersInLineBox(this, aLine);
|
1998-06-18 16:25:41 +00:00
|
|
|
}
|
1998-11-14 19:28:11 +00:00
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
return rv;
|
1998-06-18 16:25:41 +00:00
|
|
|
}
|
|
|
|
|
2010-01-11 14:08:23 +00:00
|
|
|
nsIFrame*
|
1999-02-09 17:31:33 +00:00
|
|
|
nsBlockFrame::PullFrame(nsBlockReflowState& aState,
|
2010-01-11 14:08:23 +00:00
|
|
|
line_iterator aLine)
|
1998-11-14 19:28:11 +00:00
|
|
|
{
|
2010-01-11 14:08:23 +00:00
|
|
|
// First check our remaining lines.
|
2002-01-02 22:10:13 +00:00
|
|
|
if (end_lines() != aLine.next()) {
|
2010-01-11 14:08:23 +00:00
|
|
|
return PullFrameFrom(aState, aLine, this, PR_FALSE, aLine.next());
|
1998-11-14 19:28:11 +00:00
|
|
|
}
|
1998-11-17 01:04:45 +00:00
|
|
|
|
2004-10-08 12:17:10 +00:00
|
|
|
NS_ASSERTION(!GetOverflowLines(),
|
|
|
|
"Our overflow lines should have been removed at the start of reflow");
|
|
|
|
|
2010-01-11 14:08:23 +00:00
|
|
|
// Try each next-in-flow.
|
1999-02-09 17:31:33 +00:00
|
|
|
nsBlockFrame* nextInFlow = aState.mNextInFlow;
|
2004-10-08 12:17:10 +00:00
|
|
|
while (nextInFlow) {
|
|
|
|
// first normal lines, then overflow lines
|
|
|
|
if (!nextInFlow->mLines.empty()) {
|
2010-01-11 14:08:23 +00:00
|
|
|
return PullFrameFrom(aState, aLine, nextInFlow, PR_FALSE,
|
|
|
|
nextInFlow->mLines.begin());
|
2004-10-08 12:17:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsLineList* overflowLines = nextInFlow->GetOverflowLines();
|
|
|
|
if (overflowLines) {
|
2010-01-11 14:08:23 +00:00
|
|
|
return PullFrameFrom(aState, aLine, nextInFlow, PR_TRUE,
|
|
|
|
overflowLines->begin());
|
1998-12-05 16:02:08 +00:00
|
|
|
}
|
2002-01-02 22:10:13 +00:00
|
|
|
|
2010-01-11 14:08:23 +00:00
|
|
|
nextInFlow = static_cast<nsBlockFrame*>(nextInFlow->GetNextInFlow());
|
2002-01-02 22:10:13 +00:00
|
|
|
aState.mNextInFlow = nextInFlow;
|
1998-11-17 01:04:45 +00:00
|
|
|
}
|
2002-01-02 22:10:13 +00:00
|
|
|
|
2010-01-11 14:08:23 +00:00
|
|
|
return nsnull;
|
1998-11-14 19:28:11 +00:00
|
|
|
}
|
|
|
|
|
2010-01-11 14:08:23 +00:00
|
|
|
nsIFrame*
|
|
|
|
nsBlockFrame::PullFrameFrom(nsBlockReflowState& aState,
|
|
|
|
nsLineBox* aLine,
|
|
|
|
nsBlockFrame* aFromContainer,
|
|
|
|
PRBool aFromOverflowLine,
|
|
|
|
nsLineList::iterator aFromLine)
|
1998-06-18 16:25:41 +00:00
|
|
|
{
|
2001-10-25 01:08:40 +00:00
|
|
|
nsLineBox* fromLine = aFromLine;
|
1999-10-14 23:10:03 +00:00
|
|
|
NS_ABORT_IF_FALSE(fromLine, "bad line to pull from");
|
|
|
|
NS_ABORT_IF_FALSE(fromLine->GetChildCount(), "empty line");
|
|
|
|
NS_ABORT_IF_FALSE(aLine->GetChildCount(), "empty line");
|
|
|
|
|
2007-06-27 02:31:35 +00:00
|
|
|
NS_ASSERTION(fromLine->IsBlock() == fromLine->mFirstChild->GetStyleDisplay()->IsBlockOutside(),
|
2005-03-23 03:35:08 +00:00
|
|
|
"Disagreement about whether it's a block or not");
|
|
|
|
|
1999-10-14 23:10:03 +00:00
|
|
|
if (fromLine->IsBlock()) {
|
1998-12-05 16:02:08 +00:00
|
|
|
// If our line is not empty and the child in aFromLine is a block
|
|
|
|
// then we cannot pull up the frame into this line. In this case
|
|
|
|
// we stop pulling.
|
2010-01-11 14:08:23 +00:00
|
|
|
return nsnull;
|
1998-12-05 16:02:08 +00:00
|
|
|
}
|
2010-01-11 14:08:23 +00:00
|
|
|
// Take frame from fromLine
|
|
|
|
nsIFrame* frame = fromLine->mFirstChild;
|
|
|
|
nsIFrame* newFirstChild = frame->GetNextSibling();
|
|
|
|
|
|
|
|
if (aFromContainer != this) {
|
|
|
|
NS_ASSERTION(aState.mPrevChild == aLine->LastChild(),
|
|
|
|
"mPrevChild should be the LastChild of the line we are adding to");
|
|
|
|
// The frame is being pulled from a next-in-flow; therefore we
|
|
|
|
// need to add it to our sibling list.
|
|
|
|
if (NS_LIKELY(!aFromOverflowLine)) {
|
|
|
|
NS_ASSERTION(aFromLine == aFromContainer->mLines.begin(),
|
|
|
|
"should only pull from first line");
|
|
|
|
// Pulling from the next-in-flow's normal line list
|
|
|
|
aFromContainer->mFrames.RemoveFrame(frame);
|
|
|
|
} else {
|
|
|
|
// Pulling from the next-in-flow's overflow list
|
|
|
|
// XXXbz If we switch overflow lines to nsFrameList, we should
|
|
|
|
// change this SetNextSibling call.
|
|
|
|
frame->SetNextSibling(nsnull);
|
|
|
|
}
|
2009-09-29 19:47:05 +00:00
|
|
|
|
2010-01-11 14:08:23 +00:00
|
|
|
// When pushing and pulling frames we need to check for whether any
|
|
|
|
// views need to be reparented
|
|
|
|
NS_ASSERTION(frame->GetParent() == aFromContainer, "unexpected parent frame");
|
2009-09-29 19:47:05 +00:00
|
|
|
|
2010-01-11 14:08:23 +00:00
|
|
|
ReparentFrame(frame, aFromContainer, this);
|
|
|
|
mFrames.InsertFrame(nsnull, aState.mPrevChild, frame);
|
2009-09-29 19:47:05 +00:00
|
|
|
|
2010-01-11 14:08:23 +00:00
|
|
|
// The frame might have (or contain) floats that need to be
|
|
|
|
// brought over too.
|
|
|
|
ReparentFloats(frame, aFromContainer, aFromOverflowLine, PR_TRUE);
|
|
|
|
}
|
|
|
|
// when aFromContainer is 'this', then aLine->LastChild()'s next sibling
|
|
|
|
// is already set correctly.
|
|
|
|
aLine->SetChildCount(aLine->GetChildCount() + 1);
|
|
|
|
|
|
|
|
PRInt32 fromLineChildCount = fromLine->GetChildCount();
|
|
|
|
if (0 != --fromLineChildCount) {
|
|
|
|
// Mark line dirty now that we pulled a child
|
|
|
|
fromLine->SetChildCount(fromLineChildCount);
|
|
|
|
fromLine->MarkDirty();
|
|
|
|
fromLine->mFirstChild = newFirstChild;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Free up the fromLine now that it's empty
|
|
|
|
// Its bounds might need to be redrawn, though.
|
|
|
|
// XXX WHY do we invalidate the bounds AND the combined area? doesn't
|
|
|
|
// the combined area always enclose the bounds?
|
|
|
|
Invalidate(fromLine->mBounds);
|
|
|
|
nsLineList* fromLineList = aFromOverflowLine
|
|
|
|
? aFromContainer->RemoveOverflowLines()
|
|
|
|
: &aFromContainer->mLines;
|
|
|
|
if (aFromLine.next() != fromLineList->end())
|
|
|
|
aFromLine.next()->MarkPreviousMarginDirty();
|
|
|
|
|
2010-10-07 04:25:45 +00:00
|
|
|
Invalidate(fromLine->GetVisualOverflowArea());
|
2010-01-11 14:08:23 +00:00
|
|
|
fromLineList->erase(aFromLine);
|
|
|
|
// aFromLine is now invalid
|
|
|
|
aState.FreeLineBox(fromLine);
|
|
|
|
|
|
|
|
// Put any remaining overflow lines back.
|
|
|
|
if (aFromOverflowLine) {
|
|
|
|
if (!fromLineList->empty()) {
|
|
|
|
aFromContainer->SetOverflowLines(fromLineList);
|
|
|
|
} else {
|
|
|
|
delete fromLineList;
|
|
|
|
// Now any iterators into fromLineList are invalid (but
|
|
|
|
// aFromLine already was invalidated above)
|
2004-10-08 12:17:10 +00:00
|
|
|
}
|
1998-12-05 16:02:08 +00:00
|
|
|
}
|
2010-01-11 14:08:23 +00:00
|
|
|
}
|
1998-12-05 16:02:08 +00:00
|
|
|
|
1999-03-16 19:36:00 +00:00
|
|
|
#ifdef DEBUG
|
2010-01-11 14:08:23 +00:00
|
|
|
VerifyLines(PR_TRUE);
|
1999-03-16 19:36:00 +00:00
|
|
|
#endif
|
2010-01-11 14:08:23 +00:00
|
|
|
|
|
|
|
return frame;
|
1998-12-05 16:02:08 +00:00
|
|
|
}
|
1998-09-23 20:10:40 +00:00
|
|
|
|
1999-11-19 15:33:29 +00:00
|
|
|
static void
|
2004-12-27 15:05:18 +00:00
|
|
|
PlaceFrameView(nsIFrame* aFrame)
|
1999-11-19 15:33:29 +00:00
|
|
|
{
|
2003-06-19 23:44:01 +00:00
|
|
|
if (aFrame->HasView())
|
2004-12-27 15:05:18 +00:00
|
|
|
nsContainerFrame::PositionFrameView(aFrame);
|
2004-01-10 05:36:32 +00:00
|
|
|
else
|
2004-12-27 15:05:18 +00:00
|
|
|
nsContainerFrame::PositionChildViews(aFrame);
|
1999-11-19 15:33:29 +00:00
|
|
|
}
|
|
|
|
|
1998-06-18 16:25:41 +00:00
|
|
|
void
|
1999-09-16 19:56:36 +00:00
|
|
|
nsBlockFrame::SlideLine(nsBlockReflowState& aState,
|
1999-04-03 18:59:01 +00:00
|
|
|
nsLineBox* aLine, nscoord aDY)
|
1998-06-18 16:25:41 +00:00
|
|
|
{
|
2001-10-25 01:08:40 +00:00
|
|
|
NS_PRECONDITION(aDY != 0, "why slide a line nowhere?");
|
|
|
|
|
2010-10-07 04:25:45 +00:00
|
|
|
Invalidate(aLine->GetVisualOverflowArea());
|
1999-09-15 00:28:10 +00:00
|
|
|
// Adjust line state
|
1999-10-14 23:10:03 +00:00
|
|
|
aLine->SlideBy(aDY);
|
2010-10-07 04:25:45 +00:00
|
|
|
Invalidate(aLine->GetVisualOverflowArea());
|
2011-05-12 14:59:15 +00:00
|
|
|
InvalidateThebesLayersInLineBox(this, aLine);
|
1999-09-15 00:28:10 +00:00
|
|
|
|
|
|
|
// Adjust the frames in the line
|
1998-12-05 16:02:08 +00:00
|
|
|
nsIFrame* kid = aLine->mFirstChild;
|
1999-09-15 00:28:10 +00:00
|
|
|
if (!kid) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aLine->IsBlock()) {
|
1999-09-16 19:56:36 +00:00
|
|
|
if (aDY) {
|
2003-06-26 11:30:17 +00:00
|
|
|
nsPoint p = kid->GetPosition();
|
2002-01-06 18:14:00 +00:00
|
|
|
p.y += aDY;
|
2003-06-26 11:30:17 +00:00
|
|
|
kid->SetPosition(p);
|
1999-09-16 19:56:36 +00:00
|
|
|
}
|
1998-11-20 22:24:20 +00:00
|
|
|
|
1999-11-19 15:33:29 +00:00
|
|
|
// Make sure the frame's view and any child views are updated
|
2004-12-27 15:05:18 +00:00
|
|
|
::PlaceFrameView(kid);
|
1998-09-23 02:25:26 +00:00
|
|
|
}
|
1999-09-15 00:28:10 +00:00
|
|
|
else {
|
1999-11-19 15:33:29 +00:00
|
|
|
// Adjust the Y coordinate of the frames in the line.
|
|
|
|
// Note: we need to re-position views even if aDY is 0, because
|
|
|
|
// one of our parent frames may have moved and so the view's position
|
|
|
|
// relative to its parent may have changed
|
|
|
|
PRInt32 n = aLine->GetChildCount();
|
|
|
|
while (--n >= 0) {
|
|
|
|
if (aDY) {
|
2003-06-26 11:30:17 +00:00
|
|
|
nsPoint p = kid->GetPosition();
|
2002-01-06 18:14:00 +00:00
|
|
|
p.y += aDY;
|
2003-06-26 11:30:17 +00:00
|
|
|
kid->SetPosition(p);
|
1999-09-15 00:28:10 +00:00
|
|
|
}
|
1999-11-19 15:33:29 +00:00
|
|
|
// Make sure the frame's view and any child views are updated
|
2004-12-27 15:05:18 +00:00
|
|
|
::PlaceFrameView(kid);
|
2003-06-26 11:30:17 +00:00
|
|
|
kid = kid->GetNextSibling();
|
1998-12-05 16:02:08 +00:00
|
|
|
}
|
1998-09-23 02:25:26 +00:00
|
|
|
}
|
1998-12-05 16:02:08 +00:00
|
|
|
}
|
|
|
|
|
1999-02-23 19:18:12 +00:00
|
|
|
NS_IMETHODIMP
|
2005-09-07 16:49:21 +00:00
|
|
|
nsBlockFrame::AttributeChanged(PRInt32 aNameSpaceID,
|
1999-02-23 19:18:12 +00:00
|
|
|
nsIAtom* aAttribute,
|
2003-07-11 21:16:12 +00:00
|
|
|
PRInt32 aModType)
|
1999-02-23 19:18:12 +00:00
|
|
|
{
|
2005-09-07 16:49:21 +00:00
|
|
|
nsresult rv = nsBlockFrameSuper::AttributeChanged(aNameSpaceID,
|
2004-12-31 01:13:27 +00:00
|
|
|
aAttribute, aModType);
|
1999-02-23 19:18:12 +00:00
|
|
|
|
2001-07-04 02:00:05 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
1999-02-23 19:18:12 +00:00
|
|
|
return rv;
|
|
|
|
}
|
2006-12-26 17:47:52 +00:00
|
|
|
if (nsGkAtoms::start == aAttribute) {
|
2007-03-30 21:11:41 +00:00
|
|
|
nsPresContext* presContext = PresContext();
|
2004-12-31 01:13:27 +00:00
|
|
|
|
1999-03-05 19:25:44 +00:00
|
|
|
// XXX Not sure if this is necessary anymore
|
2007-05-06 19:16:51 +00:00
|
|
|
if (RenumberLists(presContext)) {
|
|
|
|
presContext->PresShell()->
|
|
|
|
FrameNeedsReflow(this, nsIPresShell::eStyleChange,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
|
|
|
}
|
1999-02-23 19:18:12 +00:00
|
|
|
}
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (nsGkAtoms::value == aAttribute) {
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleDisplay* styleDisplay = GetStyleDisplay();
|
1999-02-23 19:18:12 +00:00
|
|
|
if (NS_STYLE_DISPLAY_LIST_ITEM == styleDisplay->mDisplay) {
|
|
|
|
// Search for the closest ancestor that's a block frame. We
|
|
|
|
// make the assumption that all related list items share a
|
|
|
|
// common block parent.
|
2001-07-04 02:00:05 +00:00
|
|
|
// XXXldb I think that's a bad assumption.
|
2007-01-17 08:11:32 +00:00
|
|
|
nsBlockFrame* blockParent = nsLayoutUtils::FindNearestBlockAncestor(this);
|
1999-02-23 19:18:12 +00:00
|
|
|
|
|
|
|
// Tell the enclosing block frame to renumber list items within
|
|
|
|
// itself
|
|
|
|
if (nsnull != blockParent) {
|
2007-03-30 21:11:41 +00:00
|
|
|
nsPresContext* presContext = PresContext();
|
1999-03-05 19:25:44 +00:00
|
|
|
// XXX Not sure if this is necessary anymore
|
2007-05-06 19:16:51 +00:00
|
|
|
if (blockParent->RenumberLists(presContext)) {
|
|
|
|
presContext->PresShell()->
|
|
|
|
FrameNeedsReflow(blockParent, nsIPresShell::eStyleChange,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
|
|
|
}
|
1999-02-23 19:18:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2010-08-25 10:17:55 +00:00
|
|
|
static inline PRBool
|
|
|
|
IsNonAutoNonZeroHeight(const nsStyleCoord& aCoord)
|
|
|
|
{
|
|
|
|
if (aCoord.GetUnit() == eStyleUnit_Auto)
|
|
|
|
return PR_FALSE;
|
|
|
|
if (aCoord.IsCoordPercentCalcUnit()) {
|
|
|
|
// If we evaluate the length/percent/calc at a percentage basis of
|
|
|
|
// both nscoord_MAX and 0, and it's zero both ways, then it's a zero
|
|
|
|
// length, percent, or combination thereof. Test > 0 so we clamp
|
|
|
|
// negative calc() results to 0.
|
|
|
|
return nsRuleNode::ComputeCoordPercentCalc(aCoord, nscoord_MAX) > 0 ||
|
|
|
|
nsRuleNode::ComputeCoordPercentCalc(aCoord, 0) > 0;
|
|
|
|
}
|
|
|
|
NS_ABORT_IF_FALSE(PR_FALSE, "unexpected unit for height or min-height");
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
2003-11-10 23:36:06 +00:00
|
|
|
/* virtual */ PRBool
|
2004-11-15 05:01:11 +00:00
|
|
|
nsBlockFrame::IsSelfEmpty()
|
2001-10-25 01:08:40 +00:00
|
|
|
{
|
2007-11-08 03:55:12 +00:00
|
|
|
// Blocks which are margin-roots (including inline-blocks) cannot be treated
|
|
|
|
// as empty for margin-collapsing and other purposes. They're more like
|
|
|
|
// replaced elements.
|
|
|
|
if (GetStateBits() & NS_BLOCK_MARGIN_ROOT)
|
|
|
|
return PR_FALSE;
|
|
|
|
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStylePosition* position = GetStylePosition();
|
2002-11-28 19:29:28 +00:00
|
|
|
|
2010-08-25 10:17:55 +00:00
|
|
|
if (IsNonAutoNonZeroHeight(position->mMinHeight) ||
|
|
|
|
IsNonAutoNonZeroHeight(position->mHeight))
|
|
|
|
return PR_FALSE;
|
2002-11-28 19:29:28 +00:00
|
|
|
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleBorder* border = GetStyleBorder();
|
|
|
|
const nsStylePadding* padding = GetStylePadding();
|
2008-07-17 06:30:25 +00:00
|
|
|
if (border->GetActualBorderWidth(NS_SIDE_TOP) != 0 ||
|
|
|
|
border->GetActualBorderWidth(NS_SIDE_BOTTOM) != 0 ||
|
2010-08-31 16:05:12 +00:00
|
|
|
!nsLayoutUtils::IsPaddingZero(padding->mPadding.GetTop()) ||
|
|
|
|
!nsLayoutUtils::IsPaddingZero(padding->mPadding.GetBottom())) {
|
2003-11-10 23:36:06 +00:00
|
|
|
return PR_FALSE;
|
2001-10-25 01:08:40 +00:00
|
|
|
}
|
|
|
|
|
2009-09-11 10:46:36 +00:00
|
|
|
if (HaveOutsideBullet() && !BulletIsEmpty()) {
|
2009-08-11 02:48:42 +00:00
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
2004-11-14 20:22:58 +00:00
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
2006-02-27 04:15:05 +00:00
|
|
|
PRBool
|
|
|
|
nsBlockFrame::CachedIsEmpty()
|
|
|
|
{
|
|
|
|
if (!IsSelfEmpty()) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (line_iterator line = begin_lines(), line_end = end_lines();
|
|
|
|
line != line_end;
|
|
|
|
++line)
|
|
|
|
{
|
|
|
|
if (!line->CachedIsEmpty())
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
2004-11-14 20:22:58 +00:00
|
|
|
PRBool
|
|
|
|
nsBlockFrame::IsEmpty()
|
|
|
|
{
|
2004-11-15 05:01:11 +00:00
|
|
|
if (!IsSelfEmpty()) {
|
2004-11-14 20:22:58 +00:00
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
2001-10-25 01:08:40 +00:00
|
|
|
for (line_iterator line = begin_lines(), line_end = end_lines();
|
|
|
|
line != line_end;
|
|
|
|
++line)
|
|
|
|
{
|
2003-11-10 23:36:06 +00:00
|
|
|
if (!line->IsEmpty())
|
|
|
|
return PR_FALSE;
|
2001-10-25 01:08:40 +00:00
|
|
|
}
|
2004-11-14 20:22:58 +00:00
|
|
|
|
2003-11-10 23:36:06 +00:00
|
|
|
return PR_TRUE;
|
2001-10-25 01:08:40 +00:00
|
|
|
}
|
|
|
|
|
1999-03-27 01:22:14 +00:00
|
|
|
PRBool
|
|
|
|
nsBlockFrame::ShouldApplyTopMargin(nsBlockReflowState& aState,
|
|
|
|
nsLineBox* aLine)
|
|
|
|
{
|
2000-04-17 14:40:46 +00:00
|
|
|
if (aState.GetFlag(BRS_APPLYTOPMARGIN)) {
|
1999-03-27 01:22:14 +00:00
|
|
|
// Apply short-circuit check to avoid searching the line list
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!aState.IsAdjacentWithTop()) {
|
|
|
|
// If we aren't at the top Y coordinate then something of non-zero
|
|
|
|
// height must have been placed. Therefore the childs top-margin
|
|
|
|
// applies.
|
2000-04-17 14:40:46 +00:00
|
|
|
aState.SetFlag(BRS_APPLYTOPMARGIN, PR_TRUE);
|
1999-03-27 01:22:14 +00:00
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Determine if this line is "essentially" the first line
|
2006-02-27 04:15:05 +00:00
|
|
|
line_iterator line = begin_lines();
|
|
|
|
if (aState.GetFlag(BRS_HAVELINEADJACENTTOTOP)) {
|
|
|
|
line = aState.mLineAdjacentToTop;
|
|
|
|
}
|
|
|
|
while (line != aLine) {
|
2005-01-27 20:54:27 +00:00
|
|
|
if (!line->CachedIsEmpty() || line->HasClearance()) {
|
2005-11-20 22:05:24 +00:00
|
|
|
// A line which precedes aLine is non-empty, or has clearance,
|
2005-01-27 20:54:27 +00:00
|
|
|
// so therefore the top margin applies.
|
2000-04-17 14:40:46 +00:00
|
|
|
aState.SetFlag(BRS_APPLYTOPMARGIN, PR_TRUE);
|
1999-03-27 01:22:14 +00:00
|
|
|
return PR_TRUE;
|
|
|
|
}
|
2003-10-13 21:51:02 +00:00
|
|
|
// No need to apply the top margin if the line has floats. We
|
2000-09-04 21:44:48 +00:00
|
|
|
// should collapse anyway (bug 44419)
|
2006-02-27 04:15:05 +00:00
|
|
|
++line;
|
|
|
|
aState.SetFlag(BRS_HAVELINEADJACENTTOTOP, PR_TRUE);
|
|
|
|
aState.mLineAdjacentToTop = line;
|
1999-03-27 01:22:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// The line being reflowed is "essentially" the first line in the
|
|
|
|
// block. Therefore its top-margin will be collapsed by the
|
|
|
|
// generational collapsing logic with its parent (us).
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
nsresult
|
1999-02-09 17:31:33 +00:00
|
|
|
nsBlockFrame::ReflowBlockFrame(nsBlockReflowState& aState,
|
2001-10-25 01:08:40 +00:00
|
|
|
line_iterator aLine,
|
1999-02-12 17:45:58 +00:00
|
|
|
PRBool* aKeepReflowGoing)
|
1998-12-05 16:02:08 +00:00
|
|
|
{
|
1999-02-12 17:45:58 +00:00
|
|
|
NS_PRECONDITION(*aKeepReflowGoing, "bad caller");
|
1998-07-10 21:45:30 +00:00
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
nsresult rv = NS_OK;
|
1998-11-17 22:28:51 +00:00
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
nsIFrame* frame = aLine->mFirstChild;
|
2002-04-25 20:53:32 +00:00
|
|
|
if (!frame) {
|
|
|
|
NS_ASSERTION(PR_FALSE, "program error - unexpected empty line");
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1998-12-05 16:02:08 +00:00
|
|
|
|
1999-03-24 15:42:19 +00:00
|
|
|
// Prepare the block reflow engine
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleDisplay* display = frame->GetStyleDisplay();
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsBlockReflowContext brc(aState.mPresContext, aState.mReflowState);
|
1998-12-05 16:02:08 +00:00
|
|
|
|
1999-10-12 23:24:22 +00:00
|
|
|
PRUint8 breakType = display->mBreakType;
|
2003-10-13 21:51:02 +00:00
|
|
|
if (NS_STYLE_CLEAR_NONE != aState.mFloatBreakType) {
|
2004-11-25 14:51:00 +00:00
|
|
|
breakType = nsLayoutUtils::CombineBreakType(breakType,
|
|
|
|
aState.mFloatBreakType);
|
2003-10-13 21:51:02 +00:00
|
|
|
aState.mFloatBreakType = NS_STYLE_CLEAR_NONE;
|
2002-07-17 01:48:56 +00:00
|
|
|
}
|
2004-11-25 14:51:00 +00:00
|
|
|
|
2003-10-13 21:51:02 +00:00
|
|
|
// Clear past floats before the block if the clear style is not none
|
2004-11-25 14:51:00 +00:00
|
|
|
aLine->SetBreakTypeBefore(breakType);
|
|
|
|
|
|
|
|
// See if we should apply the top margin. If the block frame being
|
|
|
|
// reflowed is a continuation (non-null prev-in-flow) then we don't
|
2005-11-20 22:05:24 +00:00
|
|
|
// apply its top margin because it's not significant. Otherwise, dig
|
2004-11-25 14:51:00 +00:00
|
|
|
// deeper.
|
|
|
|
PRBool applyTopMargin =
|
|
|
|
!frame->GetPrevInFlow() && ShouldApplyTopMargin(aState, aLine);
|
1998-08-04 21:18:16 +00:00
|
|
|
|
1999-10-15 23:35:10 +00:00
|
|
|
if (applyTopMargin) {
|
2004-11-25 14:51:00 +00:00
|
|
|
// The HasClearance setting is only valid if ShouldApplyTopMargin
|
|
|
|
// returned PR_FALSE (in which case the top-margin-root set our
|
|
|
|
// clearance flag). Otherwise clear it now. We'll set it later on
|
|
|
|
// ourselves if necessary.
|
|
|
|
aLine->ClearHasClearance();
|
|
|
|
}
|
|
|
|
PRBool treatWithClearance = aLine->HasClearance();
|
2008-01-29 07:40:05 +00:00
|
|
|
|
|
|
|
PRBool mightClearFloats = breakType != NS_STYLE_CLEAR_NONE;
|
2008-05-03 23:33:36 +00:00
|
|
|
nsIFrame *replacedBlock = nsnull;
|
2008-01-29 07:40:05 +00:00
|
|
|
if (!nsBlockFrame::BlockCanIntersectFloats(frame)) {
|
|
|
|
mightClearFloats = PR_TRUE;
|
2008-05-03 23:33:36 +00:00
|
|
|
replacedBlock = frame;
|
2008-01-29 07:40:05 +00:00
|
|
|
}
|
|
|
|
|
2004-11-25 14:51:00 +00:00
|
|
|
// If our top margin was counted as part of some parents top-margin
|
|
|
|
// collapse and we are being speculatively reflowed assuming this
|
|
|
|
// frame DID NOT need clearance, then we need to check that
|
|
|
|
// assumption.
|
2008-01-29 07:40:05 +00:00
|
|
|
if (!treatWithClearance && !applyTopMargin && mightClearFloats &&
|
2004-11-25 14:51:00 +00:00
|
|
|
aState.mReflowState.mDiscoveredClearance) {
|
|
|
|
nscoord curY = aState.mY + aState.mPrevBottomMargin.get();
|
2008-05-03 23:33:36 +00:00
|
|
|
nscoord clearY = aState.ClearFloats(curY, breakType, replacedBlock);
|
2004-11-25 14:51:00 +00:00
|
|
|
if (clearY != curY) {
|
|
|
|
// Looks like that assumption was invalid, we do need
|
|
|
|
// clearance. Tell our ancestor so it can reflow again. It is
|
|
|
|
// responsible for actually setting our clearance flag before
|
|
|
|
// the next reflow.
|
|
|
|
treatWithClearance = PR_TRUE;
|
|
|
|
// Only record the first frame that requires clearance
|
|
|
|
if (!*aState.mReflowState.mDiscoveredClearance) {
|
|
|
|
*aState.mReflowState.mDiscoveredClearance = frame;
|
2005-06-16 02:54:57 +00:00
|
|
|
}
|
2009-10-16 02:41:58 +00:00
|
|
|
aState.mPrevChild = frame;
|
2004-11-25 14:51:00 +00:00
|
|
|
// Exactly what we do now is flexible since we'll definitely be
|
|
|
|
// reflowed.
|
2007-11-30 01:49:01 +00:00
|
|
|
return NS_OK;
|
2004-11-25 14:51:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (treatWithClearance) {
|
|
|
|
applyTopMargin = PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame* clearanceFrame = nsnull;
|
|
|
|
nscoord startingY = aState.mY;
|
|
|
|
nsCollapsingMargin incomingMargin = aState.mPrevBottomMargin;
|
2005-03-23 03:35:08 +00:00
|
|
|
nscoord clearance;
|
2007-04-05 22:47:38 +00:00
|
|
|
// Save the original position of the frame so that we can reposition
|
|
|
|
// its view as needed.
|
|
|
|
nsPoint originalPosition = frame->GetPosition();
|
2004-11-25 14:51:00 +00:00
|
|
|
while (PR_TRUE) {
|
2006-09-19 00:15:15 +00:00
|
|
|
// Save the frame's current position. We might need it later.
|
2007-04-05 22:47:38 +00:00
|
|
|
nscoord passOriginalY = frame->GetRect().y;
|
2006-09-19 00:15:15 +00:00
|
|
|
|
2005-03-23 03:35:08 +00:00
|
|
|
clearance = 0;
|
2004-11-25 14:51:00 +00:00
|
|
|
nscoord topMargin = 0;
|
|
|
|
PRBool mayNeedRetry = PR_FALSE;
|
2011-04-28 17:21:36 +00:00
|
|
|
PRBool clearedFloats = PR_FALSE;
|
2004-11-25 14:51:00 +00:00
|
|
|
if (applyTopMargin) {
|
|
|
|
// Precompute the blocks top margin value so that we can get the
|
|
|
|
// correct available space (there might be a float that's
|
|
|
|
// already been placed below the aState.mPrevBottomMargin
|
|
|
|
|
|
|
|
// Setup a reflowState to get the style computed margin-top
|
|
|
|
// value. We'll use a reason of `resize' so that we don't fudge
|
|
|
|
// any incremental reflow state.
|
|
|
|
|
|
|
|
// The availSpace here is irrelevant to our needs - all we want
|
|
|
|
// out if this setup is the margin-top value which doesn't depend
|
|
|
|
// on the childs available space.
|
|
|
|
// XXX building a complete nsHTMLReflowState just to get the margin-top
|
|
|
|
// seems like a waste. And we do this for almost every block!
|
|
|
|
nsSize availSpace(aState.mContentArea.width, NS_UNCONSTRAINEDSIZE);
|
|
|
|
nsHTMLReflowState reflowState(aState.mPresContext, aState.mReflowState,
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
frame, availSpace);
|
2004-11-25 14:51:00 +00:00
|
|
|
|
|
|
|
if (treatWithClearance) {
|
|
|
|
aState.mY += aState.mPrevBottomMargin.get();
|
|
|
|
aState.mPrevBottomMargin.Zero();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now compute the collapsed margin-top value into aState.mPrevBottomMargin, assuming
|
|
|
|
// that all child margins collapse down to clearanceFrame.
|
|
|
|
nsBlockReflowContext::ComputeCollapsedTopMargin(reflowState,
|
|
|
|
&aState.mPrevBottomMargin, clearanceFrame, &mayNeedRetry);
|
|
|
|
|
|
|
|
// XXX optimization; we could check the collapsing children to see if they are sure
|
|
|
|
// to require clearance, and so avoid retrying them
|
|
|
|
|
|
|
|
if (clearanceFrame) {
|
|
|
|
// Don't allow retries on the second pass. The clearance decisions for the
|
|
|
|
// blocks whose top-margins collapse with ours are now fixed.
|
|
|
|
mayNeedRetry = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
2008-01-29 07:40:05 +00:00
|
|
|
if (!treatWithClearance && !clearanceFrame && mightClearFloats) {
|
2004-11-25 14:51:00 +00:00
|
|
|
// We don't know if we need clearance and this is the first,
|
|
|
|
// optimistic pass. So determine whether *this block* needs
|
|
|
|
// clearance. Note that we do not allow the decision for whether
|
|
|
|
// this block has clearance to change on the second pass; that
|
|
|
|
// decision is only allowed to be made under the optimistic
|
|
|
|
// first pass.
|
|
|
|
nscoord curY = aState.mY + aState.mPrevBottomMargin.get();
|
2008-05-03 23:33:36 +00:00
|
|
|
nscoord clearY = aState.ClearFloats(curY, breakType, replacedBlock);
|
2004-11-25 14:51:00 +00:00
|
|
|
if (clearY != curY) {
|
|
|
|
// Looks like we need clearance and we didn't know about it already. So
|
|
|
|
// recompute collapsed margin
|
|
|
|
treatWithClearance = PR_TRUE;
|
|
|
|
// Remember this decision, needed for incremental reflow
|
|
|
|
aLine->SetHasClearance();
|
|
|
|
|
|
|
|
// Apply incoming margins
|
|
|
|
aState.mY += aState.mPrevBottomMargin.get();
|
|
|
|
aState.mPrevBottomMargin.Zero();
|
|
|
|
|
|
|
|
// Compute the collapsed margin again, ignoring the incoming margin this time
|
|
|
|
mayNeedRetry = PR_FALSE;
|
|
|
|
nsBlockReflowContext::ComputeCollapsedTopMargin(reflowState,
|
|
|
|
&aState.mPrevBottomMargin, clearanceFrame, &mayNeedRetry);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Temporarily advance the running Y value so that the
|
|
|
|
// GetAvailableSpace method will return the right available
|
|
|
|
// space. This undone as soon as the horizontal margins are
|
|
|
|
// computed.
|
|
|
|
topMargin = aState.mPrevBottomMargin.get();
|
|
|
|
|
|
|
|
if (treatWithClearance) {
|
|
|
|
nscoord currentY = aState.mY;
|
|
|
|
// advance mY to the clear position.
|
2008-05-03 23:33:36 +00:00
|
|
|
aState.mY = aState.ClearFloats(aState.mY, breakType, replacedBlock);
|
2011-04-28 17:21:36 +00:00
|
|
|
|
|
|
|
clearedFloats = aState.mY != currentY;
|
|
|
|
|
2004-11-25 14:51:00 +00:00
|
|
|
// Compute clearance. It's the amount we need to add to the top
|
|
|
|
// border-edge of the frame, after applying collapsed margins
|
|
|
|
// from the frame and its children, to get it to line up with
|
|
|
|
// the bottom of the floats. The former is currentY + topMargin,
|
|
|
|
// the latter is the current aState.mY.
|
|
|
|
// Note that negative clearance is possible
|
|
|
|
clearance = aState.mY - (currentY + topMargin);
|
|
|
|
|
|
|
|
// Add clearance to our top margin while we compute available
|
|
|
|
// space for the frame
|
|
|
|
topMargin += clearance;
|
|
|
|
|
|
|
|
// Note that aState.mY should stay where it is: at the top
|
|
|
|
// border-edge of the frame
|
|
|
|
} else {
|
|
|
|
// Advance aState.mY to the top border-edge of the frame.
|
|
|
|
aState.mY += topMargin;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Here aState.mY is the top border-edge of the block.
|
|
|
|
// Compute the available space for the block
|
2009-04-08 20:52:37 +00:00
|
|
|
nsFlowAreaRect floatAvailableSpace = aState.GetFloatAvailableSpace();
|
2000-03-22 23:19:10 +00:00
|
|
|
#ifdef REALLY_NOISY_REFLOW
|
2009-04-08 20:52:37 +00:00
|
|
|
printf("setting line %p isImpacted to %s\n",
|
2009-04-08 20:52:37 +00:00
|
|
|
aLine.get(), floatAvailableSpace.mHasFloats?"true":"false");
|
2000-03-22 23:19:10 +00:00
|
|
|
#endif
|
2009-04-08 20:52:37 +00:00
|
|
|
aLine->SetLineIsImpactedByFloat(floatAvailableSpace.mHasFloats);
|
2004-11-25 14:51:00 +00:00
|
|
|
nsRect availSpace;
|
2009-04-08 20:52:37 +00:00
|
|
|
aState.ComputeBlockAvailSpace(frame, display, floatAvailableSpace,
|
2009-04-08 20:52:37 +00:00
|
|
|
replacedBlock != nsnull, availSpace);
|
2011-04-28 17:21:36 +00:00
|
|
|
|
|
|
|
// The check for
|
|
|
|
// (!aState.mReflowState.mFlags.mIsTopOfPage || clearedFloats)
|
|
|
|
// is to some degree out of paranoia: if we reliably eat up top
|
|
|
|
// margins at the top of the page as we ought to, it wouldn't be
|
|
|
|
// needed.
|
|
|
|
if ((!aState.mReflowState.mFlags.mIsTopOfPage || clearedFloats) &&
|
|
|
|
availSpace.height < 0) {
|
|
|
|
// We know already that this child block won't fit on this
|
|
|
|
// page/column due to the top margin or the clearance. So we need
|
|
|
|
// to get out of here now. (If we don't, most blocks will handle
|
|
|
|
// things fine, and report break-before, but zero-height blocks
|
|
|
|
// won't, and will thus make their parent overly-large and force
|
|
|
|
// *it* to be pushed in its entirety.)
|
|
|
|
// Doing this means that we also don't need to worry about the
|
|
|
|
// |availSpace.height += topMargin| below interacting with pushed
|
|
|
|
// floats (which force nscoord_MAX clearance) to cause a
|
|
|
|
// constrained height to turn into an unconstrained one.
|
|
|
|
aState.mY = startingY;
|
|
|
|
aState.mPrevBottomMargin = incomingMargin;
|
|
|
|
PushLines(aState, aLine.prev());
|
|
|
|
NS_FRAME_SET_INCOMPLETE(aState.mReflowStatus);
|
|
|
|
*aKeepReflowGoing = PR_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2004-11-25 14:51:00 +00:00
|
|
|
// Now put the Y coordinate back to the top of the top-margin +
|
|
|
|
// clearance, and flow the block.
|
1999-10-15 23:35:10 +00:00
|
|
|
aState.mY -= topMargin;
|
|
|
|
availSpace.y -= topMargin;
|
|
|
|
if (NS_UNCONSTRAINEDSIZE != availSpace.height) {
|
|
|
|
availSpace.height += topMargin;
|
|
|
|
}
|
2004-11-25 14:51:00 +00:00
|
|
|
|
|
|
|
// Reflow the block into the available space
|
|
|
|
// construct the html reflow state for the block. ReflowBlock
|
|
|
|
// will initialize it
|
|
|
|
nsHTMLReflowState blockHtmlRS(aState.mPresContext, aState.mReflowState, frame,
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsSize(availSpace.width, availSpace.height));
|
2004-11-25 14:51:00 +00:00
|
|
|
blockHtmlRS.mFlags.mHasClearance = aLine->HasClearance();
|
|
|
|
|
2009-01-05 00:39:54 +00:00
|
|
|
nsFloatManager::SavedState floatManagerState;
|
2004-11-25 14:51:00 +00:00
|
|
|
if (mayNeedRetry) {
|
|
|
|
blockHtmlRS.mDiscoveredClearance = &clearanceFrame;
|
2009-01-05 00:39:54 +00:00
|
|
|
aState.mFloatManager->PushState(&floatManagerState);
|
2004-11-25 14:51:00 +00:00
|
|
|
} else if (!applyTopMargin) {
|
|
|
|
blockHtmlRS.mDiscoveredClearance = aState.mReflowState.mDiscoveredClearance;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsReflowStatus frameReflowStatus = NS_FRAME_COMPLETE;
|
|
|
|
rv = brc.ReflowBlock(availSpace, applyTopMargin, aState.mPrevBottomMargin,
|
2008-04-18 07:40:35 +00:00
|
|
|
clearance, aState.IsAdjacentWithTop(),
|
2007-10-02 05:57:45 +00:00
|
|
|
aLine.get(), blockHtmlRS, frameReflowStatus, aState);
|
2006-09-19 00:15:15 +00:00
|
|
|
|
|
|
|
// If this was a second-pass reflow and the block's vertical position
|
|
|
|
// changed, invalidates from the first pass might have happened in the
|
|
|
|
// wrong places. Invalidate the entire overflow rect at the new position.
|
2007-04-05 22:47:38 +00:00
|
|
|
if (!mayNeedRetry && clearanceFrame &&
|
|
|
|
frame->GetRect().y != passOriginalY) {
|
2010-10-07 04:25:47 +00:00
|
|
|
Invalidate(frame->GetVisualOverflowRect() + frame->GetPosition());
|
2006-09-19 00:15:15 +00:00
|
|
|
}
|
2004-11-25 14:51:00 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2004-11-25 14:51:00 +00:00
|
|
|
|
2006-06-29 01:19:48 +00:00
|
|
|
if (mayNeedRetry && clearanceFrame) {
|
2009-01-05 00:39:54 +00:00
|
|
|
aState.mFloatManager->PopState(&floatManagerState);
|
2006-06-29 01:19:48 +00:00
|
|
|
aState.mY = startingY;
|
|
|
|
aState.mPrevBottomMargin = incomingMargin;
|
|
|
|
continue;
|
2004-11-25 14:51:00 +00:00
|
|
|
}
|
2009-02-10 04:36:54 +00:00
|
|
|
|
2009-09-02 15:33:15 +00:00
|
|
|
aState.mPrevChild = frame;
|
|
|
|
|
2009-02-10 04:36:54 +00:00
|
|
|
if (blockHtmlRS.WillReflowAgainForClearance()) {
|
|
|
|
// If an ancestor of ours is going to reflow for clearance, we
|
|
|
|
// need to avoid calling PlaceBlock, because it unsets dirty bits
|
|
|
|
// on the child block (both itself, and through its call to
|
|
|
|
// nsFrame::DidReflow), and those dirty bits imply dirtiness for
|
|
|
|
// all of the child block, including the lines it didn't reflow.
|
|
|
|
NS_ASSERTION(originalPosition == frame->GetPosition(),
|
|
|
|
"we need to call PositionChildViews");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2009-09-02 15:33:15 +00:00
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
#if defined(REFLOW_STATUS_COVERAGE)
|
2004-11-25 14:51:00 +00:00
|
|
|
RecordReflowStatus(PR_TRUE, frameReflowStatus);
|
1998-12-05 16:02:08 +00:00
|
|
|
#endif
|
2004-11-25 14:51:00 +00:00
|
|
|
|
|
|
|
if (NS_INLINE_IS_BREAK_BEFORE(frameReflowStatus)) {
|
|
|
|
// None of the child block fits.
|
|
|
|
PushLines(aState, aLine.prev());
|
|
|
|
*aKeepReflowGoing = PR_FALSE;
|
2007-07-26 04:03:29 +00:00
|
|
|
NS_FRAME_SET_INCOMPLETE(aState.mReflowStatus);
|
2004-09-18 14:39:07 +00:00
|
|
|
}
|
2004-11-25 14:51:00 +00:00
|
|
|
else {
|
|
|
|
// Note: line-break-after a block is a nop
|
|
|
|
|
2005-03-23 03:35:08 +00:00
|
|
|
// Try to place the child block.
|
|
|
|
// Don't force the block to fit if we have positive clearance, because
|
|
|
|
// pushing it to the next page would give it more room.
|
|
|
|
// Don't force the block to fit if it's impacted by a float. If it is,
|
|
|
|
// then pushing it to the next page would give it more room. Note that
|
|
|
|
// isImpacted doesn't include impact from the block's own floats.
|
|
|
|
PRBool forceFit = aState.IsAdjacentWithTop() && clearance <= 0 &&
|
2009-04-08 20:52:37 +00:00
|
|
|
!floatAvailableSpace.mHasFloats;
|
2004-11-25 14:51:00 +00:00
|
|
|
nsCollapsingMargin collapsedBottomMargin;
|
2010-10-07 04:25:45 +00:00
|
|
|
nsOverflowAreas overflowAreas;
|
2005-03-23 03:35:08 +00:00
|
|
|
*aKeepReflowGoing = brc.PlaceBlock(blockHtmlRS, forceFit, aLine.get(),
|
2008-04-18 07:40:35 +00:00
|
|
|
collapsedBottomMargin,
|
2010-10-07 04:25:45 +00:00
|
|
|
aLine->mBounds, overflowAreas,
|
|
|
|
frameReflowStatus);
|
2004-11-25 14:51:00 +00:00
|
|
|
if (aLine->SetCarriedOutBottomMargin(collapsedBottomMargin)) {
|
|
|
|
line_iterator nextLine = aLine;
|
|
|
|
++nextLine;
|
|
|
|
if (nextLine != end_lines()) {
|
|
|
|
nextLine->MarkPreviousMarginDirty();
|
|
|
|
}
|
2000-01-03 04:32:13 +00:00
|
|
|
}
|
2010-10-07 04:25:45 +00:00
|
|
|
|
|
|
|
aLine->SetOverflowAreas(overflowAreas);
|
2004-11-25 14:51:00 +00:00
|
|
|
if (*aKeepReflowGoing) {
|
|
|
|
// Some of the child block fit
|
|
|
|
|
|
|
|
// Advance to new Y position
|
|
|
|
nscoord newY = aLine->mBounds.YMost();
|
|
|
|
aState.mY = newY;
|
|
|
|
|
|
|
|
// Continue the block frame now if it didn't completely fit in
|
|
|
|
// the available space.
|
2007-07-26 04:03:29 +00:00
|
|
|
if (!NS_FRAME_IS_FULLY_COMPLETE(frameReflowStatus)) {
|
2004-11-25 14:51:00 +00:00
|
|
|
PRBool madeContinuation;
|
|
|
|
rv = CreateContinuationFor(aState, nsnull, frame, madeContinuation);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2004-11-25 14:51:00 +00:00
|
|
|
|
|
|
|
nsIFrame* nextFrame = frame->GetNextInFlow();
|
2007-07-26 04:03:29 +00:00
|
|
|
NS_ASSERTION(nextFrame, "We're supposed to have a next-in-flow by now");
|
2004-11-25 14:51:00 +00:00
|
|
|
|
2007-07-26 04:03:29 +00:00
|
|
|
if (NS_FRAME_IS_NOT_COMPLETE(frameReflowStatus)) {
|
|
|
|
// If nextFrame used to be an overflow container, make it a normal block
|
|
|
|
if (!madeContinuation &&
|
|
|
|
(NS_FRAME_IS_OVERFLOW_CONTAINER & nextFrame->GetStateBits())) {
|
2009-09-14 00:26:01 +00:00
|
|
|
aState.mOverflowTracker->Finish(frame);
|
2007-07-26 04:03:29 +00:00
|
|
|
nsContainerFrame* parent =
|
|
|
|
static_cast<nsContainerFrame*>(nextFrame->GetParent());
|
|
|
|
rv = parent->StealFrame(aState.mPresContext, nextFrame);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2007-10-10 22:09:53 +00:00
|
|
|
if (parent != this)
|
|
|
|
ReparentFrame(nextFrame, parent, this);
|
2009-09-29 19:47:05 +00:00
|
|
|
mFrames.InsertFrame(nsnull, frame, nextFrame);
|
2007-07-26 04:03:29 +00:00
|
|
|
madeContinuation = PR_TRUE; // needs to be added to mLines
|
|
|
|
nextFrame->RemoveStateBits(NS_FRAME_IS_OVERFLOW_CONTAINER);
|
|
|
|
frameReflowStatus |= NS_FRAME_REFLOW_NEXTINFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Push continuation to a new line, but only if we actually made one.
|
|
|
|
if (madeContinuation) {
|
|
|
|
nsLineBox* line = aState.NewLineBox(nextFrame, 1, PR_TRUE);
|
|
|
|
NS_ENSURE_TRUE(line, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
mLines.after_insert(aLine, line);
|
|
|
|
}
|
|
|
|
|
|
|
|
PushLines(aState, aLine);
|
|
|
|
NS_FRAME_SET_INCOMPLETE(aState.mReflowStatus);
|
|
|
|
|
|
|
|
// If we need to reflow the continuation of the block child,
|
|
|
|
// then we'd better reflow our continuation
|
|
|
|
if (frameReflowStatus & NS_FRAME_REFLOW_NEXTINFLOW) {
|
|
|
|
aState.mReflowStatus |= NS_FRAME_REFLOW_NEXTINFLOW;
|
|
|
|
// We also need to make that continuation's line dirty so
|
|
|
|
// it gets reflowed when we reflow our next in flow. The
|
|
|
|
// nif's line must always be either a line of the nif's
|
|
|
|
// parent block (only if we didn't make a continuation) or
|
|
|
|
// else one of our own overflow lines. In the latter case
|
|
|
|
// the line is already marked dirty, so just handle the
|
|
|
|
// first case.
|
|
|
|
if (!madeContinuation) {
|
2007-12-21 03:28:18 +00:00
|
|
|
nsBlockFrame* nifBlock =
|
|
|
|
nsLayoutUtils::GetAsBlock(nextFrame->GetParent());
|
|
|
|
NS_ASSERTION(nifBlock,
|
2007-07-26 04:03:29 +00:00
|
|
|
"A block's child's next in flow's parent must be a block!");
|
|
|
|
for (line_iterator line = nifBlock->begin_lines(),
|
2005-03-23 03:35:08 +00:00
|
|
|
line_end = nifBlock->end_lines(); line != line_end; ++line) {
|
2007-07-26 04:03:29 +00:00
|
|
|
if (line->Contains(nextFrame)) {
|
|
|
|
line->MarkDirty();
|
|
|
|
break;
|
|
|
|
}
|
2005-03-23 03:35:08 +00:00
|
|
|
}
|
|
|
|
}
|
2004-11-25 14:51:00 +00:00
|
|
|
}
|
2007-07-26 04:03:29 +00:00
|
|
|
*aKeepReflowGoing = PR_FALSE;
|
|
|
|
|
|
|
|
// The bottom margin for a block is only applied on the last
|
|
|
|
// flow block. Since we just continued the child block frame,
|
|
|
|
// we know that line->mFirstChild is not the last flow block
|
|
|
|
// therefore zero out the running margin value.
|
|
|
|
#ifdef NOISY_VERTICAL_MARGINS
|
|
|
|
ListTag(stdout);
|
|
|
|
printf(": reflow incomplete, frame=");
|
|
|
|
nsFrame::ListTag(stdout, frame);
|
|
|
|
printf(" prevBottomMargin=%d, setting to zero\n",
|
|
|
|
aState.mPrevBottomMargin);
|
|
|
|
#endif
|
|
|
|
aState.mPrevBottomMargin.Zero();
|
2004-11-25 14:51:00 +00:00
|
|
|
}
|
2007-07-26 04:03:29 +00:00
|
|
|
else { // frame is complete but its overflow is not complete
|
|
|
|
// Disconnect the next-in-flow and put it in our overflow tracker
|
|
|
|
if (!madeContinuation &&
|
|
|
|
!(NS_FRAME_IS_OVERFLOW_CONTAINER & nextFrame->GetStateBits())) {
|
|
|
|
// It already exists, but as a normal next-in-flow, so we need
|
|
|
|
// to dig it out of the child lists.
|
|
|
|
nsContainerFrame* parent = static_cast<nsContainerFrame*>
|
|
|
|
(nextFrame->GetParent());
|
|
|
|
rv = parent->StealFrame(aState.mPresContext, nextFrame);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
|
|
|
else if (madeContinuation) {
|
2009-10-02 16:27:37 +00:00
|
|
|
mFrames.RemoveFrame(nextFrame);
|
2007-07-26 04:03:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Put it in our overflow list
|
2009-09-14 00:26:01 +00:00
|
|
|
aState.mOverflowTracker->Insert(nextFrame, frameReflowStatus);
|
2008-05-28 13:39:41 +00:00
|
|
|
NS_MergeReflowStatusInto(&aState.mReflowStatus, frameReflowStatus);
|
2007-07-26 04:03:29 +00:00
|
|
|
|
2004-11-25 14:51:00 +00:00
|
|
|
#ifdef NOISY_VERTICAL_MARGINS
|
2007-07-26 04:03:29 +00:00
|
|
|
ListTag(stdout);
|
|
|
|
printf(": reflow complete but overflow incomplete for ");
|
|
|
|
nsFrame::ListTag(stdout, frame);
|
|
|
|
printf(" prevBottomMargin=%d collapsedBottomMargin=%d\n",
|
|
|
|
aState.mPrevBottomMargin, collapsedBottomMargin.get());
|
2004-11-25 14:51:00 +00:00
|
|
|
#endif
|
2007-07-26 04:03:29 +00:00
|
|
|
aState.mPrevBottomMargin = collapsedBottomMargin;
|
|
|
|
}
|
2004-08-26 12:38:50 +00:00
|
|
|
}
|
2007-07-26 04:03:29 +00:00
|
|
|
else { // frame is fully complete
|
1999-09-10 18:52:56 +00:00
|
|
|
#ifdef NOISY_VERTICAL_MARGINS
|
2004-11-25 14:51:00 +00:00
|
|
|
ListTag(stdout);
|
|
|
|
printf(": reflow complete for ");
|
|
|
|
nsFrame::ListTag(stdout, frame);
|
|
|
|
printf(" prevBottomMargin=%d collapsedBottomMargin=%d\n",
|
|
|
|
aState.mPrevBottomMargin, collapsedBottomMargin.get());
|
1999-09-10 18:52:56 +00:00
|
|
|
#endif
|
2004-11-25 14:51:00 +00:00
|
|
|
aState.mPrevBottomMargin = collapsedBottomMargin;
|
|
|
|
}
|
1999-09-10 18:52:56 +00:00
|
|
|
#ifdef NOISY_VERTICAL_MARGINS
|
|
|
|
ListTag(stdout);
|
2004-11-25 14:51:00 +00:00
|
|
|
printf(": frame=");
|
1999-09-10 18:52:56 +00:00
|
|
|
nsFrame::ListTag(stdout, frame);
|
2004-11-25 14:51:00 +00:00
|
|
|
printf(" carriedOutBottomMargin=%d collapsedBottomMargin=%d => %d\n",
|
|
|
|
brc.GetCarriedOutBottomMargin(), collapsedBottomMargin.get(),
|
|
|
|
aState.mPrevBottomMargin);
|
1999-03-27 01:22:14 +00:00
|
|
|
#endif
|
1998-12-05 16:02:08 +00:00
|
|
|
}
|
|
|
|
else {
|
2004-11-25 14:51:00 +00:00
|
|
|
// None of the block fits. Determine the correct reflow status.
|
2009-07-13 16:50:54 +00:00
|
|
|
if (aLine == mLines.front() && !GetPrevInFlow()) {
|
2004-11-25 14:51:00 +00:00
|
|
|
// If it's our very first line then we need to be pushed to
|
|
|
|
// our parents next-in-flow. Therefore, return break-before
|
|
|
|
// status for our reflow status.
|
|
|
|
aState.mReflowStatus = NS_INLINE_LINE_BREAK_BEFORE();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Push the line that didn't fit and any lines that follow it
|
|
|
|
// to our next-in-flow.
|
|
|
|
PushLines(aState, aLine.prev());
|
2007-07-26 04:03:29 +00:00
|
|
|
NS_FRAME_SET_INCOMPLETE(aState.mReflowStatus);
|
2004-11-25 14:51:00 +00:00
|
|
|
}
|
1998-12-05 16:02:08 +00:00
|
|
|
}
|
|
|
|
}
|
2004-11-25 14:51:00 +00:00
|
|
|
break; // out of the reflow retry loop
|
1998-06-25 16:33:10 +00:00
|
|
|
}
|
2007-04-05 22:47:38 +00:00
|
|
|
|
|
|
|
// Now that we've got its final position all figured out, position any child
|
|
|
|
// views it may have. Note that the case when frame has a view got handled
|
|
|
|
// by FinishReflowChild, but that function didn't have the coordinates needed
|
|
|
|
// to correctly decide whether to reposition child views.
|
|
|
|
if (originalPosition != frame->GetPosition() && !frame->HasView()) {
|
|
|
|
nsContainerFrame::PositionChildViews(frame);
|
|
|
|
}
|
2004-11-25 14:51:00 +00:00
|
|
|
|
1999-03-16 19:36:00 +00:00
|
|
|
#ifdef DEBUG
|
1999-04-20 00:27:43 +00:00
|
|
|
VerifyLines(PR_TRUE);
|
1999-03-16 19:36:00 +00:00
|
|
|
#endif
|
1998-12-05 16:02:08 +00:00
|
|
|
return rv;
|
|
|
|
}
|
1998-10-30 22:10:10 +00:00
|
|
|
|
1999-03-21 01:15:12 +00:00
|
|
|
nsresult
|
|
|
|
nsBlockFrame::ReflowInlineFrames(nsBlockReflowState& aState,
|
2001-10-25 01:08:40 +00:00
|
|
|
line_iterator aLine,
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
PRBool* aKeepReflowGoing)
|
1999-03-21 01:15:12 +00:00
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
*aKeepReflowGoing = PR_TRUE;
|
|
|
|
|
2009-05-20 11:21:34 +00:00
|
|
|
aLine->SetLineIsImpactedByFloat(PR_FALSE);
|
|
|
|
|
|
|
|
// Setup initial coordinate system for reflowing the inline frames
|
|
|
|
// into. Apply a previous block frame's bottom margin first.
|
|
|
|
if (ShouldApplyTopMargin(aState, aLine)) {
|
|
|
|
aState.mY += aState.mPrevBottomMargin.get();
|
|
|
|
}
|
|
|
|
nsFlowAreaRect floatAvailableSpace = aState.GetFloatAvailableSpace();
|
|
|
|
|
2010-08-06 04:59:19 +00:00
|
|
|
LineReflowStatus lineReflowStatus;
|
2004-07-15 17:50:34 +00:00
|
|
|
do {
|
2009-06-16 15:00:20 +00:00
|
|
|
nscoord availableSpaceHeight = 0;
|
2006-06-29 01:19:48 +00:00
|
|
|
do {
|
2009-06-16 15:00:20 +00:00
|
|
|
PRBool allowPullUp = PR_TRUE;
|
|
|
|
nsIContent* forceBreakInContent = nsnull;
|
|
|
|
PRInt32 forceBreakOffset = -1;
|
|
|
|
gfxBreakPriority forceBreakPriority = eNoBreak;
|
|
|
|
do {
|
|
|
|
nsFloatManager::SavedState floatManagerState;
|
|
|
|
aState.mReflowState.mFloatManager->PushState(&floatManagerState);
|
|
|
|
|
|
|
|
// Once upon a time we allocated the first 30 nsLineLayout objects
|
|
|
|
// on the stack, and then we switched to the heap. At that time
|
|
|
|
// these objects were large (1100 bytes on a 32 bit system).
|
|
|
|
// Then the nsLineLayout object was shrunk to 156 bytes by
|
|
|
|
// removing some internal buffers. Given that it is so much
|
|
|
|
// smaller, the complexity of 2 different ways of allocating
|
|
|
|
// no longer makes sense. Now we always allocate on the stack.
|
|
|
|
nsLineLayout lineLayout(aState.mPresContext,
|
|
|
|
aState.mReflowState.mFloatManager,
|
|
|
|
&aState.mReflowState, &aLine);
|
|
|
|
lineLayout.Init(&aState, aState.mMinLineHeight, aState.mLineNumber);
|
|
|
|
if (forceBreakInContent) {
|
|
|
|
lineLayout.ForceBreakAtPosition(forceBreakInContent, forceBreakOffset);
|
2006-10-19 01:47:47 +00:00
|
|
|
}
|
2009-06-16 15:00:20 +00:00
|
|
|
rv = DoReflowInlineFrames(aState, lineLayout, aLine,
|
|
|
|
floatAvailableSpace, availableSpaceHeight,
|
|
|
|
&floatManagerState, aKeepReflowGoing,
|
|
|
|
&lineReflowStatus, allowPullUp);
|
|
|
|
lineLayout.EndLineReflow();
|
|
|
|
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (LINE_REFLOW_REDO_NO_PULL == lineReflowStatus ||
|
|
|
|
LINE_REFLOW_REDO_MORE_FLOATS == lineReflowStatus ||
|
|
|
|
LINE_REFLOW_REDO_NEXT_BAND == lineReflowStatus) {
|
|
|
|
if (lineLayout.NeedsBackup()) {
|
|
|
|
NS_ASSERTION(!forceBreakInContent, "Backing up twice; this should never be necessary");
|
|
|
|
// If there is no saved break position, then this will set
|
|
|
|
// set forceBreakInContent to null and we won't back up, which is
|
|
|
|
// correct.
|
|
|
|
forceBreakInContent = lineLayout.GetLastOptionalBreakPosition(&forceBreakOffset, &forceBreakPriority);
|
|
|
|
} else {
|
|
|
|
forceBreakInContent = nsnull;
|
|
|
|
}
|
|
|
|
// restore the float manager state
|
|
|
|
aState.mReflowState.mFloatManager->PopState(&floatManagerState);
|
|
|
|
// Clear out float lists
|
|
|
|
aState.mCurrentLineFloats.DeleteAll();
|
|
|
|
aState.mBelowCurrentLineFloats.DeleteAll();
|
|
|
|
}
|
1999-03-24 15:42:19 +00:00
|
|
|
|
2009-06-16 15:00:20 +00:00
|
|
|
// Don't allow pullup on a subsequent LINE_REFLOW_REDO_NO_PULL pass
|
|
|
|
allowPullUp = PR_FALSE;
|
|
|
|
} while (LINE_REFLOW_REDO_NO_PULL == lineReflowStatus);
|
|
|
|
} while (LINE_REFLOW_REDO_MORE_FLOATS == lineReflowStatus);
|
|
|
|
} while (LINE_REFLOW_REDO_NEXT_BAND == lineReflowStatus);
|
2005-07-26 21:33:28 +00:00
|
|
|
|
1999-08-27 21:45:37 +00:00
|
|
|
return rv;
|
|
|
|
}
|
2000-01-08 03:58:27 +00:00
|
|
|
|
2002-05-28 22:50:43 +00:00
|
|
|
void
|
2010-08-06 04:59:20 +00:00
|
|
|
nsBlockFrame::PushTruncatedLine(nsBlockReflowState& aState,
|
|
|
|
line_iterator aLine,
|
|
|
|
PRBool& aKeepReflowGoing)
|
2002-05-28 22:50:43 +00:00
|
|
|
{
|
|
|
|
line_iterator prevLine = aLine;
|
|
|
|
--prevLine;
|
|
|
|
PushLines(aState, prevLine);
|
|
|
|
aKeepReflowGoing = PR_FALSE;
|
2007-07-26 04:03:29 +00:00
|
|
|
NS_FRAME_SET_INCOMPLETE(aState.mReflowStatus);
|
2002-05-28 22:50:43 +00:00
|
|
|
}
|
|
|
|
|
2006-10-19 01:47:47 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
static const char* LineReflowStatusNames[] = {
|
|
|
|
"LINE_REFLOW_OK", "LINE_REFLOW_STOP", "LINE_REFLOW_REDO_NO_PULL",
|
2009-05-20 11:21:34 +00:00
|
|
|
"LINE_REFLOW_REDO_MORE_FLOATS",
|
2006-10-19 01:47:47 +00:00
|
|
|
"LINE_REFLOW_REDO_NEXT_BAND", "LINE_REFLOW_TRUNCATED"
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
1999-08-27 21:45:37 +00:00
|
|
|
nsresult
|
|
|
|
nsBlockFrame::DoReflowInlineFrames(nsBlockReflowState& aState,
|
|
|
|
nsLineLayout& aLineLayout,
|
2001-10-25 01:08:40 +00:00
|
|
|
line_iterator aLine,
|
2009-05-20 11:21:34 +00:00
|
|
|
nsFlowAreaRect& aFloatAvailableSpace,
|
2009-06-16 15:00:20 +00:00
|
|
|
nscoord& aAvailableSpaceHeight,
|
2009-05-20 11:21:34 +00:00
|
|
|
nsFloatManager::SavedState*
|
|
|
|
aFloatStateBeforeLine,
|
1999-08-27 21:45:37 +00:00
|
|
|
PRBool* aKeepReflowGoing,
|
2006-06-29 01:19:48 +00:00
|
|
|
LineReflowStatus* aLineReflowStatus,
|
|
|
|
PRBool aAllowPullUp)
|
1999-08-27 21:45:37 +00:00
|
|
|
{
|
2003-10-13 21:51:02 +00:00
|
|
|
// Forget all of the floats on the line
|
|
|
|
aLine->FreeFloats(aState.mFloatCacheFreeList);
|
2010-10-07 04:25:45 +00:00
|
|
|
aState.mFloatOverflowAreas.Clear();
|
1999-03-27 01:22:14 +00:00
|
|
|
|
2009-05-20 11:21:34 +00:00
|
|
|
// We need to set this flag on the line if any of our reflow passes
|
|
|
|
// are impacted by floats.
|
|
|
|
if (aFloatAvailableSpace.mHasFloats)
|
|
|
|
aLine->SetLineIsImpactedByFloat(PR_TRUE);
|
2000-03-22 23:19:10 +00:00
|
|
|
#ifdef REALLY_NOISY_REFLOW
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("nsBlockFrame::DoReflowInlineFrames %p impacted = %d\n",
|
2009-05-20 11:21:34 +00:00
|
|
|
this, aFloatAvailableSpace.mHasFloats);
|
2000-03-22 23:19:10 +00:00
|
|
|
#endif
|
1999-08-27 21:45:37 +00:00
|
|
|
|
2010-08-11 19:32:53 +00:00
|
|
|
nscoord x = aFloatAvailableSpace.mRect.x;
|
2009-05-20 11:21:34 +00:00
|
|
|
nscoord availWidth = aFloatAvailableSpace.mRect.width;
|
1999-08-27 21:45:37 +00:00
|
|
|
nscoord availHeight;
|
2000-04-17 14:40:46 +00:00
|
|
|
if (aState.GetFlag(BRS_UNCONSTRAINEDHEIGHT)) {
|
1999-08-27 21:45:37 +00:00
|
|
|
availHeight = NS_UNCONSTRAINEDSIZE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* XXX get the height right! */
|
2009-05-20 11:21:34 +00:00
|
|
|
availHeight = aFloatAvailableSpace.mRect.height;
|
1999-08-27 21:45:37 +00:00
|
|
|
}
|
2007-05-21 09:55:27 +00:00
|
|
|
|
|
|
|
// Make sure to enable resize optimization before we call BeginLineReflow
|
|
|
|
// because it might get disabled there
|
|
|
|
aLine->EnableResizeReflowOptimization();
|
|
|
|
|
1999-08-27 21:45:37 +00:00
|
|
|
aLineLayout.BeginLineReflow(x, aState.mY,
|
|
|
|
availWidth, availHeight,
|
2009-05-20 11:21:34 +00:00
|
|
|
aFloatAvailableSpace.mHasFloats,
|
1999-08-27 21:45:37 +00:00
|
|
|
PR_FALSE /*XXX isTopOfPage*/);
|
1999-08-31 03:09:40 +00:00
|
|
|
|
2008-11-27 18:44:47 +00:00
|
|
|
aState.SetFlag(BRS_LINE_LAYOUT_EMPTY, PR_FALSE);
|
|
|
|
|
1999-08-31 03:09:40 +00:00
|
|
|
// XXX Unfortunately we need to know this before reflowing the first
|
|
|
|
// inline frame in the line. FIX ME.
|
1999-08-27 21:45:37 +00:00
|
|
|
if ((0 == aLineLayout.GetLineNumber()) &&
|
2007-12-05 08:15:15 +00:00
|
|
|
(NS_BLOCK_HAS_FIRST_LETTER_CHILD & mState) &&
|
1999-08-27 21:45:37 +00:00
|
|
|
(NS_BLOCK_HAS_FIRST_LETTER_STYLE & mState)) {
|
|
|
|
aLineLayout.SetFirstLetterStyleOK(PR_TRUE);
|
|
|
|
}
|
2009-12-22 23:44:35 +00:00
|
|
|
NS_ASSERTION(!((NS_BLOCK_HAS_FIRST_LETTER_CHILD & mState) &&
|
|
|
|
GetPrevContinuation()),
|
|
|
|
"first letter child bit should only be on first continuation");
|
1999-08-27 21:45:37 +00:00
|
|
|
|
|
|
|
// Reflow the frames that are already on the line first
|
|
|
|
nsresult rv = NS_OK;
|
2006-06-29 01:19:48 +00:00
|
|
|
LineReflowStatus lineReflowStatus = LINE_REFLOW_OK;
|
1999-08-27 21:45:37 +00:00
|
|
|
PRInt32 i;
|
|
|
|
nsIFrame* frame = aLine->mFirstChild;
|
2007-01-27 18:40:26 +00:00
|
|
|
|
2009-05-20 11:21:34 +00:00
|
|
|
if (aFloatAvailableSpace.mHasFloats) {
|
2006-10-19 01:47:47 +00:00
|
|
|
// There is a soft break opportunity at the start of the line, because
|
|
|
|
// we can always move this line down below float(s).
|
2008-07-24 07:16:18 +00:00
|
|
|
if (aLineLayout.NotifyOptionalBreakPosition(frame->GetContent(), 0, PR_TRUE, eNormalBreak)) {
|
2006-10-19 01:47:47 +00:00
|
|
|
lineReflowStatus = LINE_REFLOW_REDO_NEXT_BAND;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
bug 14280
nsTextTransformer.cpp.
I moved where we translate the nbsp to a (ascii 32 space character) until after the i18n routines are called, so they can properly account
for the space as non-breaking and therefore part of the first word in the block.
bug 39901 and 38396
nsHTMLImageLoader.*, nsImageFrame.cpp
I backed out the bad fix for 38396, and put in a new fix where I store a little state in the image loader flags for cases where the image
gets an unconstrained reflow and has %-based width. This does not handle %-based min-width or max-width, that would be a separate
bug that I'll file shortly. But this fixes the vast majority of real cases out there.
bug 18754
nsHRFrame.cpp, quirks.css, nsCSSFrameConstructor.cpp, last part of nsLineLayout.cpp
in quirks mode, I changed HR from a block element to a replaced inline element that acts like a block, using generated content to get
newlines before and after the HR. This isn't ideal, but it gets us backwards compatibility, and ian and dbaron have blessed the approach.
bug 50257
nsLineLayout.cpp
Did a couple of things in here:
* The actual fix is controlled by FIX_BUG_50257 #define symbol. This basically says that an break (BR) will always fit on a line.
A more general solution would probably be to round up to the nearest pixel, and if the thing is less than a pixel make it fit on a
line. This is a wimpier, safer solution.
* I noticed that the way we got the compatibility mode was way out of date, very wasteful. So I fixed that.
* I noticed that there were a bunch of redundant SetFlag calls. Since the flag variable is initialized to 0, setting a flag to 0 on a newly
created object is a waste.
nsBlockFrame.cpp -- just added a comment to some odd looking code, to make sure no one comes along later and breaks it
2000-09-11 21:15:02 +00:00
|
|
|
// need to repeatedly call GetChildCount here, because the child
|
|
|
|
// count can change during the loop!
|
2006-10-19 01:47:47 +00:00
|
|
|
for (i = 0; LINE_REFLOW_OK == lineReflowStatus && i < aLine->GetChildCount();
|
|
|
|
i++, frame = frame->GetNextSibling()) {
|
1999-08-27 21:45:37 +00:00
|
|
|
rv = ReflowInlineFrame(aState, aLineLayout, aLine, frame,
|
|
|
|
&lineReflowStatus);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
1999-08-27 21:45:37 +00:00
|
|
|
if (LINE_REFLOW_OK != lineReflowStatus) {
|
|
|
|
// It is possible that one or more of next lines are empty
|
2002-10-08 20:35:26 +00:00
|
|
|
// (because of DeleteNextInFlowChild). If so, delete them now
|
1999-08-27 21:45:37 +00:00
|
|
|
// in case we are finished.
|
2001-10-25 01:08:40 +00:00
|
|
|
++aLine;
|
|
|
|
while ((aLine != end_lines()) && (0 == aLine->GetChildCount())) {
|
2002-10-08 20:35:26 +00:00
|
|
|
// XXX Is this still necessary now that DeleteNextInFlowChild
|
1999-08-27 21:45:37 +00:00
|
|
|
// uses DoRemoveFrame?
|
2001-10-25 01:08:40 +00:00
|
|
|
nsLineBox *toremove = aLine;
|
|
|
|
aLine = mLines.erase(aLine);
|
|
|
|
NS_ASSERTION(nsnull == toremove->mFirstChild, "bad empty line");
|
|
|
|
aState.FreeLineBox(toremove);
|
1999-03-21 01:15:12 +00:00
|
|
|
}
|
2001-10-25 01:08:40 +00:00
|
|
|
--aLine;
|
2002-05-28 22:50:43 +00:00
|
|
|
|
2010-08-06 04:59:19 +00:00
|
|
|
NS_ASSERTION(lineReflowStatus != LINE_REFLOW_TRUNCATED,
|
|
|
|
"ReflowInlineFrame should never determine that a line "
|
|
|
|
"needs to go to the next page/column");
|
1999-03-21 01:15:12 +00:00
|
|
|
}
|
1999-08-27 21:45:37 +00:00
|
|
|
}
|
1999-03-21 01:15:12 +00:00
|
|
|
|
2005-03-23 03:35:08 +00:00
|
|
|
// Don't pull up new frames into lines with continuation placeholders
|
2009-08-31 18:25:35 +00:00
|
|
|
if (aAllowPullUp) {
|
2005-03-23 03:35:08 +00:00
|
|
|
// Pull frames and reflow them until we can't
|
1999-03-21 01:15:12 +00:00
|
|
|
while (LINE_REFLOW_OK == lineReflowStatus) {
|
2010-01-11 14:08:23 +00:00
|
|
|
frame = PullFrame(aState, aLine);
|
|
|
|
if (!frame) {
|
1999-08-27 21:45:37 +00:00
|
|
|
break;
|
1999-03-24 15:42:19 +00:00
|
|
|
}
|
2005-03-23 03:35:08 +00:00
|
|
|
|
|
|
|
while (LINE_REFLOW_OK == lineReflowStatus) {
|
|
|
|
PRInt32 oldCount = aLine->GetChildCount();
|
|
|
|
rv = ReflowInlineFrame(aState, aLineLayout, aLine, frame,
|
|
|
|
&lineReflowStatus);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2005-03-23 03:35:08 +00:00
|
|
|
if (aLine->GetChildCount() != oldCount) {
|
|
|
|
// We just created a continuation for aFrame AND its going
|
|
|
|
// to end up on this line (e.g. :first-letter
|
|
|
|
// situation). Therefore we have to loop here before trying
|
|
|
|
// to pull another frame.
|
|
|
|
frame = frame->GetNextSibling();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1999-03-21 01:15:12 +00:00
|
|
|
}
|
1999-08-27 21:45:37 +00:00
|
|
|
}
|
2005-03-23 03:35:08 +00:00
|
|
|
|
2008-11-27 18:44:47 +00:00
|
|
|
aState.SetFlag(BRS_LINE_LAYOUT_EMPTY, aLineLayout.LineIsEmpty());
|
|
|
|
|
2007-01-17 22:11:01 +00:00
|
|
|
// We only need to backup if the line isn't going to be reflowed again anyway
|
|
|
|
PRBool needsBackup = aLineLayout.NeedsBackup() &&
|
|
|
|
(lineReflowStatus == LINE_REFLOW_STOP || lineReflowStatus == LINE_REFLOW_OK);
|
|
|
|
if (needsBackup && aLineLayout.HaveForcedBreakPosition()) {
|
|
|
|
NS_WARNING("We shouldn't be backing up more than once! "
|
2007-02-21 01:52:03 +00:00
|
|
|
"Someone must have set a break opportunity beyond the available width, "
|
|
|
|
"even though there were better break opportunities before it");
|
2007-01-17 22:11:01 +00:00
|
|
|
needsBackup = PR_FALSE;
|
|
|
|
}
|
|
|
|
if (needsBackup) {
|
2006-10-19 01:47:47 +00:00
|
|
|
// We need to try backing up to before a text run
|
|
|
|
PRInt32 offset;
|
2008-07-24 07:16:18 +00:00
|
|
|
gfxBreakPriority breakPriority;
|
|
|
|
nsIContent* breakContent = aLineLayout.GetLastOptionalBreakPosition(&offset, &breakPriority);
|
2007-03-22 23:10:10 +00:00
|
|
|
// XXX It's possible, in fact not unusual, for the break opportunity to already
|
|
|
|
// be the end of the line. We should detect that and optimize to not
|
|
|
|
// re-do the line.
|
2006-10-19 01:47:47 +00:00
|
|
|
if (breakContent) {
|
|
|
|
// We can back up!
|
|
|
|
lineReflowStatus = LINE_REFLOW_REDO_NO_PULL;
|
|
|
|
}
|
|
|
|
} else {
|
2007-01-17 22:11:01 +00:00
|
|
|
// In case we reflow this line again, remember that we don't
|
|
|
|
// need to force any breaking
|
2006-10-19 01:47:47 +00:00
|
|
|
aLineLayout.ClearOptionalBreakPosition();
|
|
|
|
}
|
|
|
|
|
2006-06-29 01:19:48 +00:00
|
|
|
if (LINE_REFLOW_REDO_NEXT_BAND == lineReflowStatus) {
|
1999-08-27 21:45:37 +00:00
|
|
|
// This happens only when we have a line that is impacted by
|
2003-10-13 21:51:02 +00:00
|
|
|
// floats and the first element in the line doesn't fit with
|
|
|
|
// the floats.
|
1999-08-27 21:45:37 +00:00
|
|
|
//
|
2003-10-13 21:51:02 +00:00
|
|
|
// What we do is to advance past the first float we find and
|
1999-08-27 21:45:37 +00:00
|
|
|
// then reflow the line all over again.
|
2009-05-20 11:21:34 +00:00
|
|
|
NS_ASSERTION(NS_UNCONSTRAINEDSIZE != aFloatAvailableSpace.mRect.height,
|
1999-08-27 21:45:37 +00:00
|
|
|
"unconstrained height on totally empty line");
|
1999-10-29 14:34:53 +00:00
|
|
|
|
2008-01-29 07:40:05 +00:00
|
|
|
// See the analogous code for blocks in nsBlockReflowState::ClearFloats.
|
2009-05-20 11:21:34 +00:00
|
|
|
if (aFloatAvailableSpace.mRect.height > 0) {
|
|
|
|
NS_ASSERTION(aFloatAvailableSpace.mHasFloats,
|
2007-10-10 02:18:40 +00:00
|
|
|
"redo line on totally empty line with non-empty band...");
|
2009-05-20 11:21:34 +00:00
|
|
|
// We should never hit this case if we've placed floats on the
|
|
|
|
// line; if we have, then the GetFloatAvailableSpace call is wrong
|
|
|
|
// and needs to happen after the caller pops the space manager
|
|
|
|
// state.
|
|
|
|
aState.mFloatManager->AssertStateMatches(aFloatStateBeforeLine);
|
|
|
|
aState.mY += aFloatAvailableSpace.mRect.height;
|
|
|
|
aFloatAvailableSpace = aState.GetFloatAvailableSpace();
|
2005-03-23 03:35:08 +00:00
|
|
|
} else {
|
|
|
|
NS_ASSERTION(NS_UNCONSTRAINEDSIZE != aState.mReflowState.availableHeight,
|
|
|
|
"We shouldn't be running out of height here");
|
|
|
|
if (NS_UNCONSTRAINEDSIZE == aState.mReflowState.availableHeight) {
|
|
|
|
// just move it down a bit to try to get out of this mess
|
|
|
|
aState.mY += 1;
|
2009-05-20 11:21:34 +00:00
|
|
|
// We should never hit this case if we've placed floats on the
|
|
|
|
// line; if we have, then the GetFloatAvailableSpace call is wrong
|
|
|
|
// and needs to happen after the caller pops the space manager
|
|
|
|
// state.
|
|
|
|
aState.mFloatManager->AssertStateMatches(aFloatStateBeforeLine);
|
|
|
|
aFloatAvailableSpace = aState.GetFloatAvailableSpace();
|
2005-03-23 03:35:08 +00:00
|
|
|
} else {
|
2010-08-06 04:59:19 +00:00
|
|
|
// There's nowhere to retry placing the line, so we want to push
|
|
|
|
// it to the next page/column where its contents can fit not
|
|
|
|
// next to a float.
|
2005-03-23 03:35:08 +00:00
|
|
|
lineReflowStatus = LINE_REFLOW_TRUNCATED;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
// Push the line that didn't fit
|
2010-08-06 04:59:20 +00:00
|
|
|
PushTruncatedLine(aState, aLine, *aKeepReflowGoing);
|
2005-03-23 03:35:08 +00:00
|
|
|
}
|
|
|
|
}
|
2002-08-14 12:44:40 +00:00
|
|
|
|
1999-08-27 21:45:37 +00:00
|
|
|
// XXX: a small optimization can be done here when paginating:
|
|
|
|
// if the new Y coordinate is past the end of the block then
|
|
|
|
// push the line and return now instead of later on after we are
|
2003-10-13 21:51:02 +00:00
|
|
|
// past the float.
|
1999-08-27 21:45:37 +00:00
|
|
|
}
|
2009-05-20 11:21:34 +00:00
|
|
|
else if (LINE_REFLOW_TRUNCATED != lineReflowStatus &&
|
|
|
|
LINE_REFLOW_REDO_NO_PULL != lineReflowStatus) {
|
2001-12-23 23:23:41 +00:00
|
|
|
// If we are propagating out a break-before status then there is
|
1999-03-21 01:15:12 +00:00
|
|
|
// no point in placing the line.
|
1999-08-27 21:45:37 +00:00
|
|
|
if (!NS_INLINE_IS_BREAK_BEFORE(aState.mReflowStatus)) {
|
2009-05-20 11:21:34 +00:00
|
|
|
if (!PlaceLine(aState, aLineLayout, aLine, aFloatStateBeforeLine,
|
2009-06-16 15:00:20 +00:00
|
|
|
aFloatAvailableSpace.mRect, aAvailableSpaceHeight,
|
|
|
|
aKeepReflowGoing)) {
|
2009-05-20 11:21:34 +00:00
|
|
|
lineReflowStatus = LINE_REFLOW_REDO_MORE_FLOATS;
|
|
|
|
// PlaceLine already called GetAvailableSpaceForHeight for us.
|
|
|
|
}
|
1999-03-21 01:15:12 +00:00
|
|
|
}
|
|
|
|
}
|
2006-10-19 01:47:47 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (gNoisyReflow) {
|
|
|
|
printf("Line reflow status = %s\n", LineReflowStatusNames[lineReflowStatus]);
|
|
|
|
}
|
|
|
|
#endif
|
2009-10-27 01:43:56 +00:00
|
|
|
|
|
|
|
if (aLineLayout.GetDirtyNextLine()) {
|
|
|
|
// aLine may have been pushed to the overflow lines.
|
|
|
|
nsLineList* overflowLines = GetOverflowLines();
|
|
|
|
// We can't just compare iterators front() to aLine here, since they may be in
|
|
|
|
// different lists.
|
|
|
|
PRBool pushedToOverflowLines = overflowLines &&
|
|
|
|
overflowLines->front() == aLine.get();
|
|
|
|
if (pushedToOverflowLines) {
|
|
|
|
// aLine is stale, it's associated with the main line list but it should
|
|
|
|
// be associated with the overflow line list now
|
|
|
|
aLine = overflowLines->begin();
|
|
|
|
}
|
|
|
|
nsBlockInFlowLineIterator iter(this, aLine, pushedToOverflowLines);
|
|
|
|
if (iter.Next() && iter.GetLine()->IsInline()) {
|
|
|
|
iter.GetLine()->MarkDirty();
|
|
|
|
if (iter.GetContainer() != this) {
|
|
|
|
aState.mReflowStatus |= NS_FRAME_REFLOW_NEXTINFLOW;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-08-27 21:45:37 +00:00
|
|
|
*aLineReflowStatus = lineReflowStatus;
|
1999-03-21 01:15:12 +00:00
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
/**
|
|
|
|
* Reflow an inline frame. The reflow status is mapped from the frames
|
|
|
|
* reflow status to the lines reflow status (not to our reflow status).
|
|
|
|
* The line reflow status is simple: PR_TRUE means keep placing frames
|
|
|
|
* on the line; PR_FALSE means don't (the line is done). If the line
|
1999-10-14 23:10:03 +00:00
|
|
|
* has some sort of breaking affect then aLine's break-type will be set
|
1998-12-05 16:02:08 +00:00
|
|
|
* to something other than NS_STYLE_CLEAR_NONE.
|
|
|
|
*/
|
|
|
|
nsresult
|
1999-02-09 17:31:33 +00:00
|
|
|
nsBlockFrame::ReflowInlineFrame(nsBlockReflowState& aState,
|
1999-08-27 21:45:37 +00:00
|
|
|
nsLineLayout& aLineLayout,
|
2001-10-25 01:08:40 +00:00
|
|
|
line_iterator aLine,
|
1999-02-12 17:45:58 +00:00
|
|
|
nsIFrame* aFrame,
|
2006-06-29 01:19:48 +00:00
|
|
|
LineReflowStatus* aLineReflowStatus)
|
1998-12-05 16:02:08 +00:00
|
|
|
{
|
2006-06-29 01:19:48 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(aFrame);
|
2001-10-03 00:01:04 +00:00
|
|
|
|
1999-03-21 01:15:12 +00:00
|
|
|
*aLineReflowStatus = LINE_REFLOW_OK;
|
1998-10-30 22:10:10 +00:00
|
|
|
|
1999-04-27 22:10:51 +00:00
|
|
|
#ifdef NOISY_FIRST_LETTER
|
|
|
|
ListTag(stdout);
|
2000-10-28 22:17:53 +00:00
|
|
|
printf(": reflowing ");
|
1999-04-27 22:10:51 +00:00
|
|
|
nsFrame::ListTag(stdout, aFrame);
|
2008-08-06 00:31:25 +00:00
|
|
|
printf(" reflowingFirstLetter=%s\n",
|
|
|
|
aLineLayout.GetFirstLetterStyleOK() ? "on" : "off");
|
1999-04-27 22:10:51 +00:00
|
|
|
#endif
|
1998-06-18 16:25:41 +00:00
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
// Reflow the inline frame
|
|
|
|
nsReflowStatus frameReflowStatus;
|
2000-01-03 04:32:13 +00:00
|
|
|
PRBool pushedFrame;
|
2002-05-10 18:22:41 +00:00
|
|
|
nsresult rv = aLineLayout.ReflowFrame(aFrame, frameReflowStatus,
|
|
|
|
nsnull, pushedFrame);
|
2007-04-22 20:57:54 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2002-05-10 18:22:41 +00:00
|
|
|
|
2005-03-23 03:35:08 +00:00
|
|
|
if (frameReflowStatus & NS_FRAME_REFLOW_NEXTINFLOW) {
|
2009-10-27 01:43:56 +00:00
|
|
|
aLineLayout.SetDirtyNextLine();
|
2005-03-23 03:35:08 +00:00
|
|
|
}
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
1999-03-16 19:36:00 +00:00
|
|
|
#ifdef REALLY_NOISY_REFLOW_CHILD
|
|
|
|
nsFrame::ListTag(stdout, aFrame);
|
2000-10-28 22:17:53 +00:00
|
|
|
printf(": status=%x\n", frameReflowStatus);
|
1999-03-16 19:36:00 +00:00
|
|
|
#endif
|
1998-09-10 19:32:14 +00:00
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
#if defined(REFLOW_STATUS_COVERAGE)
|
1999-02-09 17:31:33 +00:00
|
|
|
RecordReflowStatus(PR_FALSE, frameReflowStatus);
|
1998-12-05 16:02:08 +00:00
|
|
|
#endif
|
1998-09-10 19:32:14 +00:00
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
// Send post-reflow notification
|
|
|
|
aState.mPrevChild = aFrame;
|
1998-09-10 19:32:14 +00:00
|
|
|
|
2000-06-14 23:15:59 +00:00
|
|
|
/* XXX
|
|
|
|
This is where we need to add logic to handle some odd behavior.
|
|
|
|
For one thing, we should usually place at least one thing next
|
2003-10-13 21:51:02 +00:00
|
|
|
to a left float, even when that float takes up all the width on a line.
|
2000-06-14 23:15:59 +00:00
|
|
|
see bug 22496
|
|
|
|
*/
|
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
// Process the child frames reflow status. There are 5 cases:
|
|
|
|
// complete, not-complete, break-before, break-after-complete,
|
|
|
|
// break-after-not-complete. There are two situations: we are a
|
|
|
|
// block or we are an inline. This makes a total of 10 cases
|
|
|
|
// (fortunately, there is some overlap).
|
2004-11-25 14:51:00 +00:00
|
|
|
aLine->SetBreakTypeAfter(NS_STYLE_CLEAR_NONE);
|
2002-07-17 01:48:56 +00:00
|
|
|
if (NS_INLINE_IS_BREAK(frameReflowStatus) ||
|
2003-10-13 21:51:02 +00:00
|
|
|
(NS_STYLE_CLEAR_NONE != aState.mFloatBreakType)) {
|
1998-12-05 16:02:08 +00:00
|
|
|
// Always abort the line reflow (because a line break is the
|
|
|
|
// minimal amount of break we do).
|
1999-03-21 01:15:12 +00:00
|
|
|
*aLineReflowStatus = LINE_REFLOW_STOP;
|
1998-12-05 16:02:08 +00:00
|
|
|
|
1999-10-14 23:10:03 +00:00
|
|
|
// XXX what should aLine's break-type be set to in all these cases?
|
1998-12-05 16:02:08 +00:00
|
|
|
PRUint8 breakType = NS_INLINE_GET_BREAK_TYPE(frameReflowStatus);
|
2002-07-17 01:48:56 +00:00
|
|
|
NS_ASSERTION((NS_STYLE_CLEAR_NONE != breakType) ||
|
2003-10-13 21:51:02 +00:00
|
|
|
(NS_STYLE_CLEAR_NONE != aState.mFloatBreakType), "bad break type");
|
1998-12-05 16:02:08 +00:00
|
|
|
NS_ASSERTION(NS_STYLE_CLEAR_PAGE != breakType, "no page breaks yet");
|
|
|
|
|
|
|
|
if (NS_INLINE_IS_BREAK_BEFORE(frameReflowStatus)) {
|
|
|
|
// Break-before cases.
|
|
|
|
if (aFrame == aLine->mFirstChild) {
|
1999-03-21 01:15:12 +00:00
|
|
|
// If we break before the first frame on the line then we must
|
2005-11-20 22:05:24 +00:00
|
|
|
// be trying to place content where there's no room (e.g. on a
|
2003-10-13 21:51:02 +00:00
|
|
|
// line with wide floats). Inform the caller to reflow the
|
|
|
|
// line after skipping past a float.
|
2006-06-29 01:19:48 +00:00
|
|
|
*aLineReflowStatus = LINE_REFLOW_REDO_NEXT_BAND;
|
1998-12-05 16:02:08 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// It's not the first child on this line so go ahead and split
|
|
|
|
// the line. We will see the frame again on the next-line.
|
2006-06-29 01:19:48 +00:00
|
|
|
rv = SplitLine(aState, aLineLayout, aLine, aFrame, aLineReflowStatus);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2000-01-03 04:32:13 +00:00
|
|
|
|
|
|
|
// If we're splitting the line because the frame didn't fit and it
|
|
|
|
// was pushed, then mark the line as having word wrapped. We need to
|
|
|
|
// know that if we're shrink wrapping our width
|
|
|
|
if (pushedFrame) {
|
|
|
|
aLine->SetLineWrapped(PR_TRUE);
|
|
|
|
}
|
1998-12-05 16:02:08 +00:00
|
|
|
}
|
1998-09-10 19:32:14 +00:00
|
|
|
}
|
1998-12-05 16:02:08 +00:00
|
|
|
else {
|
2003-10-13 21:51:02 +00:00
|
|
|
// If a float split and its prev-in-flow was followed by a <BR>, then combine
|
2002-07-17 01:48:56 +00:00
|
|
|
// the <BR>'s break type with the inline's break type (the inline will be the very
|
2003-10-13 21:51:02 +00:00
|
|
|
// next frame after the split float).
|
|
|
|
if (NS_STYLE_CLEAR_NONE != aState.mFloatBreakType) {
|
2004-11-25 14:51:00 +00:00
|
|
|
breakType = nsLayoutUtils::CombineBreakType(breakType,
|
|
|
|
aState.mFloatBreakType);
|
2003-10-13 21:51:02 +00:00
|
|
|
aState.mFloatBreakType = NS_STYLE_CLEAR_NONE;
|
2002-07-17 01:48:56 +00:00
|
|
|
}
|
1998-12-05 16:02:08 +00:00
|
|
|
// Break-after cases
|
1999-10-29 14:34:53 +00:00
|
|
|
if (breakType == NS_STYLE_CLEAR_LINE) {
|
|
|
|
if (!aLineLayout.GetLineEndsInBR()) {
|
2004-01-18 18:20:57 +00:00
|
|
|
breakType = NS_STYLE_CLEAR_NONE;
|
1999-10-29 14:34:53 +00:00
|
|
|
}
|
|
|
|
}
|
2004-11-25 14:51:00 +00:00
|
|
|
aLine->SetBreakTypeAfter(breakType);
|
2008-04-08 14:42:52 +00:00
|
|
|
if (NS_FRAME_IS_COMPLETE(frameReflowStatus)) {
|
|
|
|
// Split line, but after the frame just reflowed
|
|
|
|
rv = SplitLine(aState, aLineLayout, aLine, aFrame->GetNextSibling(), aLineReflowStatus);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2001-05-16 15:51:17 +00:00
|
|
|
|
2008-04-08 14:42:52 +00:00
|
|
|
if (NS_INLINE_IS_BREAK_AFTER(frameReflowStatus) &&
|
|
|
|
!aLineLayout.GetLineEndsInBR()) {
|
2009-10-27 01:43:56 +00:00
|
|
|
aLineLayout.SetDirtyNextLine();
|
2005-07-21 22:17:34 +00:00
|
|
|
}
|
2001-05-16 15:51:17 +00:00
|
|
|
}
|
1998-12-05 16:02:08 +00:00
|
|
|
}
|
|
|
|
}
|
2002-05-28 22:50:43 +00:00
|
|
|
|
2009-08-31 18:25:36 +00:00
|
|
|
if (!NS_FRAME_IS_FULLY_COMPLETE(frameReflowStatus)) {
|
1998-12-05 16:02:08 +00:00
|
|
|
// Create a continuation for the incomplete frame. Note that the
|
|
|
|
// frame may already have a continuation.
|
2008-04-08 14:42:52 +00:00
|
|
|
nsIAtom* frameType = aFrame->GetType();
|
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
PRBool madeContinuation;
|
2010-08-06 04:59:19 +00:00
|
|
|
rv = CreateContinuationFor(aState, aLine, aFrame, madeContinuation);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
1998-12-05 16:02:08 +00:00
|
|
|
|
2000-01-03 04:32:13 +00:00
|
|
|
// Remember that the line has wrapped
|
2004-04-23 19:27:14 +00:00
|
|
|
if (!aLineLayout.GetLineEndsInBR()) {
|
|
|
|
aLine->SetLineWrapped(PR_TRUE);
|
|
|
|
}
|
2000-01-03 04:32:13 +00:00
|
|
|
|
2008-08-06 00:31:25 +00:00
|
|
|
// If we just ended a first-letter frame or reflowed a placeholder then
|
2002-05-28 22:50:43 +00:00
|
|
|
// don't split the line and don't stop the line reflow...
|
2010-01-28 04:12:45 +00:00
|
|
|
// But if we are going to stop anyways we'd better split the line.
|
|
|
|
if ((!(frameReflowStatus & NS_INLINE_BREAK_FIRST_LETTER_COMPLETE) &&
|
|
|
|
nsGkAtoms::placeholderFrame != frameType) ||
|
|
|
|
*aLineReflowStatus == LINE_REFLOW_STOP) {
|
1998-12-05 16:02:08 +00:00
|
|
|
// Split line after the current frame
|
1999-03-21 01:15:12 +00:00
|
|
|
*aLineReflowStatus = LINE_REFLOW_STOP;
|
2006-06-29 01:19:48 +00:00
|
|
|
rv = SplitLine(aState, aLineLayout, aLine, aFrame->GetNextSibling(), aLineReflowStatus);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
1998-12-05 16:02:08 +00:00
|
|
|
}
|
1998-09-10 19:32:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-06-30 20:14:04 +00:00
|
|
|
nsresult
|
1999-02-09 17:31:33 +00:00
|
|
|
nsBlockFrame::CreateContinuationFor(nsBlockReflowState& aState,
|
2002-05-28 22:50:43 +00:00
|
|
|
nsLineBox* aLine,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
PRBool& aMadeNewFrame)
|
1998-06-30 20:14:04 +00:00
|
|
|
{
|
1998-12-05 16:02:08 +00:00
|
|
|
aMadeNewFrame = PR_FALSE;
|
2009-09-18 11:09:35 +00:00
|
|
|
|
|
|
|
if (!aFrame->GetNextInFlow()) {
|
|
|
|
nsIFrame* newFrame;
|
|
|
|
nsresult rv = aState.mPresContext->PresShell()->FrameConstructor()->
|
|
|
|
CreateContinuingFrame(aState.mPresContext, aFrame, this, &newFrame);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2009-09-29 19:47:05 +00:00
|
|
|
mFrames.InsertFrame(nsnull, aFrame, newFrame);
|
2009-09-18 11:09:35 +00:00
|
|
|
|
2002-05-28 22:50:43 +00:00
|
|
|
if (aLine) {
|
|
|
|
aLine->SetChildCount(aLine->GetChildCount() + 1);
|
|
|
|
}
|
2009-09-18 11:09:35 +00:00
|
|
|
|
|
|
|
aMadeNewFrame = PR_TRUE;
|
1998-12-05 16:02:08 +00:00
|
|
|
}
|
1999-03-16 19:36:00 +00:00
|
|
|
#ifdef DEBUG
|
1999-04-20 00:27:43 +00:00
|
|
|
VerifyLines(PR_FALSE);
|
1999-03-16 19:36:00 +00:00
|
|
|
#endif
|
2009-09-18 11:09:35 +00:00
|
|
|
return NS_OK;
|
1998-06-30 20:14:04 +00:00
|
|
|
}
|
|
|
|
|
2002-05-28 22:50:43 +00:00
|
|
|
nsresult
|
2009-08-31 18:25:36 +00:00
|
|
|
nsBlockFrame::SplitFloat(nsBlockReflowState& aState,
|
|
|
|
nsIFrame* aFloat,
|
|
|
|
nsReflowStatus aFloatStatus)
|
2002-05-28 22:50:43 +00:00
|
|
|
{
|
2010-08-06 04:59:19 +00:00
|
|
|
nsIFrame* nextInFlow = aFloat->GetNextInFlow();
|
|
|
|
if (nextInFlow) {
|
|
|
|
nsContainerFrame *oldParent =
|
|
|
|
static_cast<nsContainerFrame*>(nextInFlow->GetParent());
|
|
|
|
nsresult rv = oldParent->StealFrame(aState.mPresContext, nextInFlow);
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "StealFrame failed");
|
|
|
|
if (oldParent != this) {
|
|
|
|
ReparentFrame(nextInFlow, oldParent, this);
|
|
|
|
}
|
|
|
|
} else {
|
2009-09-18 11:09:35 +00:00
|
|
|
nsresult rv = aState.mPresContext->PresShell()->FrameConstructor()->
|
|
|
|
CreateContinuingFrame(aState.mPresContext, aFloat, this, &nextInFlow);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
2009-08-31 18:25:36 +00:00
|
|
|
if (NS_FRAME_OVERFLOW_IS_INCOMPLETE(aFloatStatus))
|
|
|
|
aFloat->GetNextInFlow()->AddStateBits(NS_FRAME_IS_OVERFLOW_CONTAINER);
|
|
|
|
|
2010-08-06 04:59:19 +00:00
|
|
|
// The containing block is now overflow-incomplete.
|
|
|
|
NS_FRAME_SET_OVERFLOW_INCOMPLETE(aState.mReflowStatus);
|
2005-03-23 03:35:08 +00:00
|
|
|
|
2010-08-06 04:59:19 +00:00
|
|
|
if (aFloat->GetStyleDisplay()->mFloats == NS_STYLE_FLOAT_LEFT) {
|
|
|
|
aState.mFloatManager->SetSplitLeftFloatAcrossBreak();
|
|
|
|
} else {
|
|
|
|
NS_ABORT_IF_FALSE(aFloat->GetStyleDisplay()->mFloats ==
|
|
|
|
NS_STYLE_FLOAT_RIGHT, "unexpected float side");
|
|
|
|
aState.mFloatManager->SetSplitRightFloatAcrossBreak();
|
|
|
|
}
|
|
|
|
|
2010-08-06 04:59:20 +00:00
|
|
|
aState.AppendPushedFloat(nextInFlow);
|
2002-05-28 22:50:43 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2006-06-29 01:19:48 +00:00
|
|
|
static nsFloatCache*
|
|
|
|
GetLastFloat(nsLineBox* aLine)
|
|
|
|
{
|
|
|
|
nsFloatCache* fc = aLine->GetFirstFloat();
|
|
|
|
while (fc && fc->Next()) {
|
|
|
|
fc = fc->Next();
|
|
|
|
}
|
|
|
|
return fc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PRBool
|
|
|
|
CheckPlaceholderInLine(nsIFrame* aBlock, nsLineBox* aLine, nsFloatCache* aFC)
|
|
|
|
{
|
2010-08-06 04:59:19 +00:00
|
|
|
if (!aFC)
|
2006-06-29 01:19:48 +00:00
|
|
|
return PR_TRUE;
|
2010-08-06 04:59:19 +00:00
|
|
|
NS_ASSERTION(!aFC->mFloat->GetPrevContinuation(),
|
|
|
|
"float in a line should never be a continuation");
|
2010-08-06 04:59:20 +00:00
|
|
|
NS_ASSERTION(!(aFC->mFloat->GetStateBits() & NS_FRAME_IS_PUSHED_FLOAT),
|
2010-08-06 04:59:19 +00:00
|
|
|
"float in a line should never be a pushed float");
|
2009-08-31 18:25:35 +00:00
|
|
|
nsIFrame* ph = aBlock->PresContext()->FrameManager()->
|
|
|
|
GetPlaceholderFrameFor(aFC->mFloat->GetFirstInFlow());
|
|
|
|
for (nsIFrame* f = ph; f; f = f->GetParent()) {
|
2006-06-29 01:19:48 +00:00
|
|
|
if (f->GetParent() == aBlock)
|
|
|
|
return aLine->Contains(f);
|
|
|
|
}
|
|
|
|
NS_ASSERTION(PR_FALSE, "aBlock is not an ancestor of aFrame!");
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
nsresult
|
1999-02-09 17:31:33 +00:00
|
|
|
nsBlockFrame::SplitLine(nsBlockReflowState& aState,
|
1999-08-27 21:45:37 +00:00
|
|
|
nsLineLayout& aLineLayout,
|
2001-10-25 01:08:40 +00:00
|
|
|
line_iterator aLine,
|
2006-06-29 01:19:48 +00:00
|
|
|
nsIFrame* aFrame,
|
|
|
|
LineReflowStatus* aLineReflowStatus)
|
1998-10-02 21:50:53 +00:00
|
|
|
{
|
1999-10-14 23:10:03 +00:00
|
|
|
NS_ABORT_IF_FALSE(aLine->IsInline(), "illegal SplitLine on block line");
|
|
|
|
|
|
|
|
PRInt32 pushCount = aLine->GetChildCount() - aLineLayout.GetCurrentSpanCount();
|
|
|
|
NS_ABORT_IF_FALSE(pushCount >= 0, "bad push count");
|
|
|
|
|
1999-10-29 14:34:53 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (gNoisyReflow) {
|
|
|
|
nsFrame::IndentBy(stdout, gNoiseIndent);
|
2001-10-25 01:08:40 +00:00
|
|
|
printf("split line: from line=%p pushCount=%d aFrame=",
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<void*>(aLine.get()), pushCount);
|
1999-11-02 15:44:57 +00:00
|
|
|
if (aFrame) {
|
|
|
|
nsFrame::ListTag(stdout, aFrame);
|
|
|
|
}
|
|
|
|
else {
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("(null)");
|
1999-11-02 15:44:57 +00:00
|
|
|
}
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("\n");
|
1999-10-29 14:34:53 +00:00
|
|
|
if (gReallyNoisyReflow) {
|
2005-09-06 21:34:50 +00:00
|
|
|
aLine->List(stdout, gNoiseIndent+1);
|
1999-10-29 14:34:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
if (0 != pushCount) {
|
1999-10-14 23:10:03 +00:00
|
|
|
NS_ABORT_IF_FALSE(aLine->GetChildCount() > pushCount, "bad push");
|
|
|
|
NS_ABORT_IF_FALSE(nsnull != aFrame, "whoops");
|
2010-08-19 13:38:00 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
{
|
|
|
|
nsIFrame *f = aFrame;
|
|
|
|
PRInt32 count = pushCount;
|
|
|
|
while (f && count > 0) {
|
|
|
|
f = f->GetNextSibling();
|
|
|
|
--count;
|
|
|
|
}
|
|
|
|
NS_ASSERTION(count == 0, "Not enough frames to push");
|
|
|
|
}
|
|
|
|
#endif
|
1999-10-14 23:10:03 +00:00
|
|
|
|
|
|
|
// Put frames being split out into their own line
|
1999-10-19 23:04:19 +00:00
|
|
|
nsLineBox* newLine = aState.NewLineBox(aFrame, pushCount, PR_FALSE);
|
1999-10-14 23:10:03 +00:00
|
|
|
if (!newLine) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
1998-10-02 21:50:53 +00:00
|
|
|
}
|
2001-10-25 01:08:40 +00:00
|
|
|
mLines.after_insert(aLine, newLine);
|
1999-10-14 23:10:03 +00:00
|
|
|
aLine->SetChildCount(aLine->GetChildCount() - pushCount);
|
1999-10-29 14:34:53 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (gReallyNoisyReflow) {
|
2005-09-06 21:34:50 +00:00
|
|
|
newLine->List(stdout, gNoiseIndent+1);
|
1999-10-29 14:34:53 +00:00
|
|
|
}
|
|
|
|
#endif
|
1998-10-02 21:50:53 +00:00
|
|
|
|
1999-03-18 21:03:25 +00:00
|
|
|
// Let line layout know that some frames are no longer part of its
|
|
|
|
// state.
|
1999-10-14 23:10:03 +00:00
|
|
|
aLineLayout.SplitLineTo(aLine->GetChildCount());
|
2006-06-29 01:19:48 +00:00
|
|
|
|
|
|
|
// If floats have been placed whose placeholders have been pushed to the new
|
|
|
|
// line, we need to reflow the old line again. We don't want to look at the
|
|
|
|
// frames in the new line, because as a large paragraph is laid out the
|
|
|
|
// we'd get O(N^2) performance. So instead we just check that the last
|
|
|
|
// float and the last below-current-line float are still in aLine.
|
|
|
|
if (!CheckPlaceholderInLine(this, aLine, GetLastFloat(aLine)) ||
|
|
|
|
!CheckPlaceholderInLine(this, aLine, aState.mBelowCurrentLineFloats.Tail())) {
|
|
|
|
*aLineReflowStatus = LINE_REFLOW_REDO_NO_PULL;
|
|
|
|
}
|
|
|
|
|
1999-03-16 19:36:00 +00:00
|
|
|
#ifdef DEBUG
|
1999-04-20 00:27:43 +00:00
|
|
|
VerifyLines(PR_TRUE);
|
1999-03-16 19:36:00 +00:00
|
|
|
#endif
|
1998-12-05 16:02:08 +00:00
|
|
|
}
|
|
|
|
return NS_OK;
|
1998-10-02 21:50:53 +00:00
|
|
|
}
|
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
PRBool
|
2001-10-25 01:08:40 +00:00
|
|
|
nsBlockFrame::ShouldJustifyLine(nsBlockReflowState& aState,
|
|
|
|
line_iterator aLine)
|
1998-06-24 17:52:42 +00:00
|
|
|
{
|
2001-10-25 01:08:40 +00:00
|
|
|
while (++aLine != end_lines()) {
|
1998-12-05 16:02:08 +00:00
|
|
|
// There is another line
|
2001-10-25 01:08:40 +00:00
|
|
|
if (0 != aLine->GetChildCount()) {
|
1998-12-05 16:02:08 +00:00
|
|
|
// If the next line is a block line then we must not justify
|
|
|
|
// this line because it means that this line is the last in a
|
|
|
|
// group of inline lines.
|
2001-10-25 01:08:40 +00:00
|
|
|
return !aLine->IsBlock();
|
1998-12-05 16:02:08 +00:00
|
|
|
}
|
|
|
|
// The next line is empty, try the next one
|
1998-06-30 20:14:04 +00:00
|
|
|
}
|
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
// XXX Not sure about this part
|
|
|
|
// Try our next-in-flows lines to answer the question
|
2006-02-21 21:33:47 +00:00
|
|
|
nsBlockFrame* nextInFlow = (nsBlockFrame*) GetNextInFlow();
|
1998-12-05 16:02:08 +00:00
|
|
|
while (nsnull != nextInFlow) {
|
2001-10-25 01:08:40 +00:00
|
|
|
for (line_iterator line = nextInFlow->begin_lines(),
|
|
|
|
line_end = nextInFlow->end_lines();
|
|
|
|
line != line_end;
|
|
|
|
++line)
|
|
|
|
{
|
|
|
|
if (0 != line->GetChildCount())
|
1998-12-11 15:49:07 +00:00
|
|
|
return !line->IsBlock();
|
1998-11-11 03:55:55 +00:00
|
|
|
}
|
2006-02-21 21:33:47 +00:00
|
|
|
nextInFlow = (nsBlockFrame*) nextInFlow->GetNextInFlow();
|
1998-12-05 16:02:08 +00:00
|
|
|
}
|
1998-11-11 03:55:55 +00:00
|
|
|
|
1998-12-11 15:49:07 +00:00
|
|
|
// This is the last line - so don't allow justification
|
|
|
|
return PR_FALSE;
|
1998-12-05 16:02:08 +00:00
|
|
|
}
|
|
|
|
|
2009-05-20 11:21:34 +00:00
|
|
|
PRBool
|
1999-02-09 17:31:33 +00:00
|
|
|
nsBlockFrame::PlaceLine(nsBlockReflowState& aState,
|
2002-07-17 01:48:56 +00:00
|
|
|
nsLineLayout& aLineLayout,
|
|
|
|
line_iterator aLine,
|
2009-05-20 11:21:34 +00:00
|
|
|
nsFloatManager::SavedState *aFloatStateBeforeLine,
|
|
|
|
nsRect& aFloatAvailableSpace,
|
2009-06-16 15:00:20 +00:00
|
|
|
nscoord& aAvailableSpaceHeight,
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
PRBool* aKeepReflowGoing)
|
1998-12-05 16:02:08 +00:00
|
|
|
{
|
1999-09-21 00:13:50 +00:00
|
|
|
// Trim extra white-space from the line before placing the frames
|
2001-10-25 01:08:40 +00:00
|
|
|
aLineLayout.TrimTrailingWhiteSpace();
|
1999-09-21 00:13:50 +00:00
|
|
|
|
1999-02-18 22:22:55 +00:00
|
|
|
// Vertically align the frames on this line.
|
|
|
|
//
|
|
|
|
// According to the CSS2 spec, section 12.6.1, the "marker" box
|
|
|
|
// participates in the height calculation of the list-item box's
|
|
|
|
// first line box.
|
|
|
|
//
|
|
|
|
// There are exactly two places a bullet can be placed: near the
|
2005-11-20 22:05:24 +00:00
|
|
|
// first or second line. It's only placed on the second line in a
|
2008-02-10 21:49:24 +00:00
|
|
|
// rare case: when the first line is empty.
|
1999-02-18 22:22:55 +00:00
|
|
|
PRBool addedBullet = PR_FALSE;
|
2008-02-10 21:49:24 +00:00
|
|
|
if (mBullet && HaveOutsideBullet() &&
|
|
|
|
((aLine == mLines.front() &&
|
|
|
|
(!aLineLayout.IsZeroHeight() || (aLine == mLines.back()))) ||
|
|
|
|
(mLines.front() != mLines.back() &&
|
|
|
|
0 == mLines.front()->mBounds.height &&
|
|
|
|
aLine == mLines.begin().next()))) {
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsHTMLReflowMetrics metrics;
|
2008-02-10 21:49:24 +00:00
|
|
|
ReflowBullet(aState, metrics, aState.mY);
|
2009-09-11 10:46:36 +00:00
|
|
|
NS_ASSERTION(!BulletIsEmpty() || metrics.height == 0,
|
|
|
|
"empty bullet took up space");
|
1999-08-27 21:45:37 +00:00
|
|
|
aLineLayout.AddBulletFrame(mBullet, metrics);
|
1999-02-18 22:22:55 +00:00
|
|
|
addedBullet = PR_TRUE;
|
|
|
|
}
|
2007-01-18 01:20:09 +00:00
|
|
|
aLineLayout.VerticalAlignLine();
|
2000-07-28 09:18:15 +00:00
|
|
|
|
2009-05-20 11:21:34 +00:00
|
|
|
// We want to compare to the available space that we would have had in
|
|
|
|
// the line's height *before* we placed any floats in the line itself.
|
|
|
|
// Floats that are in the line are handled during line reflow (and may
|
|
|
|
// result in floats being pushed to below the line or (I HOPE???) in a
|
|
|
|
// reflow with a forced break position).
|
|
|
|
nsRect oldFloatAvailableSpace(aFloatAvailableSpace);
|
2009-06-16 15:00:20 +00:00
|
|
|
// As we redo for floats, we can't reduce the amount of height we're
|
|
|
|
// checking.
|
2009-09-16 15:01:36 +00:00
|
|
|
aAvailableSpaceHeight = NS_MAX(aAvailableSpaceHeight, aLine->mBounds.height);
|
2009-05-20 11:21:34 +00:00
|
|
|
aFloatAvailableSpace =
|
|
|
|
aState.GetFloatAvailableSpaceForHeight(aLine->mBounds.y,
|
2009-06-16 15:00:20 +00:00
|
|
|
aAvailableSpaceHeight,
|
2009-05-20 11:21:34 +00:00
|
|
|
aFloatStateBeforeLine).mRect;
|
|
|
|
NS_ASSERTION(aFloatAvailableSpace.y == oldFloatAvailableSpace.y, "yikes");
|
|
|
|
// Restore the height to the position of the next band.
|
|
|
|
aFloatAvailableSpace.height = oldFloatAvailableSpace.height;
|
|
|
|
// If the available space between the floats is smaller now that we
|
|
|
|
// know the height, return false (and cause another pass with
|
|
|
|
// LINE_REFLOW_REDO_MORE_FLOATS).
|
|
|
|
if (AvailableSpaceShrunk(oldFloatAvailableSpace, aFloatAvailableSpace)) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
1999-03-20 21:57:03 +00:00
|
|
|
#ifdef DEBUG
|
2001-10-25 01:08:40 +00:00
|
|
|
{
|
|
|
|
static nscoord lastHeight = 0;
|
|
|
|
if (CRAZY_HEIGHT(aLine->mBounds.y)) {
|
|
|
|
lastHeight = aLine->mBounds.y;
|
|
|
|
if (abs(aLine->mBounds.y - lastHeight) > CRAZY_H/10) {
|
|
|
|
nsFrame::ListTag(stdout);
|
|
|
|
printf(": line=%p y=%d line.bounds.height=%d\n",
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<void*>(aLine.get()),
|
2001-10-25 01:08:40 +00:00
|
|
|
aLine->mBounds.y, aLine->mBounds.height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
lastHeight = 0;
|
|
|
|
}
|
1999-03-20 21:57:03 +00:00
|
|
|
}
|
1999-03-05 04:21:32 +00:00
|
|
|
#endif
|
1998-12-05 16:02:08 +00:00
|
|
|
|
|
|
|
// Only block frames horizontally align their children because
|
|
|
|
// inline frames "shrink-wrap" around their children (therefore
|
|
|
|
// there is no extra horizontal space).
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleText* styleText = GetStyleText();
|
2002-12-11 02:38:33 +00:00
|
|
|
PRBool allowJustify = NS_STYLE_TEXT_ALIGN_JUSTIFY == styleText->mTextAlign &&
|
|
|
|
!aLineLayout.GetLineEndsInBR() &&
|
|
|
|
ShouldJustifyLine(aState, aLine);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
aLineLayout.HorizontalAlignFrames(aLine->mBounds, allowJustify);
|
2002-12-11 02:38:33 +00:00
|
|
|
// XXX: not only bidi: right alignment can be broken after
|
|
|
|
// RelativePositionFrames!!!
|
2001-07-04 02:00:05 +00:00
|
|
|
// XXXldb Is something here considering relatively positioned frames at
|
|
|
|
// other than their original positions?
|
2001-03-09 03:29:00 +00:00
|
|
|
#ifdef IBMBIDI
|
2001-07-04 02:00:05 +00:00
|
|
|
// XXXldb Why don't we do this earlier?
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
if (aState.mPresContext->BidiEnabled()) {
|
2009-05-11 10:36:01 +00:00
|
|
|
if (!aState.mPresContext->IsVisualMode() ||
|
|
|
|
GetStyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL) {
|
2011-04-27 08:47:18 +00:00
|
|
|
nsBidiPresUtils* bidiUtils = aState.mPresContext->GetBidiUtils();
|
|
|
|
|
|
|
|
if (bidiUtils && bidiUtils->IsSuccessful() ) {
|
|
|
|
bidiUtils->ReorderFrames(aLine->mFirstChild, aLine->GetChildCount());
|
|
|
|
} // bidiUtils
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
} // not visual mode
|
|
|
|
} // bidi enabled
|
2001-03-09 03:29:00 +00:00
|
|
|
#endif // IBMBIDI
|
2000-04-17 14:40:46 +00:00
|
|
|
|
2007-12-12 01:43:09 +00:00
|
|
|
// From here on, pfd->mBounds rectangles are incorrect because bidi
|
|
|
|
// might have moved frames around!
|
2010-10-07 04:25:45 +00:00
|
|
|
nsOverflowAreas overflowAreas;
|
|
|
|
aLineLayout.RelativePositionFrames(overflowAreas);
|
|
|
|
aLine->SetOverflowAreas(overflowAreas);
|
1999-03-20 01:37:43 +00:00
|
|
|
if (addedBullet) {
|
1999-08-27 21:45:37 +00:00
|
|
|
aLineLayout.RemoveBulletFrame(mBullet);
|
1999-03-20 01:37:43 +00:00
|
|
|
}
|
1998-10-02 21:50:53 +00:00
|
|
|
|
1999-03-27 01:22:14 +00:00
|
|
|
// Inline lines do not have margins themselves; however they are
|
|
|
|
// impacted by prior block margins. If this line ends up having some
|
|
|
|
// height then we zero out the previous bottom margin value that was
|
|
|
|
// already applied to the line's starting Y coordinate. Otherwise we
|
|
|
|
// leave it be so that the previous blocks bottom margin can be
|
|
|
|
// collapsed with a block that follows.
|
|
|
|
nscoord newY;
|
2002-11-28 19:29:28 +00:00
|
|
|
|
2004-11-24 13:22:10 +00:00
|
|
|
if (!aLine->CachedIsEmpty()) {
|
1999-03-27 01:22:14 +00:00
|
|
|
// This line has some height. Therefore the application of the
|
|
|
|
// previous-bottom-margin should stick.
|
2001-10-25 01:08:40 +00:00
|
|
|
aState.mPrevBottomMargin.Zero();
|
1999-04-03 18:59:01 +00:00
|
|
|
newY = aLine->mBounds.YMost();
|
1999-03-27 01:22:14 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Don't let the previous-bottom-margin value affect the newY
|
|
|
|
// coordinate (it was applied in ReflowInlineFrames speculatively)
|
|
|
|
// since the line is empty.
|
2002-11-28 19:29:28 +00:00
|
|
|
// We already called |ShouldApplyTopMargin|, and if we applied it
|
|
|
|
// then BRS_APPLYTOPMARGIN is set.
|
|
|
|
nscoord dy = aState.GetFlag(BRS_APPLYTOPMARGIN)
|
|
|
|
? -aState.mPrevBottomMargin.get() : 0;
|
1999-04-01 01:37:36 +00:00
|
|
|
newY = aState.mY + dy;
|
1999-03-27 01:22:14 +00:00
|
|
|
}
|
1998-12-05 16:02:08 +00:00
|
|
|
|
2010-12-02 18:57:26 +00:00
|
|
|
// See if the line fit. If it doesn't we need to push it. Our first
|
|
|
|
// line will always fit.
|
|
|
|
if (mLines.front() != aLine &&
|
2004-10-22 17:32:54 +00:00
|
|
|
newY > aState.mBottomEdge &&
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
aState.mBottomEdge != NS_UNCONSTRAINEDSIZE) {
|
2005-11-20 22:05:24 +00:00
|
|
|
// Push this line and all of its children and anything else that
|
1998-12-05 16:02:08 +00:00
|
|
|
// follows to our next-in-flow
|
2001-10-25 01:08:40 +00:00
|
|
|
NS_ASSERTION((aState.mCurrentLine == aLine), "oops");
|
|
|
|
PushLines(aState, aLine.prev());
|
1998-12-05 16:02:08 +00:00
|
|
|
|
|
|
|
// Stop reflow and whack the reflow status if reflow hasn't
|
|
|
|
// already been stopped.
|
1999-02-12 17:45:58 +00:00
|
|
|
if (*aKeepReflowGoing) {
|
2007-07-26 04:03:29 +00:00
|
|
|
NS_FRAME_SET_INCOMPLETE(aState.mReflowStatus);
|
1999-02-12 17:45:58 +00:00
|
|
|
*aKeepReflowGoing = PR_FALSE;
|
1998-10-06 00:38:56 +00:00
|
|
|
}
|
2009-05-20 11:21:34 +00:00
|
|
|
return PR_TRUE;
|
1998-12-05 16:02:08 +00:00
|
|
|
}
|
1998-10-02 21:50:53 +00:00
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
aState.mY = newY;
|
2000-01-08 03:58:27 +00:00
|
|
|
|
2003-10-13 21:51:02 +00:00
|
|
|
// Add the already placed current-line floats to the line
|
|
|
|
aLine->AppendFloats(aState.mCurrentLineFloats);
|
1999-09-15 00:28:10 +00:00
|
|
|
|
2003-10-13 21:51:02 +00:00
|
|
|
// Any below current line floats to place?
|
|
|
|
if (aState.mBelowCurrentLineFloats.NotEmpty()) {
|
2010-08-06 04:59:20 +00:00
|
|
|
// Reflow the below-current-line floats, which places on the line's
|
|
|
|
// float list.
|
2010-08-06 04:59:20 +00:00
|
|
|
aState.PlaceBelowCurrentLineFloats(aState.mBelowCurrentLineFloats, aLine);
|
2010-08-06 04:59:20 +00:00
|
|
|
aLine->AppendFloats(aState.mBelowCurrentLineFloats);
|
1998-06-30 23:51:26 +00:00
|
|
|
}
|
|
|
|
|
2003-10-13 21:51:02 +00:00
|
|
|
// When a line has floats, factor them into the combined-area
|
1999-03-23 04:28:20 +00:00
|
|
|
// computations.
|
2003-10-13 21:51:02 +00:00
|
|
|
if (aLine->HasFloats()) {
|
|
|
|
// Combine the float combined area (stored in aState) and the
|
1999-03-23 04:28:20 +00:00
|
|
|
// value computed by the line layout code.
|
2010-10-07 04:25:45 +00:00
|
|
|
nsOverflowAreas lineOverflowAreas;
|
|
|
|
NS_FOR_FRAME_OVERFLOW_TYPES(otype) {
|
|
|
|
nsRect &o = lineOverflowAreas.Overflow(otype);
|
|
|
|
o = aLine->GetOverflowArea(otype);
|
1999-10-14 23:10:03 +00:00
|
|
|
#ifdef NOISY_COMBINED_AREA
|
2010-10-07 04:25:45 +00:00
|
|
|
ListTag(stdout);
|
|
|
|
printf(": overflow %d lineCA=%d,%d,%d,%d floatCA=%d,%d,%d,%d\n",
|
|
|
|
otype,
|
|
|
|
o.x, o.y, o.width, o.height,
|
|
|
|
aState.mFloatOverflowAreas.Overflow(otype).x,
|
|
|
|
aState.mFloatOverflowAreas.Overflow(otype).y,
|
|
|
|
aState.mFloatOverflowAreas.Overflow(otype).width,
|
|
|
|
aState.mFloatOverflowAreas.Overflow(otype).height);
|
1999-10-14 23:10:03 +00:00
|
|
|
#endif
|
2010-10-07 04:25:45 +00:00
|
|
|
o.UnionRect(aState.mFloatOverflowAreas.Overflow(otype), o);
|
1999-10-14 23:10:03 +00:00
|
|
|
|
|
|
|
#ifdef NOISY_COMBINED_AREA
|
2010-10-07 04:25:45 +00:00
|
|
|
printf(" ==> final lineCA=%d,%d,%d,%d\n",
|
|
|
|
o.x, o.y, o.width, o.height);
|
1999-10-14 23:10:03 +00:00
|
|
|
#endif
|
2010-10-07 04:25:45 +00:00
|
|
|
}
|
|
|
|
aLine->SetOverflowAreas(lineOverflowAreas);
|
1999-03-23 04:28:20 +00:00
|
|
|
}
|
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
// Apply break-after clearing if necessary
|
2003-03-25 15:24:07 +00:00
|
|
|
// This must stay in sync with |ReflowDirtyLines|.
|
2004-11-25 14:51:00 +00:00
|
|
|
if (aLine->HasFloatBreakAfter()) {
|
|
|
|
aState.mY = aState.ClearFloats(aState.mY, aLine->GetBreakTypeAfter());
|
1998-11-11 03:55:55 +00:00
|
|
|
}
|
2009-05-20 11:21:34 +00:00
|
|
|
return PR_TRUE;
|
1998-12-05 16:02:08 +00:00
|
|
|
}
|
1998-11-05 19:33:01 +00:00
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
void
|
2002-07-17 01:48:56 +00:00
|
|
|
nsBlockFrame::PushLines(nsBlockReflowState& aState,
|
2001-10-25 01:08:40 +00:00
|
|
|
nsLineList::iterator aLineBefore)
|
1998-07-06 21:37:08 +00:00
|
|
|
{
|
2001-10-25 01:08:40 +00:00
|
|
|
nsLineList::iterator overBegin(aLineBefore.next());
|
2004-02-03 18:19:42 +00:00
|
|
|
|
|
|
|
// PushTruncatedPlaceholderLine sometimes pushes the first line. Ugh.
|
|
|
|
PRBool firstLine = overBegin == begin_lines();
|
2001-10-25 01:08:40 +00:00
|
|
|
|
|
|
|
if (overBegin != end_lines()) {
|
2006-04-09 22:56:27 +00:00
|
|
|
// Remove floats in the lines from mFloats
|
|
|
|
nsFrameList floats;
|
2009-09-18 11:09:36 +00:00
|
|
|
CollectFloats(overBegin->mFirstChild, floats, PR_FALSE, PR_TRUE);
|
2006-04-09 22:56:27 +00:00
|
|
|
|
|
|
|
if (floats.NotEmpty()) {
|
|
|
|
// Push the floats onto the front of the overflow out-of-flows list
|
2009-09-18 11:09:36 +00:00
|
|
|
nsAutoOOFFrameList oofs(this);
|
|
|
|
oofs.mList.InsertFrames(nsnull, nsnull, floats);
|
2006-04-09 22:56:27 +00:00
|
|
|
}
|
|
|
|
|
2005-03-23 03:35:08 +00:00
|
|
|
// overflow lines can already exist in some cases, in particular,
|
|
|
|
// when shrinkwrapping and we discover that the shrinkwap causes
|
|
|
|
// the height of some child block to grow which creates additional
|
|
|
|
// overflowing content. In such cases we must prepend the new
|
|
|
|
// overflow to the existing overflow.
|
|
|
|
nsLineList* overflowLines = RemoveOverflowLines();
|
|
|
|
if (!overflowLines) {
|
|
|
|
// XXXldb use presshell arena!
|
|
|
|
overflowLines = new nsLineList();
|
|
|
|
}
|
|
|
|
if (overflowLines) {
|
2009-09-29 19:47:05 +00:00
|
|
|
// First, remove the frames we're pushing from mFrames
|
|
|
|
nsIFrame* oldLastChild = mFrames.LastChild();
|
|
|
|
if (firstLine) {
|
|
|
|
mFrames.Clear();
|
|
|
|
} else {
|
|
|
|
mFrames.RemoveFramesAfter(aLineBefore->LastChild());
|
|
|
|
}
|
2005-03-23 03:35:08 +00:00
|
|
|
if (!overflowLines->empty()) {
|
2009-09-29 19:47:05 +00:00
|
|
|
// XXXbz If we switch overflow lines to nsFrameList, we should
|
|
|
|
// change this SetNextSibling call.
|
|
|
|
oldLastChild->SetNextSibling(overflowLines->front()->mFirstChild);
|
2005-03-23 03:35:08 +00:00
|
|
|
}
|
|
|
|
overflowLines->splice(overflowLines->begin(), mLines, overBegin,
|
|
|
|
end_lines());
|
|
|
|
NS_ASSERTION(!overflowLines->empty(), "should not be empty");
|
2001-10-25 01:08:40 +00:00
|
|
|
// this takes ownership but it won't delete it immediately so we
|
|
|
|
// can keep using it.
|
2005-03-23 03:35:08 +00:00
|
|
|
SetOverflowLines(overflowLines);
|
1999-12-07 23:41:48 +00:00
|
|
|
|
2005-03-23 03:35:08 +00:00
|
|
|
// Mark all the overflow lines dirty so that they get reflowed when
|
|
|
|
// they are pulled up by our next-in-flow.
|
|
|
|
|
|
|
|
// XXXldb Can this get called O(N) times making the whole thing O(N^2)?
|
|
|
|
for (line_iterator line = overflowLines->begin(),
|
|
|
|
line_end = overflowLines->end();
|
|
|
|
line != line_end;
|
|
|
|
++line)
|
|
|
|
{
|
|
|
|
line->MarkDirty();
|
|
|
|
line->MarkPreviousMarginDirty();
|
|
|
|
line->mBounds.SetRect(0, 0, 0, 0);
|
|
|
|
if (line->HasFloats()) {
|
|
|
|
line->FreeFloats(aState.mFloatCacheFreeList);
|
|
|
|
}
|
|
|
|
}
|
1999-12-07 23:41:48 +00:00
|
|
|
}
|
1998-09-25 05:13:06 +00:00
|
|
|
}
|
|
|
|
|
1999-03-16 19:36:00 +00:00
|
|
|
#ifdef DEBUG
|
2004-06-01 06:20:16 +00:00
|
|
|
VerifyOverflowSituation();
|
1998-09-25 05:13:06 +00:00
|
|
|
#endif
|
1998-12-05 16:02:08 +00:00
|
|
|
}
|
1998-09-25 05:13:06 +00:00
|
|
|
|
2001-10-25 01:08:40 +00:00
|
|
|
// The overflowLines property is stored as a pointer to a line list,
|
|
|
|
// which must be deleted. However, the following functions all maintain
|
|
|
|
// the invariant that the property is never set if the list is empty.
|
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
PRBool
|
2005-03-23 03:35:08 +00:00
|
|
|
nsBlockFrame::DrainOverflowLines(nsBlockReflowState& aState)
|
1998-12-05 16:02:08 +00:00
|
|
|
{
|
1999-03-16 19:36:00 +00:00
|
|
|
#ifdef DEBUG
|
2004-06-01 06:20:16 +00:00
|
|
|
VerifyOverflowSituation();
|
1999-03-16 19:36:00 +00:00
|
|
|
#endif
|
2005-03-23 03:35:08 +00:00
|
|
|
nsLineList* overflowLines = nsnull;
|
|
|
|
nsLineList* ourOverflowLines = nsnull;
|
1998-11-17 01:04:45 +00:00
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
// First grab the prev-in-flows overflow lines
|
2006-02-21 21:33:47 +00:00
|
|
|
nsBlockFrame* prevBlock = (nsBlockFrame*) GetPrevInFlow();
|
2005-03-23 03:35:08 +00:00
|
|
|
if (prevBlock) {
|
2004-06-01 06:20:16 +00:00
|
|
|
overflowLines = prevBlock->RemoveOverflowLines();
|
2005-03-23 03:35:08 +00:00
|
|
|
if (overflowLines) {
|
2001-10-25 01:08:40 +00:00
|
|
|
NS_ASSERTION(! overflowLines->empty(),
|
|
|
|
"overflow lines should never be set and empty");
|
1999-11-02 23:42:52 +00:00
|
|
|
// Make all the frames on the overflow line list mine
|
2001-10-25 01:08:40 +00:00
|
|
|
nsIFrame* frame = overflowLines->front()->mFirstChild;
|
1998-12-05 16:02:08 +00:00
|
|
|
while (nsnull != frame) {
|
2004-10-08 12:17:10 +00:00
|
|
|
ReparentFrame(frame, prevBlock, this);
|
1999-04-11 04:22:00 +00:00
|
|
|
|
|
|
|
// Get the next frame
|
2003-06-26 11:30:17 +00:00
|
|
|
frame = frame->GetNextSibling();
|
1998-09-25 05:13:06 +00:00
|
|
|
}
|
|
|
|
|
2005-03-23 03:35:08 +00:00
|
|
|
// make the overflow out-of-flow frames mine too
|
|
|
|
nsAutoOOFFrameList oofs(prevBlock);
|
|
|
|
if (oofs.mList.NotEmpty()) {
|
|
|
|
for (nsIFrame* f = oofs.mList.FirstChild(); f; f = f->GetNextSibling()) {
|
|
|
|
ReparentFrame(f, prevBlock, this);
|
|
|
|
}
|
2009-07-30 17:23:32 +00:00
|
|
|
mFloats.InsertFrames(nsnull, nsnull, oofs.mList);
|
1998-12-05 16:02:08 +00:00
|
|
|
}
|
2005-03-23 03:35:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// The lines on the overflow list have already been marked dirty and their
|
|
|
|
// previous margins marked dirty also.
|
|
|
|
}
|
2004-05-05 02:30:33 +00:00
|
|
|
|
2005-03-23 03:35:08 +00:00
|
|
|
// Don't need to reparent frames in our own overflow lines/oofs, because they're
|
|
|
|
// already ours. But we should put overflow floats back in mFloats.
|
|
|
|
ourOverflowLines = RemoveOverflowLines();
|
|
|
|
if (ourOverflowLines) {
|
|
|
|
nsAutoOOFFrameList oofs(this);
|
|
|
|
if (oofs.mList.NotEmpty()) {
|
2006-04-09 22:56:27 +00:00
|
|
|
// The overflow floats go after our regular floats
|
2009-09-18 11:09:36 +00:00
|
|
|
mFloats.AppendFrames(nsnull, oofs.mList);
|
2005-03-23 03:35:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!overflowLines && !ourOverflowLines) {
|
|
|
|
// nothing to do; always the case for non-constrained-height reflows
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now join the line lists into mLines
|
1999-11-02 23:42:52 +00:00
|
|
|
if (overflowLines) {
|
2005-03-23 03:35:08 +00:00
|
|
|
if (!overflowLines->empty()) {
|
|
|
|
// Join the line lists
|
2009-09-29 19:47:05 +00:00
|
|
|
if (!mLines.empty()) {
|
2005-03-23 03:35:08 +00:00
|
|
|
// Remember to recompute the margins on the first line. This will
|
|
|
|
// also recompute the correct deltaY if necessary.
|
|
|
|
mLines.front()->MarkPreviousMarginDirty();
|
2009-09-29 19:47:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Join the sibling lists together
|
|
|
|
nsIFrame* firstFrame = overflowLines->front()->mFirstChild;
|
|
|
|
nsIFrame* lastFrame = overflowLines->back()->LastChild();
|
|
|
|
nsFrameList framesToInsert(firstFrame, lastFrame);
|
|
|
|
mFrames.InsertFrames(nsnull, nsnull, framesToInsert);
|
|
|
|
|
2005-03-23 03:35:08 +00:00
|
|
|
// Place overflow lines at the front of our line list
|
|
|
|
mLines.splice(mLines.begin(), *overflowLines);
|
|
|
|
NS_ASSERTION(overflowLines->empty(), "splice should empty list");
|
1998-12-05 16:02:08 +00:00
|
|
|
}
|
2001-10-25 01:08:40 +00:00
|
|
|
delete overflowLines;
|
2005-03-23 03:35:08 +00:00
|
|
|
}
|
|
|
|
if (ourOverflowLines) {
|
|
|
|
if (!ourOverflowLines->empty()) {
|
2009-09-29 19:47:05 +00:00
|
|
|
nsIFrame* firstFrame = ourOverflowLines->front()->mFirstChild;
|
|
|
|
nsIFrame* lastFrame = ourOverflowLines->back()->LastChild();
|
|
|
|
nsFrameList framesToAppend(firstFrame, lastFrame);
|
|
|
|
mFrames.AppendFrames(nsnull, framesToAppend);
|
|
|
|
|
2005-03-23 03:35:08 +00:00
|
|
|
// append the overflow to mLines
|
|
|
|
mLines.splice(mLines.end(), *ourOverflowLines);
|
|
|
|
}
|
|
|
|
delete ourOverflowLines;
|
|
|
|
}
|
2004-05-05 02:30:33 +00:00
|
|
|
|
2005-03-23 03:35:08 +00:00
|
|
|
return PR_TRUE;
|
1998-09-25 16:10:10 +00:00
|
|
|
}
|
|
|
|
|
2009-08-31 18:25:36 +00:00
|
|
|
// This function assumes our prev-in-flow has completed reflow and its
|
2010-08-06 04:59:19 +00:00
|
|
|
// mFloats may contain frames at the end of its float list, marked with
|
2010-08-06 04:59:20 +00:00
|
|
|
// NS_FRAME_IS_PUSHED_FLOAT, that should be pulled to this block.
|
2009-08-31 18:25:36 +00:00
|
|
|
void
|
2010-08-06 04:59:20 +00:00
|
|
|
nsBlockFrame::DrainPushedFloats(nsBlockReflowState& aState)
|
2009-08-31 18:25:36 +00:00
|
|
|
{
|
2011-01-12 01:09:21 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
// Between when we drain pushed floats and when we complete reflow,
|
|
|
|
// we're allowed to have multiple continuations of the same float on
|
|
|
|
// our floats list, since a first-in-flow might get pushed to a later
|
|
|
|
// continuation of its containing block. But it's not permitted
|
|
|
|
// outside that time.
|
|
|
|
nsLayoutUtils::AssertNoDuplicateContinuations(this, mFloats);
|
|
|
|
#endif
|
|
|
|
|
2010-08-06 04:59:19 +00:00
|
|
|
// Take any continuations we need to take from our prev-in-flow.
|
2009-08-31 18:25:36 +00:00
|
|
|
nsBlockFrame* prevBlock = static_cast<nsBlockFrame*>(GetPrevInFlow());
|
|
|
|
if (!prevBlock)
|
|
|
|
return;
|
2010-08-06 04:59:20 +00:00
|
|
|
nsFrameList *list = prevBlock->RemovePushedFloats();
|
2010-08-06 04:59:19 +00:00
|
|
|
if (list) {
|
|
|
|
if (list->NotEmpty()) {
|
2010-08-06 04:59:19 +00:00
|
|
|
mFloats.InsertFrames(this, nsnull, *list);
|
2010-08-06 04:59:19 +00:00
|
|
|
}
|
|
|
|
delete list;
|
2010-08-06 04:59:19 +00:00
|
|
|
}
|
2009-08-31 18:25:36 +00:00
|
|
|
}
|
|
|
|
|
2001-10-25 01:08:40 +00:00
|
|
|
nsLineList*
|
2004-06-01 06:20:16 +00:00
|
|
|
nsBlockFrame::GetOverflowLines() const
|
1999-11-02 23:42:52 +00:00
|
|
|
{
|
2004-08-26 03:07:05 +00:00
|
|
|
if (!(GetStateBits() & NS_BLOCK_HAS_OVERFLOW_LINES)) {
|
|
|
|
return nsnull;
|
|
|
|
}
|
2007-07-08 07:08:04 +00:00
|
|
|
nsLineList* lines = static_cast<nsLineList*>
|
2010-03-29 01:46:55 +00:00
|
|
|
(Properties().Get(OverflowLinesProperty()));
|
2004-08-26 03:07:05 +00:00
|
|
|
NS_ASSERTION(lines && !lines->empty(),
|
|
|
|
"value should always be stored and non-empty when state set");
|
2004-06-01 06:20:16 +00:00
|
|
|
return lines;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsLineList*
|
2004-08-26 03:07:05 +00:00
|
|
|
nsBlockFrame::RemoveOverflowLines()
|
2004-06-01 06:20:16 +00:00
|
|
|
{
|
2004-08-26 03:07:05 +00:00
|
|
|
if (!(GetStateBits() & NS_BLOCK_HAS_OVERFLOW_LINES)) {
|
|
|
|
return nsnull;
|
|
|
|
}
|
2007-07-08 07:08:04 +00:00
|
|
|
nsLineList* lines = static_cast<nsLineList*>
|
2010-03-29 01:46:55 +00:00
|
|
|
(Properties().Remove(OverflowLinesProperty()));
|
2004-08-26 03:07:05 +00:00
|
|
|
NS_ASSERTION(lines && !lines->empty(),
|
|
|
|
"value should always be stored and non-empty when state set");
|
|
|
|
RemoveStateBits(NS_BLOCK_HAS_OVERFLOW_LINES);
|
2002-12-04 00:58:52 +00:00
|
|
|
return lines;
|
1999-11-02 23:42:52 +00:00
|
|
|
}
|
|
|
|
|
2001-10-25 01:08:40 +00:00
|
|
|
// This takes ownership of aOverflowLines.
|
|
|
|
// XXX We should allocate overflowLines from presShell arena!
|
1999-11-02 23:42:52 +00:00
|
|
|
nsresult
|
2004-06-01 06:20:16 +00:00
|
|
|
nsBlockFrame::SetOverflowLines(nsLineList* aOverflowLines)
|
1999-11-02 23:42:52 +00:00
|
|
|
{
|
2001-10-25 01:08:40 +00:00
|
|
|
NS_ASSERTION(aOverflowLines, "null lines");
|
2002-12-04 00:58:52 +00:00
|
|
|
NS_ASSERTION(!aOverflowLines->empty(), "empty lines");
|
2004-08-26 03:07:05 +00:00
|
|
|
NS_ASSERTION(!(GetStateBits() & NS_BLOCK_HAS_OVERFLOW_LINES),
|
|
|
|
"Overwriting existing overflow lines");
|
2001-10-25 01:08:40 +00:00
|
|
|
|
2010-03-29 01:46:55 +00:00
|
|
|
FrameProperties props = Properties();
|
|
|
|
// Verify that we won't overwrite an existing overflow list
|
|
|
|
NS_ASSERTION(!props.Get(OverflowLinesProperty()), "existing overflow list");
|
|
|
|
props.Set(OverflowLinesProperty(), aOverflowLines);
|
2004-08-26 03:07:05 +00:00
|
|
|
AddStateBits(NS_BLOCK_HAS_OVERFLOW_LINES);
|
2010-03-29 01:46:55 +00:00
|
|
|
return NS_OK;
|
2002-12-04 00:58:52 +00:00
|
|
|
}
|
1999-11-02 23:42:52 +00:00
|
|
|
|
2009-09-24 02:39:21 +00:00
|
|
|
nsFrameList*
|
2004-06-01 06:20:16 +00:00
|
|
|
nsBlockFrame::GetOverflowOutOfFlows() const
|
|
|
|
{
|
2004-08-26 03:07:05 +00:00
|
|
|
if (!(GetStateBits() & NS_BLOCK_HAS_OVERFLOW_OUT_OF_FLOWS)) {
|
2009-09-24 02:39:21 +00:00
|
|
|
return nsnull;
|
2004-08-26 03:07:05 +00:00
|
|
|
}
|
2009-09-24 02:39:21 +00:00
|
|
|
nsFrameList* result =
|
2010-03-29 01:46:55 +00:00
|
|
|
GetPropTableFrames(PresContext(), OverflowOutOfFlowsProperty());
|
2004-08-26 03:07:05 +00:00
|
|
|
NS_ASSERTION(result, "value should always be non-empty when state set");
|
2009-09-24 02:39:21 +00:00
|
|
|
return result;
|
2004-06-01 06:20:16 +00:00
|
|
|
}
|
|
|
|
|
2005-03-23 03:35:08 +00:00
|
|
|
// This takes ownership of the frames
|
|
|
|
void
|
2009-09-24 02:39:21 +00:00
|
|
|
nsBlockFrame::SetOverflowOutOfFlows(const nsFrameList& aList,
|
|
|
|
nsFrameList* aPropValue)
|
2004-05-05 02:30:33 +00:00
|
|
|
{
|
2009-09-24 02:39:21 +00:00
|
|
|
NS_PRECONDITION(!!(GetStateBits() & NS_BLOCK_HAS_OVERFLOW_OUT_OF_FLOWS) ==
|
|
|
|
!!aPropValue, "state does not match value");
|
|
|
|
|
2005-03-23 03:35:08 +00:00
|
|
|
if (aList.IsEmpty()) {
|
|
|
|
if (!(GetStateBits() & NS_BLOCK_HAS_OVERFLOW_OUT_OF_FLOWS)) {
|
|
|
|
return;
|
|
|
|
}
|
2009-09-24 02:39:21 +00:00
|
|
|
nsFrameList* list =
|
|
|
|
RemovePropTableFrames(PresContext(),
|
2010-03-29 01:46:55 +00:00
|
|
|
OverflowOutOfFlowsProperty());
|
2009-09-24 02:39:21 +00:00
|
|
|
NS_ASSERTION(aPropValue == list, "prop value mismatch");
|
|
|
|
delete list;
|
2005-03-23 03:35:08 +00:00
|
|
|
RemoveStateBits(NS_BLOCK_HAS_OVERFLOW_OUT_OF_FLOWS);
|
2009-09-24 02:39:21 +00:00
|
|
|
}
|
|
|
|
else if (GetStateBits() & NS_BLOCK_HAS_OVERFLOW_OUT_OF_FLOWS) {
|
|
|
|
NS_ASSERTION(aPropValue == GetPropTableFrames(PresContext(),
|
2010-03-29 01:46:55 +00:00
|
|
|
OverflowOutOfFlowsProperty()),
|
2009-09-24 02:39:21 +00:00
|
|
|
"prop value mismatch");
|
|
|
|
*aPropValue = aList;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
SetPropTableFrames(PresContext(), new nsFrameList(aList),
|
2010-03-29 01:46:55 +00:00
|
|
|
OverflowOutOfFlowsProperty());
|
2005-03-23 03:35:08 +00:00
|
|
|
AddStateBits(NS_BLOCK_HAS_OVERFLOW_OUT_OF_FLOWS);
|
2004-08-26 03:07:05 +00:00
|
|
|
}
|
2004-05-05 02:30:33 +00:00
|
|
|
}
|
|
|
|
|
2010-08-06 04:59:19 +00:00
|
|
|
nsFrameList*
|
2010-08-06 04:59:20 +00:00
|
|
|
nsBlockFrame::GetPushedFloats() const
|
2010-08-06 04:59:19 +00:00
|
|
|
{
|
2010-08-06 04:59:20 +00:00
|
|
|
if (!(GetStateBits() & NS_BLOCK_HAS_PUSHED_FLOATS)) {
|
2010-08-06 04:59:19 +00:00
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
nsFrameList* result =
|
2010-08-06 04:59:20 +00:00
|
|
|
static_cast<nsFrameList*>(Properties().Get(PushedFloatProperty()));
|
2010-08-06 04:59:19 +00:00
|
|
|
NS_ASSERTION(result, "value should always be non-empty when state set");
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsFrameList*
|
2010-08-06 04:59:20 +00:00
|
|
|
nsBlockFrame::EnsurePushedFloats()
|
2010-08-06 04:59:19 +00:00
|
|
|
{
|
2010-08-06 04:59:20 +00:00
|
|
|
nsFrameList *result = GetPushedFloats();
|
2010-08-06 04:59:19 +00:00
|
|
|
if (result)
|
|
|
|
return result;
|
|
|
|
|
|
|
|
result = new nsFrameList;
|
2010-08-06 04:59:20 +00:00
|
|
|
Properties().Set(PushedFloatProperty(), result);
|
|
|
|
AddStateBits(NS_BLOCK_HAS_PUSHED_FLOATS);
|
2010-08-06 04:59:19 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsFrameList*
|
2010-08-06 04:59:20 +00:00
|
|
|
nsBlockFrame::RemovePushedFloats()
|
2010-08-06 04:59:19 +00:00
|
|
|
{
|
2010-08-06 04:59:20 +00:00
|
|
|
if (!(GetStateBits() & NS_BLOCK_HAS_PUSHED_FLOATS)) {
|
2010-08-06 04:59:19 +00:00
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsFrameList *result =
|
2010-08-06 04:59:20 +00:00
|
|
|
static_cast<nsFrameList*>(Properties().Remove(PushedFloatProperty()));
|
|
|
|
RemoveStateBits(NS_BLOCK_HAS_PUSHED_FLOATS);
|
2010-08-06 04:59:19 +00:00
|
|
|
NS_ASSERTION(result, "value should always be non-empty when state set");
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-12-17 18:52:10 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// Frame list manipulation routines
|
|
|
|
|
1999-02-02 17:31:09 +00:00
|
|
|
NS_IMETHODIMP
|
2006-04-09 22:56:27 +00:00
|
|
|
nsBlockFrame::AppendFrames(nsIAtom* aListName,
|
2009-07-30 17:23:32 +00:00
|
|
|
nsFrameList& aFrameList)
|
1999-02-02 17:31:09 +00:00
|
|
|
{
|
2009-07-30 17:23:32 +00:00
|
|
|
if (aFrameList.IsEmpty()) {
|
1999-04-21 19:58:38 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2006-06-29 02:32:36 +00:00
|
|
|
if (aListName) {
|
2011-04-29 23:02:33 +00:00
|
|
|
if (nsGkAtoms::floatList == aListName) {
|
2006-06-29 02:32:36 +00:00
|
|
|
mFloats.AppendFrames(nsnull, aFrameList);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
NS_ERROR("unexpected child list");
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
1999-02-26 17:04:44 +00:00
|
|
|
}
|
|
|
|
|
1999-04-20 00:27:43 +00:00
|
|
|
// Find the proper last-child for where the append should go
|
2009-09-18 11:09:36 +00:00
|
|
|
nsIFrame* lastKid = mLines.empty() ? nsnull : mLines.back()->LastChild();
|
1999-04-20 00:27:43 +00:00
|
|
|
|
|
|
|
// Add frames after the last child
|
1999-04-21 19:58:38 +00:00
|
|
|
#ifdef NOISY_REFLOW_REASON
|
|
|
|
ListTag(stdout);
|
2000-10-28 22:17:53 +00:00
|
|
|
printf(": append ");
|
1999-04-21 19:58:38 +00:00
|
|
|
nsFrame::ListTag(stdout, aFrameList);
|
|
|
|
if (lastKid) {
|
2000-10-28 22:17:53 +00:00
|
|
|
printf(" after ");
|
1999-04-21 19:58:38 +00:00
|
|
|
nsFrame::ListTag(stdout, lastKid);
|
|
|
|
}
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("\n");
|
1999-04-21 19:58:38 +00:00
|
|
|
#endif
|
2005-02-07 01:58:25 +00:00
|
|
|
nsresult rv = AddFrames(aFrameList, lastKid);
|
2009-07-30 17:23:32 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
1999-02-02 17:31:09 +00:00
|
|
|
}
|
2009-07-30 17:23:32 +00:00
|
|
|
aFrameList.Clear();
|
|
|
|
|
|
|
|
PresContext()->PresShell()->
|
|
|
|
FrameNeedsReflow(this, nsIPresShell::eTreeChange,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN); // XXX sufficient?
|
|
|
|
return NS_OK;
|
1999-02-02 17:31:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2006-04-09 22:56:27 +00:00
|
|
|
nsBlockFrame::InsertFrames(nsIAtom* aListName,
|
|
|
|
nsIFrame* aPrevFrame,
|
2009-07-30 17:23:32 +00:00
|
|
|
nsFrameList& aFrameList)
|
1999-02-02 17:31:09 +00:00
|
|
|
{
|
2006-06-29 02:32:36 +00:00
|
|
|
NS_ASSERTION(!aPrevFrame || aPrevFrame->GetParent() == this,
|
|
|
|
"inserting after sibling frame with different parent");
|
|
|
|
|
|
|
|
if (aListName) {
|
2011-04-29 23:02:33 +00:00
|
|
|
if (nsGkAtoms::floatList == aListName) {
|
2006-06-29 02:32:36 +00:00
|
|
|
mFloats.InsertFrames(this, aPrevFrame, aFrameList);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2001-03-09 03:29:00 +00:00
|
|
|
#ifdef IBMBIDI
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (nsGkAtoms::nextBidi == aListName) {}
|
2001-03-09 03:29:00 +00:00
|
|
|
#endif // IBMBIDI
|
2006-06-29 02:32:36 +00:00
|
|
|
else {
|
|
|
|
NS_ERROR("unexpected child list");
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
1999-02-03 19:09:24 +00:00
|
|
|
}
|
1999-02-26 17:04:44 +00:00
|
|
|
|
1999-04-21 19:58:38 +00:00
|
|
|
#ifdef NOISY_REFLOW_REASON
|
|
|
|
ListTag(stdout);
|
2000-10-28 22:17:53 +00:00
|
|
|
printf(": insert ");
|
1999-04-21 19:58:38 +00:00
|
|
|
nsFrame::ListTag(stdout, aFrameList);
|
|
|
|
if (aPrevFrame) {
|
2000-10-28 22:17:53 +00:00
|
|
|
printf(" after ");
|
1999-04-21 19:58:38 +00:00
|
|
|
nsFrame::ListTag(stdout, aPrevFrame);
|
|
|
|
}
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("\n");
|
1999-04-21 19:58:38 +00:00
|
|
|
#endif
|
2005-02-07 01:58:25 +00:00
|
|
|
nsresult rv = AddFrames(aFrameList, aPrevFrame);
|
2009-07-30 17:23:32 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
2001-03-09 03:29:00 +00:00
|
|
|
#ifdef IBMBIDI
|
2006-12-26 17:47:52 +00:00
|
|
|
if (aListName != nsGkAtoms::nextBidi)
|
2001-03-09 03:29:00 +00:00
|
|
|
#endif // IBMBIDI
|
2007-03-30 21:11:41 +00:00
|
|
|
PresContext()->PresShell()->
|
2007-05-06 19:16:51 +00:00
|
|
|
FrameNeedsReflow(this, nsIPresShell::eTreeChange,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN); // XXX sufficient?
|
2009-07-30 17:23:32 +00:00
|
|
|
return NS_OK;
|
1999-02-02 17:31:09 +00:00
|
|
|
}
|
|
|
|
|
2006-09-22 01:53:13 +00:00
|
|
|
static PRBool
|
|
|
|
ShouldPutNextSiblingOnNewLine(nsIFrame* aLastFrame)
|
|
|
|
{
|
|
|
|
nsIAtom* type = aLastFrame->GetType();
|
2006-12-26 17:47:52 +00:00
|
|
|
if (type == nsGkAtoms::brFrame)
|
2006-09-22 01:53:13 +00:00
|
|
|
return PR_TRUE;
|
2006-12-26 17:47:52 +00:00
|
|
|
if (type == nsGkAtoms::textFrame)
|
2006-09-22 01:53:13 +00:00
|
|
|
return aLastFrame->HasTerminalNewline() &&
|
2008-08-12 08:31:56 +00:00
|
|
|
aLastFrame->GetStyleText()->NewlineIsSignificant();
|
2006-09-22 01:53:13 +00:00
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
1998-06-18 16:25:41 +00:00
|
|
|
nsresult
|
2009-09-29 19:47:05 +00:00
|
|
|
nsBlockFrame::AddFrames(nsFrameList& aFrameList, nsIFrame* aPrevSibling)
|
1998-06-18 16:25:41 +00:00
|
|
|
{
|
2004-03-14 18:19:24 +00:00
|
|
|
// Clear our line cursor, since our lines may change.
|
|
|
|
ClearLineCursor();
|
|
|
|
|
2009-07-28 12:51:10 +00:00
|
|
|
if (aFrameList.IsEmpty()) {
|
1999-04-20 00:27:43 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2005-08-02 14:38:16 +00:00
|
|
|
// If we're inserting at the beginning of our list and we have an
|
|
|
|
// inside bullet, insert after that bullet.
|
|
|
|
if (!aPrevSibling && mBullet && !HaveOutsideBullet()) {
|
2009-07-28 12:51:10 +00:00
|
|
|
NS_ASSERTION(!aFrameList.ContainsFrame(mBullet),
|
2005-08-31 19:38:59 +00:00
|
|
|
"Trying to make mBullet prev sibling to itself");
|
2005-08-02 14:38:16 +00:00
|
|
|
aPrevSibling = mBullet;
|
|
|
|
}
|
|
|
|
|
2007-03-30 21:11:41 +00:00
|
|
|
nsIPresShell *presShell = PresContext()->PresShell();
|
2000-03-12 03:00:51 +00:00
|
|
|
|
1999-04-20 00:27:43 +00:00
|
|
|
// Attempt to find the line that contains the previous sibling
|
2001-10-25 01:08:40 +00:00
|
|
|
nsLineList::iterator prevSibLine = end_lines();
|
1999-04-20 21:51:39 +00:00
|
|
|
PRInt32 prevSiblingIndex = -1;
|
1999-04-20 00:27:43 +00:00
|
|
|
if (aPrevSibling) {
|
2001-10-25 01:08:40 +00:00
|
|
|
// XXX_perf This is technically O(N^2) in some cases, but by using
|
|
|
|
// RFind instead of Find, we make it O(N) in the most common case,
|
2005-11-20 22:05:24 +00:00
|
|
|
// which is appending content.
|
2001-10-25 01:08:40 +00:00
|
|
|
|
1999-11-01 15:24:57 +00:00
|
|
|
// Find the line that contains the previous sibling
|
2001-10-25 01:08:40 +00:00
|
|
|
if (! nsLineBox::RFindLineContaining(aPrevSibling,
|
|
|
|
begin_lines(), prevSibLine,
|
2009-10-02 16:31:43 +00:00
|
|
|
mFrames.LastChild(),
|
2001-10-25 01:08:40 +00:00
|
|
|
&prevSiblingIndex)) {
|
|
|
|
// Note: defensive code! RFindLineContaining must not return
|
|
|
|
// false in this case, so if it does...
|
|
|
|
NS_NOTREACHED("prev sibling not in line list");
|
1999-11-01 15:24:57 +00:00
|
|
|
aPrevSibling = nsnull;
|
2001-10-25 01:08:40 +00:00
|
|
|
prevSibLine = end_lines();
|
1999-02-01 17:29:37 +00:00
|
|
|
}
|
1999-04-20 00:27:43 +00:00
|
|
|
}
|
|
|
|
|
1999-04-20 21:51:39 +00:00
|
|
|
// Find the frame following aPrevSibling so that we can join up the
|
|
|
|
// two lists of frames.
|
1999-04-20 00:27:43 +00:00
|
|
|
if (aPrevSibling) {
|
1999-04-20 21:51:39 +00:00
|
|
|
// Split line containing aPrevSibling in two if the insertion
|
|
|
|
// point is somewhere in the middle of the line.
|
1999-10-14 23:10:03 +00:00
|
|
|
PRInt32 rem = prevSibLine->GetChildCount() - prevSiblingIndex - 1;
|
1999-04-20 21:51:39 +00:00
|
|
|
if (rem) {
|
|
|
|
// Split the line in two where the frame(s) are being inserted.
|
2009-09-29 19:47:05 +00:00
|
|
|
nsLineBox* line = NS_NewLineBox(presShell, aPrevSibling->GetNextSibling(), rem, PR_FALSE);
|
1999-04-20 21:51:39 +00:00
|
|
|
if (!line) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
2001-10-25 01:08:40 +00:00
|
|
|
mLines.after_insert(prevSibLine, line);
|
1999-10-14 23:10:03 +00:00
|
|
|
prevSibLine->SetChildCount(prevSibLine->GetChildCount() - rem);
|
2007-11-09 06:55:32 +00:00
|
|
|
// Mark prevSibLine dirty and as needing textrun invalidation, since
|
|
|
|
// we may be breaking up text in the line. Its previous line may also
|
|
|
|
// need to be invalidated because it may be able to pull some text up.
|
|
|
|
MarkLineDirty(prevSibLine);
|
|
|
|
// The new line will also need its textruns recomputed because of the
|
|
|
|
// frame changes.
|
2009-05-19 15:54:42 +00:00
|
|
|
line->MarkDirty();
|
2007-11-09 06:55:32 +00:00
|
|
|
line->SetInvalidateTextRuns(PR_TRUE);
|
2007-09-18 03:00:16 +00:00
|
|
|
}
|
1999-04-20 00:27:43 +00:00
|
|
|
}
|
2001-10-25 01:08:40 +00:00
|
|
|
else if (! mLines.empty()) {
|
2009-05-19 15:54:42 +00:00
|
|
|
mLines.front()->MarkDirty();
|
2007-09-18 03:00:16 +00:00
|
|
|
mLines.front()->SetInvalidateTextRuns(PR_TRUE);
|
1999-04-20 00:27:43 +00:00
|
|
|
}
|
2009-09-29 19:47:05 +00:00
|
|
|
const nsFrameList::Slice& newFrames =
|
|
|
|
mFrames.InsertFrames(nsnull, aPrevSibling, aFrameList);
|
1999-04-20 00:27:43 +00:00
|
|
|
|
|
|
|
// Walk through the new frames being added and update the line data
|
|
|
|
// structures to fit.
|
2009-09-29 19:47:05 +00:00
|
|
|
for (nsFrameList::Enumerator e(newFrames); !e.AtEnd(); e.Next()) {
|
|
|
|
nsIFrame* newFrame = e.get();
|
|
|
|
NS_ASSERTION(!aPrevSibling || aPrevSibling->GetNextSibling() == newFrame,
|
|
|
|
"Unexpected aPrevSibling");
|
2007-07-24 01:42:23 +00:00
|
|
|
NS_ASSERTION(newFrame->GetType() != nsGkAtoms::placeholderFrame ||
|
|
|
|
(!newFrame->GetStyleDisplay()->IsAbsolutelyPositioned() &&
|
|
|
|
!newFrame->GetStyleDisplay()->IsFloating()),
|
|
|
|
"Placeholders should not float or be positioned");
|
|
|
|
|
2007-06-27 02:31:35 +00:00
|
|
|
PRBool isBlock = newFrame->GetStyleDisplay()->IsBlockOutside();
|
1999-10-12 23:24:22 +00:00
|
|
|
|
2004-04-13 01:45:57 +00:00
|
|
|
// If the frame is a block frame, or if there is no previous line or if the
|
2006-04-20 19:00:33 +00:00
|
|
|
// previous line is a block line we need to make a new line. We also make
|
2009-08-31 18:25:35 +00:00
|
|
|
// a new line, as an optimization, in the two cases we know we'll need it:
|
|
|
|
// if the previous line ended with a <br>, or if it has significant whitespace
|
|
|
|
// and ended in a newline.
|
2004-04-13 01:45:57 +00:00
|
|
|
if (isBlock || prevSibLine == end_lines() || prevSibLine->IsBlock() ||
|
2006-09-22 01:53:13 +00:00
|
|
|
(aPrevSibling && ShouldPutNextSiblingOnNewLine(aPrevSibling))) {
|
1999-04-20 21:51:39 +00:00
|
|
|
// Create a new line for the frame and add its line to the line
|
|
|
|
// list.
|
2000-03-12 03:00:51 +00:00
|
|
|
nsLineBox* line = NS_NewLineBox(presShell, newFrame, 1, isBlock);
|
1999-04-20 00:27:43 +00:00
|
|
|
if (!line) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
2001-10-25 01:08:40 +00:00
|
|
|
if (prevSibLine != end_lines()) {
|
1999-04-20 03:42:32 +00:00
|
|
|
// Append new line after prevSibLine
|
2001-10-25 01:08:40 +00:00
|
|
|
mLines.after_insert(prevSibLine, line);
|
|
|
|
++prevSibLine;
|
1999-04-20 00:27:43 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// New line is going before the other lines
|
2001-10-25 01:08:40 +00:00
|
|
|
mLines.push_front(line);
|
|
|
|
prevSibLine = begin_lines();
|
1999-04-20 00:27:43 +00:00
|
|
|
}
|
1999-02-01 17:29:37 +00:00
|
|
|
}
|
1999-04-20 00:27:43 +00:00
|
|
|
else {
|
1999-10-14 23:10:03 +00:00
|
|
|
prevSibLine->SetChildCount(prevSibLine->GetChildCount() + 1);
|
2007-11-09 06:55:32 +00:00
|
|
|
// We're adding inline content to prevSibLine, so we need to mark it
|
|
|
|
// dirty, ensure its textruns are recomputed, and possibly do the same
|
|
|
|
// to its previous line since that line may be able to pull content up.
|
|
|
|
MarkLineDirty(prevSibLine);
|
1999-04-20 00:27:43 +00:00
|
|
|
}
|
1999-04-20 21:51:39 +00:00
|
|
|
|
|
|
|
aPrevSibling = newFrame;
|
1999-04-20 00:27:43 +00:00
|
|
|
}
|
|
|
|
|
1999-03-16 19:36:00 +00:00
|
|
|
#ifdef DEBUG
|
1999-04-20 00:27:43 +00:00
|
|
|
VerifyLines(PR_TRUE);
|
1999-03-16 19:36:00 +00:00
|
|
|
#endif
|
1998-12-05 16:02:08 +00:00
|
|
|
return NS_OK;
|
1998-06-18 16:25:41 +00:00
|
|
|
}
|
|
|
|
|
2004-10-08 12:17:10 +00:00
|
|
|
nsBlockFrame::line_iterator
|
|
|
|
nsBlockFrame::RemoveFloat(nsIFrame* aFloat) {
|
2005-03-23 03:35:08 +00:00
|
|
|
// Find which line contains the float, so we can update
|
|
|
|
// the float cache.
|
2004-10-08 12:17:10 +00:00
|
|
|
line_iterator line = begin_lines(), line_end = end_lines();
|
|
|
|
for ( ; line != line_end; ++line) {
|
|
|
|
if (line->IsInline() && line->RemoveFloat(aFloat)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-03-23 03:35:08 +00:00
|
|
|
// Try to destroy if it's in mFloats.
|
2009-09-18 11:09:36 +00:00
|
|
|
if (mFloats.DestroyFrameIfPresent(aFloat)) {
|
2005-03-23 03:35:08 +00:00
|
|
|
return line;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Try our overflow list
|
|
|
|
{
|
|
|
|
nsAutoOOFFrameList oofs(this);
|
2009-09-18 11:09:36 +00:00
|
|
|
if (oofs.mList.DestroyFrameIfPresent(aFloat)) {
|
2005-03-23 03:35:08 +00:00
|
|
|
return line_end;
|
|
|
|
}
|
|
|
|
}
|
2009-08-31 18:25:36 +00:00
|
|
|
|
|
|
|
NS_ERROR("Destroying float without removing from a child list.");
|
2005-03-23 03:35:08 +00:00
|
|
|
return line_end;
|
2004-10-08 12:17:10 +00:00
|
|
|
}
|
|
|
|
|
2009-01-05 00:39:54 +00:00
|
|
|
static void MarkSameFloatManagerLinesDirty(nsBlockFrame* aBlock)
|
2005-07-19 21:58:41 +00:00
|
|
|
{
|
2009-01-05 00:39:54 +00:00
|
|
|
nsBlockFrame* blockWithFloatMgr = aBlock;
|
|
|
|
while (!(blockWithFloatMgr->GetStateBits() & NS_BLOCK_FLOAT_MGR)) {
|
|
|
|
nsBlockFrame* bf = nsLayoutUtils::GetAsBlock(blockWithFloatMgr->GetParent());
|
2008-07-13 22:10:23 +00:00
|
|
|
if (!bf) {
|
2005-07-19 21:58:41 +00:00
|
|
|
break;
|
|
|
|
}
|
2009-01-05 00:39:54 +00:00
|
|
|
blockWithFloatMgr = bf;
|
2005-07-19 21:58:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Mark every line at and below the line where the float was
|
|
|
|
// dirty, and mark their lines dirty too. We could probably do
|
|
|
|
// something more efficient --- e.g., just dirty the lines that intersect
|
|
|
|
// the float vertically.
|
2009-01-05 00:39:54 +00:00
|
|
|
MarkAllDescendantLinesDirty(blockWithFloatMgr);
|
2005-07-19 21:58:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns PR_TRUE if aFrame is a block that has one or more float children.
|
|
|
|
*/
|
|
|
|
static PRBool BlockHasAnyFloats(nsIFrame* aFrame)
|
|
|
|
{
|
2008-07-13 22:10:23 +00:00
|
|
|
nsBlockFrame* block = nsLayoutUtils::GetAsBlock(aFrame);
|
|
|
|
if (!block)
|
2005-07-19 21:58:41 +00:00
|
|
|
return PR_FALSE;
|
2006-12-26 17:47:52 +00:00
|
|
|
if (block->GetFirstChild(nsGkAtoms::floatList))
|
2005-07-19 21:58:41 +00:00
|
|
|
return PR_TRUE;
|
|
|
|
|
|
|
|
nsLineList::iterator line = block->begin_lines();
|
|
|
|
nsLineList::iterator endLine = block->end_lines();
|
|
|
|
while (line != endLine) {
|
|
|
|
if (line->IsBlock() && BlockHasAnyFloats(line->mFirstChild))
|
|
|
|
return PR_TRUE;
|
|
|
|
++line;
|
|
|
|
}
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
1999-02-02 17:31:09 +00:00
|
|
|
NS_IMETHODIMP
|
2006-04-09 22:56:27 +00:00
|
|
|
nsBlockFrame::RemoveFrame(nsIAtom* aListName,
|
|
|
|
nsIFrame* aOldFrame)
|
1999-02-02 17:31:09 +00:00
|
|
|
{
|
1999-02-26 17:04:44 +00:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
1999-09-22 00:58:58 +00:00
|
|
|
#ifdef NOISY_REFLOW_REASON
|
2006-05-25 01:30:34 +00:00
|
|
|
ListTag(stdout);
|
|
|
|
printf(": remove ");
|
|
|
|
nsFrame::ListTag(stdout, aOldFrame);
|
|
|
|
printf("\n");
|
1999-09-22 00:58:58 +00:00
|
|
|
#endif
|
|
|
|
|
2002-01-06 18:17:41 +00:00
|
|
|
if (nsnull == aListName) {
|
2005-07-19 21:58:41 +00:00
|
|
|
PRBool hasFloats = BlockHasAnyFloats(aOldFrame);
|
2008-12-03 01:27:19 +00:00
|
|
|
rv = DoRemoveFrame(aOldFrame, REMOVE_FIXED_CONTINUATIONS);
|
2005-07-19 21:58:41 +00:00
|
|
|
if (hasFloats) {
|
2009-01-05 00:39:54 +00:00
|
|
|
MarkSameFloatManagerLinesDirty(this);
|
2005-07-19 21:58:41 +00:00
|
|
|
}
|
2002-01-06 18:17:41 +00:00
|
|
|
}
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (nsGkAtoms::floatList == aListName) {
|
2009-08-31 18:25:37 +00:00
|
|
|
// Make sure to mark affected lines dirty for the float frame
|
2007-08-18 00:06:46 +00:00
|
|
|
// we are removing; this way is a bit messy, but so is the rest of the code.
|
|
|
|
// See bug 390762.
|
2009-08-31 18:25:37 +00:00
|
|
|
NS_ASSERTION(!aOldFrame->GetPrevContinuation(),
|
2010-08-06 04:59:20 +00:00
|
|
|
"RemoveFrame should not be called on pushed floats.");
|
2009-08-31 18:25:37 +00:00
|
|
|
for (nsIFrame* f = aOldFrame;
|
|
|
|
f && !(f->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER);
|
|
|
|
f = f->GetNextContinuation()) {
|
|
|
|
MarkSameFloatManagerLinesDirty(static_cast<nsBlockFrame*>(f->GetParent()));
|
|
|
|
}
|
|
|
|
DoRemoveOutOfFlowFrame(aOldFrame);
|
1999-02-26 17:04:44 +00:00
|
|
|
}
|
2001-03-09 03:29:00 +00:00
|
|
|
#ifdef IBMBIDI
|
2006-12-26 17:47:52 +00:00
|
|
|
else if (nsGkAtoms::nextBidi == aListName) {
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
// Skip the call to |FrameNeedsReflow| below by returning now.
|
2008-12-03 01:27:19 +00:00
|
|
|
return DoRemoveFrame(aOldFrame, REMOVE_FIXED_CONTINUATIONS);
|
2001-03-09 03:29:00 +00:00
|
|
|
}
|
|
|
|
#endif // IBMBIDI
|
1999-09-22 00:58:58 +00:00
|
|
|
else {
|
2006-06-29 02:32:36 +00:00
|
|
|
NS_ERROR("unexpected child list");
|
2002-01-06 18:17:41 +00:00
|
|
|
rv = NS_ERROR_INVALID_ARG;
|
1999-02-03 19:09:24 +00:00
|
|
|
}
|
1999-02-23 19:18:12 +00:00
|
|
|
|
1999-02-02 17:31:09 +00:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2007-03-30 21:11:41 +00:00
|
|
|
PresContext()->PresShell()->
|
2007-05-06 19:16:51 +00:00
|
|
|
FrameNeedsReflow(this, nsIPresShell::eTreeChange,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN); // XXX sufficient?
|
1999-02-02 17:31:09 +00:00
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2002-05-28 22:50:43 +00:00
|
|
|
void
|
2005-02-07 01:58:25 +00:00
|
|
|
nsBlockFrame::DoRemoveOutOfFlowFrame(nsIFrame* aFrame)
|
2002-05-28 22:50:43 +00:00
|
|
|
{
|
2005-03-23 03:35:08 +00:00
|
|
|
// The containing block is always the parent of aFrame.
|
|
|
|
nsBlockFrame* block = (nsBlockFrame*)aFrame->GetParent();
|
2007-07-26 04:03:29 +00:00
|
|
|
|
|
|
|
// Remove aFrame from the appropriate list.
|
2007-10-02 05:57:45 +00:00
|
|
|
const nsStyleDisplay* display = aFrame->GetStyleDisplay();
|
2002-05-28 22:50:43 +00:00
|
|
|
if (display->IsAbsolutelyPositioned()) {
|
2007-10-02 05:57:45 +00:00
|
|
|
// This also deletes the next-in-flows
|
2011-04-29 23:02:33 +00:00
|
|
|
block->GetAbsoluteContainingBlock()->RemoveFrame(block,
|
|
|
|
nsGkAtoms::absoluteList,
|
|
|
|
aFrame);
|
2002-05-28 22:50:43 +00:00
|
|
|
}
|
|
|
|
else {
|
2009-08-31 18:25:36 +00:00
|
|
|
// First remove aFrame's next-in-flows
|
|
|
|
nsIFrame* nif = aFrame->GetNextInFlow();
|
|
|
|
if (nif) {
|
|
|
|
static_cast<nsContainerFrame*>(nif->GetParent())
|
|
|
|
->DeleteNextInFlowChild(aFrame->PresContext(), nif, PR_FALSE);
|
2007-10-02 05:57:45 +00:00
|
|
|
}
|
|
|
|
// Now remove aFrame
|
2004-10-08 12:17:10 +00:00
|
|
|
// This also destroys the frame.
|
|
|
|
block->RemoveFloat(aFrame);
|
2002-05-28 22:50:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-03-23 03:35:08 +00:00
|
|
|
/**
|
|
|
|
* This helps us iterate over the list of all normal + overflow lines
|
|
|
|
*/
|
2004-08-26 12:38:50 +00:00
|
|
|
void
|
2004-10-08 12:17:10 +00:00
|
|
|
nsBlockFrame::TryAllLines(nsLineList::iterator* aIterator,
|
2007-10-07 17:32:07 +00:00
|
|
|
nsLineList::iterator* aStartIterator,
|
2004-10-08 12:17:10 +00:00
|
|
|
nsLineList::iterator* aEndIterator,
|
|
|
|
PRBool* aInOverflowLines) {
|
2004-08-26 12:38:50 +00:00
|
|
|
if (*aIterator == *aEndIterator) {
|
|
|
|
if (!*aInOverflowLines) {
|
|
|
|
*aInOverflowLines = PR_TRUE;
|
|
|
|
// Try the overflow lines
|
|
|
|
nsLineList* overflowLines = GetOverflowLines();
|
|
|
|
if (overflowLines) {
|
2007-10-07 17:32:07 +00:00
|
|
|
*aStartIterator = overflowLines->begin();
|
|
|
|
*aIterator = *aStartIterator;
|
2004-08-26 12:38:50 +00:00
|
|
|
*aEndIterator = overflowLines->end();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-22 09:08:13 +00:00
|
|
|
nsBlockInFlowLineIterator::nsBlockInFlowLineIterator(nsBlockFrame* aFrame,
|
2008-01-29 23:39:39 +00:00
|
|
|
line_iterator aLine, PRBool aInOverflow)
|
2007-08-22 09:08:13 +00:00
|
|
|
: mFrame(aFrame), mLine(aLine), mInOverflowLines(nsnull)
|
|
|
|
{
|
|
|
|
if (aInOverflow) {
|
|
|
|
mInOverflowLines = aFrame->GetOverflowLines();
|
|
|
|
NS_ASSERTION(mInOverflowLines, "How can we be in overflow if there isn't any?");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-02-24 07:31:29 +00:00
|
|
|
nsBlockInFlowLineIterator::nsBlockInFlowLineIterator(nsBlockFrame* aFrame,
|
|
|
|
PRBool* aFoundValidLine)
|
|
|
|
: mFrame(aFrame), mInOverflowLines(nsnull)
|
|
|
|
{
|
|
|
|
mLine = aFrame->begin_lines();
|
|
|
|
*aFoundValidLine = FindValidLine();
|
|
|
|
}
|
|
|
|
|
2008-02-27 09:53:48 +00:00
|
|
|
static nsIFrame*
|
|
|
|
FindChildContaining(nsBlockFrame* aFrame, nsIFrame* aFindFrame)
|
|
|
|
{
|
2009-02-19 17:48:37 +00:00
|
|
|
NS_ASSERTION(aFrame, "must have frame");
|
2008-02-27 09:53:48 +00:00
|
|
|
nsIFrame* child;
|
|
|
|
while (PR_TRUE) {
|
|
|
|
nsIFrame* block = aFrame;
|
2009-02-19 17:48:37 +00:00
|
|
|
do {
|
2008-02-27 09:53:48 +00:00
|
|
|
child = nsLayoutUtils::FindChildContainingDescendant(block, aFindFrame);
|
|
|
|
if (child)
|
|
|
|
break;
|
|
|
|
block = block->GetNextContinuation();
|
2009-02-19 17:48:37 +00:00
|
|
|
} while (block);
|
2008-02-27 09:53:48 +00:00
|
|
|
if (!child)
|
|
|
|
return nsnull;
|
|
|
|
if (!(child->GetStateBits() & NS_FRAME_OUT_OF_FLOW))
|
|
|
|
break;
|
|
|
|
aFindFrame = aFrame->PresContext()->FrameManager()->GetPlaceholderFrameFor(child);
|
|
|
|
}
|
|
|
|
|
|
|
|
return child;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsBlockInFlowLineIterator::nsBlockInFlowLineIterator(nsBlockFrame* aFrame,
|
|
|
|
nsIFrame* aFindFrame, PRBool* aFoundValidLine)
|
|
|
|
: mFrame(aFrame), mInOverflowLines(nsnull)
|
|
|
|
{
|
|
|
|
*aFoundValidLine = PR_FALSE;
|
|
|
|
|
|
|
|
nsIFrame* child = FindChildContaining(aFrame, aFindFrame);
|
|
|
|
if (!child)
|
|
|
|
return;
|
|
|
|
|
2010-09-09 00:15:24 +00:00
|
|
|
// Try to use the cursor if it exists, otherwise fall back to the first line
|
|
|
|
nsLineBox* cursor = static_cast<nsLineBox*>
|
|
|
|
(aFrame->Properties().Get(LineCursorProperty()));
|
|
|
|
if (!cursor) {
|
|
|
|
line_iterator iter = aFrame->begin_lines();
|
|
|
|
if (iter != aFrame->end_lines()) {
|
|
|
|
cursor = iter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cursor) {
|
|
|
|
// Perform a simultaneous forward and reverse search starting from the
|
|
|
|
// line cursor.
|
|
|
|
nsBlockFrame::line_iterator line = aFrame->line(cursor);
|
|
|
|
nsBlockFrame::reverse_line_iterator rline = aFrame->rline(cursor);
|
|
|
|
nsBlockFrame::line_iterator line_end = aFrame->end_lines();
|
|
|
|
nsBlockFrame::reverse_line_iterator rline_end = aFrame->rend_lines();
|
2010-09-17 19:09:08 +00:00
|
|
|
// rline is positioned on the line containing 'cursor', so it's not
|
|
|
|
// rline_end. So we can safely increment it (i.e. move it to one line
|
|
|
|
// earlier) to start searching there.
|
|
|
|
++rline;
|
|
|
|
while (line != line_end || rline != rline_end) {
|
2010-09-09 00:15:24 +00:00
|
|
|
if (line != line_end) {
|
|
|
|
if (line->Contains(child)) {
|
|
|
|
*aFoundValidLine = PR_TRUE;
|
|
|
|
mLine = line;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
++line;
|
|
|
|
}
|
|
|
|
if (rline != rline_end) {
|
|
|
|
if (rline->Contains(child)) {
|
|
|
|
*aFoundValidLine = PR_TRUE;
|
|
|
|
mLine = rline;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
++rline;
|
|
|
|
}
|
|
|
|
}
|
2010-09-17 19:09:08 +00:00
|
|
|
// Didn't find the line
|
2010-09-09 00:15:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// If we reach here, it means that we have not been able to find the
|
|
|
|
// desired frame in our in-flow lines. So we should start looking at
|
|
|
|
// our overflow lines. In order to do that, we set mLine to the end
|
|
|
|
// iterator so that FindValidLine starts to look at overflow lines,
|
|
|
|
// if any.
|
|
|
|
|
|
|
|
mLine = aFrame->end_lines();
|
|
|
|
|
2008-02-27 09:53:48 +00:00
|
|
|
if (!FindValidLine())
|
|
|
|
return;
|
|
|
|
|
|
|
|
do {
|
|
|
|
if (mLine->Contains(child)) {
|
|
|
|
*aFoundValidLine = PR_TRUE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} while (Next());
|
|
|
|
}
|
|
|
|
|
2008-04-12 05:32:49 +00:00
|
|
|
nsBlockFrame::line_iterator
|
|
|
|
nsBlockInFlowLineIterator::End()
|
|
|
|
{
|
|
|
|
return mInOverflowLines ? mInOverflowLines->end() : mFrame->end_lines();
|
|
|
|
}
|
|
|
|
|
2008-01-29 23:39:39 +00:00
|
|
|
PRBool
|
|
|
|
nsBlockInFlowLineIterator::IsLastLineInList()
|
|
|
|
{
|
2008-04-12 05:32:49 +00:00
|
|
|
line_iterator end = End();
|
2008-01-29 23:39:39 +00:00
|
|
|
return mLine != end && mLine.next() == end;
|
|
|
|
}
|
|
|
|
|
2007-08-22 09:08:13 +00:00
|
|
|
PRBool
|
|
|
|
nsBlockInFlowLineIterator::Next()
|
|
|
|
{
|
|
|
|
++mLine;
|
2008-02-24 07:31:29 +00:00
|
|
|
return FindValidLine();
|
2007-08-22 09:08:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsBlockInFlowLineIterator::Prev()
|
|
|
|
{
|
|
|
|
line_iterator begin = mInOverflowLines ? mInOverflowLines->begin() : mFrame->begin_lines();
|
|
|
|
if (mLine != begin) {
|
|
|
|
--mLine;
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
PRBool currentlyInOverflowLines = mInOverflowLines != nsnull;
|
|
|
|
while (PR_TRUE) {
|
|
|
|
if (currentlyInOverflowLines) {
|
2008-10-12 00:19:41 +00:00
|
|
|
mInOverflowLines = nsnull;
|
2007-08-22 09:08:13 +00:00
|
|
|
mLine = mFrame->end_lines();
|
|
|
|
if (mLine != mFrame->begin_lines()) {
|
|
|
|
--mLine;
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
mFrame = static_cast<nsBlockFrame*>(mFrame->GetPrevInFlow());
|
|
|
|
if (!mFrame)
|
|
|
|
return PR_FALSE;
|
|
|
|
mInOverflowLines = mFrame->GetOverflowLines();
|
|
|
|
if (mInOverflowLines) {
|
|
|
|
mLine = mInOverflowLines->end();
|
|
|
|
NS_ASSERTION(mLine != mInOverflowLines->begin(), "empty overflow line list?");
|
|
|
|
--mLine;
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
currentlyInOverflowLines = !currentlyInOverflowLines;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-02-24 07:31:29 +00:00
|
|
|
PRBool
|
|
|
|
nsBlockInFlowLineIterator::FindValidLine()
|
|
|
|
{
|
|
|
|
line_iterator end = mInOverflowLines ? mInOverflowLines->end() : mFrame->end_lines();
|
|
|
|
if (mLine != end)
|
2009-02-10 09:23:05 +00:00
|
|
|
return PR_TRUE;
|
2008-02-24 07:31:29 +00:00
|
|
|
PRBool currentlyInOverflowLines = mInOverflowLines != nsnull;
|
|
|
|
while (PR_TRUE) {
|
|
|
|
if (currentlyInOverflowLines) {
|
|
|
|
mFrame = static_cast<nsBlockFrame*>(mFrame->GetNextInFlow());
|
|
|
|
if (!mFrame)
|
|
|
|
return PR_FALSE;
|
|
|
|
mInOverflowLines = nsnull;
|
|
|
|
mLine = mFrame->begin_lines();
|
|
|
|
if (mLine != mFrame->end_lines())
|
|
|
|
return PR_TRUE;
|
|
|
|
} else {
|
|
|
|
mInOverflowLines = mFrame->GetOverflowLines();
|
|
|
|
if (mInOverflowLines) {
|
|
|
|
mLine = mInOverflowLines->begin();
|
|
|
|
NS_ASSERTION(mLine != mInOverflowLines->end(), "empty overflow line list?");
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
currentlyInOverflowLines = !currentlyInOverflowLines;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-31 18:25:35 +00:00
|
|
|
static nsresult RemoveBlockChild(nsIFrame* aFrame,
|
|
|
|
PRBool aRemoveOnlyFluidContinuations)
|
2005-03-23 03:35:08 +00:00
|
|
|
{
|
|
|
|
if (!aFrame)
|
|
|
|
return NS_OK;
|
|
|
|
|
2008-07-13 22:10:23 +00:00
|
|
|
nsBlockFrame* nextBlock = nsLayoutUtils::GetAsBlock(aFrame->GetParent());
|
|
|
|
NS_ASSERTION(nextBlock,
|
2005-03-23 03:35:08 +00:00
|
|
|
"Our child's continuation's parent is not a block?");
|
2008-12-03 01:27:19 +00:00
|
|
|
return nextBlock->DoRemoveFrame(aFrame,
|
|
|
|
(aRemoveOnlyFluidContinuations ? 0 : nsBlockFrame::REMOVE_FIXED_CONTINUATIONS));
|
2005-03-23 03:35:08 +00:00
|
|
|
}
|
|
|
|
|
2004-08-26 12:38:50 +00:00
|
|
|
// This function removes aDeletedFrame and all its continuations. It
|
|
|
|
// is optimized for deleting a whole series of frames. The easy
|
|
|
|
// implementation would invoke itself recursively on
|
2006-02-21 21:33:47 +00:00
|
|
|
// aDeletedFrame->GetNextContinuation, then locate the line containing
|
2004-08-26 12:38:50 +00:00
|
|
|
// aDeletedFrame and remove aDeletedFrame from that line. But here we
|
|
|
|
// start by locating aDeletedFrame and then scanning from that point
|
|
|
|
// on looking for continuations.
|
1998-12-05 16:02:08 +00:00
|
|
|
nsresult
|
2008-12-03 01:27:19 +00:00
|
|
|
nsBlockFrame::DoRemoveFrame(nsIFrame* aDeletedFrame, PRUint32 aFlags)
|
1998-06-18 16:25:41 +00:00
|
|
|
{
|
2004-03-14 18:19:24 +00:00
|
|
|
// Clear our line cursor, since our lines may change.
|
|
|
|
ClearLineCursor();
|
2007-10-02 05:57:45 +00:00
|
|
|
|
|
|
|
nsPresContext* presContext = PresContext();
|
2009-08-31 18:25:36 +00:00
|
|
|
if (aDeletedFrame->GetStateBits() &
|
|
|
|
(NS_FRAME_OUT_OF_FLOW | NS_FRAME_IS_OVERFLOW_CONTAINER)) {
|
|
|
|
if (!aDeletedFrame->GetPrevInFlow()) {
|
|
|
|
NS_ASSERTION(aDeletedFrame->GetStateBits() & NS_FRAME_OUT_OF_FLOW,
|
|
|
|
"Expected out-of-flow frame");
|
|
|
|
DoRemoveOutOfFlowFrame(aDeletedFrame);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsContainerFrame::DeleteNextInFlowChild(presContext, aDeletedFrame,
|
|
|
|
(aFlags & FRAMES_ARE_EMPTY) != 0);
|
|
|
|
}
|
2007-10-10 22:09:53 +00:00
|
|
|
return NS_OK;
|
2007-10-02 05:57:45 +00:00
|
|
|
}
|
|
|
|
|
2005-02-07 01:58:25 +00:00
|
|
|
nsIPresShell* presShell = presContext->PresShell();
|
|
|
|
|
2009-10-02 16:27:37 +00:00
|
|
|
// Find the line that contains deletedFrame
|
2007-10-07 17:32:07 +00:00
|
|
|
nsLineList::iterator line_start = mLines.begin(),
|
2004-08-26 12:38:50 +00:00
|
|
|
line_end = mLines.end();
|
2007-10-07 17:32:07 +00:00
|
|
|
nsLineList::iterator line = line_start;
|
2004-08-26 12:38:50 +00:00
|
|
|
PRBool searchingOverflowList = PR_FALSE;
|
2004-10-08 12:17:10 +00:00
|
|
|
// Make sure we look in the overflow lines even if the normal line
|
|
|
|
// list is empty
|
2007-10-07 17:32:07 +00:00
|
|
|
TryAllLines(&line, &line_start, &line_end, &searchingOverflowList);
|
2004-10-08 12:17:10 +00:00
|
|
|
while (line != line_end) {
|
2009-10-02 16:27:37 +00:00
|
|
|
if (line->Contains(aDeletedFrame)) {
|
|
|
|
break;
|
1998-10-16 20:22:39 +00:00
|
|
|
}
|
2004-10-08 12:17:10 +00:00
|
|
|
++line;
|
2007-10-07 17:32:07 +00:00
|
|
|
TryAllLines(&line, &line_start, &line_end, &searchingOverflowList);
|
1998-08-04 21:18:16 +00:00
|
|
|
}
|
2009-10-02 16:27:37 +00:00
|
|
|
|
2003-08-20 16:49:27 +00:00
|
|
|
if (line == line_end) {
|
|
|
|
NS_ERROR("can't find deleted frame in lines");
|
2002-01-14 22:05:26 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
2003-08-20 16:49:27 +00:00
|
|
|
}
|
2007-09-18 03:00:16 +00:00
|
|
|
|
2008-12-03 01:27:19 +00:00
|
|
|
if (!(aFlags & FRAMES_ARE_EMPTY)) {
|
|
|
|
if (line != line_start) {
|
2009-05-19 15:54:42 +00:00
|
|
|
line.prev()->MarkDirty();
|
2008-12-03 01:27:19 +00:00
|
|
|
line.prev()->SetInvalidateTextRuns(PR_TRUE);
|
|
|
|
}
|
|
|
|
else if (searchingOverflowList && !mLines.empty()) {
|
2009-05-19 15:54:42 +00:00
|
|
|
mLines.back()->MarkDirty();
|
2008-12-03 01:27:19 +00:00
|
|
|
mLines.back()->SetInvalidateTextRuns(PR_TRUE);
|
|
|
|
}
|
2007-10-07 17:32:07 +00:00
|
|
|
}
|
2004-08-26 12:38:50 +00:00
|
|
|
|
2004-10-08 12:17:10 +00:00
|
|
|
while ((line != line_end) && (nsnull != aDeletedFrame)) {
|
2004-08-26 12:38:50 +00:00
|
|
|
NS_ASSERTION(this == aDeletedFrame->GetParent(), "messed up delete code");
|
2004-10-08 12:17:10 +00:00
|
|
|
NS_ASSERTION(line->Contains(aDeletedFrame), "frame not in line");
|
1998-12-05 16:02:08 +00:00
|
|
|
|
2008-12-03 01:27:19 +00:00
|
|
|
if (!(aFlags & FRAMES_ARE_EMPTY)) {
|
2009-05-19 15:54:42 +00:00
|
|
|
line->MarkDirty();
|
2008-12-03 01:27:19 +00:00
|
|
|
line->SetInvalidateTextRuns(PR_TRUE);
|
|
|
|
}
|
2007-09-18 03:00:16 +00:00
|
|
|
|
2006-01-21 10:33:48 +00:00
|
|
|
// If the frame being deleted is the last one on the line then
|
|
|
|
// optimize away the line->Contains(next-in-flow) call below.
|
|
|
|
PRBool isLastFrameOnLine = (1 == line->GetChildCount() ||
|
|
|
|
line->LastChild() == aDeletedFrame);
|
1999-01-05 23:01:54 +00:00
|
|
|
|
2004-10-08 12:17:10 +00:00
|
|
|
// Remove aDeletedFrame from the line
|
|
|
|
nsIFrame* nextFrame = aDeletedFrame->GetNextSibling();
|
|
|
|
if (line->mFirstChild == aDeletedFrame) {
|
|
|
|
// We should be setting this to null if aDeletedFrame
|
|
|
|
// is the only frame on the line. HOWEVER in that case
|
|
|
|
// we will be removing the line anyway, see below.
|
|
|
|
line->mFirstChild = nextFrame;
|
|
|
|
}
|
2001-10-25 01:08:40 +00:00
|
|
|
|
2004-08-26 12:38:50 +00:00
|
|
|
// Hmm, this won't do anything if we're removing a frame in the first
|
|
|
|
// overflow line... Hopefully doesn't matter
|
2004-10-08 12:17:10 +00:00
|
|
|
--line;
|
|
|
|
if (line != line_end && !line->IsBlock()) {
|
|
|
|
// Since we just removed a frame that follows some inline
|
|
|
|
// frames, we need to reflow the previous line.
|
|
|
|
line->MarkDirty();
|
|
|
|
}
|
|
|
|
++line;
|
1998-06-18 16:25:41 +00:00
|
|
|
|
2004-10-08 12:17:10 +00:00
|
|
|
// Take aDeletedFrame out of the sibling list. Note that
|
|
|
|
// prevSibling will only be nsnull when we are deleting the very
|
2004-08-26 12:38:50 +00:00
|
|
|
// first frame in the main or overflow list.
|
2009-09-29 19:47:05 +00:00
|
|
|
if (searchingOverflowList) {
|
2009-10-02 16:27:37 +00:00
|
|
|
nsIFrame* prevSibling = aDeletedFrame->GetPrevSibling();
|
2009-09-29 19:47:05 +00:00
|
|
|
if (prevSibling) {
|
|
|
|
// XXXbz If we switch overflow lines to nsFrameList, we should
|
|
|
|
// change this SetNextSibling call.
|
|
|
|
prevSibling->SetNextSibling(nextFrame);
|
|
|
|
}
|
2009-12-24 05:20:41 +00:00
|
|
|
aDeletedFrame->SetNextSibling(nsnull);
|
2009-09-29 19:47:05 +00:00
|
|
|
} else {
|
2009-10-02 16:27:37 +00:00
|
|
|
mFrames.RemoveFrame(aDeletedFrame);
|
2004-10-08 12:17:10 +00:00
|
|
|
}
|
1998-12-05 16:02:08 +00:00
|
|
|
|
2004-10-08 12:17:10 +00:00
|
|
|
// Update the child count of the line to be accurate
|
|
|
|
PRInt32 lineChildCount = line->GetChildCount();
|
|
|
|
lineChildCount--;
|
|
|
|
line->SetChildCount(lineChildCount);
|
2002-02-25 19:23:48 +00:00
|
|
|
|
2006-02-21 21:33:47 +00:00
|
|
|
// Destroy frame; capture its next continuation first in case we need
|
2004-10-08 12:17:10 +00:00
|
|
|
// to destroy that too.
|
2008-12-03 01:27:19 +00:00
|
|
|
nsIFrame* deletedNextContinuation = (aFlags & REMOVE_FIXED_CONTINUATIONS) ?
|
|
|
|
aDeletedFrame->GetNextContinuation() : aDeletedFrame->GetNextInFlow();
|
1999-03-16 19:36:00 +00:00
|
|
|
#ifdef NOISY_REMOVE_FRAME
|
2006-01-21 10:33:48 +00:00
|
|
|
printf("DoRemoveFrame: %s line=%p frame=",
|
|
|
|
searchingOverflowList?"overflow":"normal", line.get());
|
2004-10-08 12:17:10 +00:00
|
|
|
nsFrame::ListTag(stdout, aDeletedFrame);
|
2010-06-01 23:32:59 +00:00
|
|
|
printf(" prevSibling=%p deletedNextContinuation=%p\n",
|
|
|
|
aDeletedFrame->GetPrevSibling(), deletedNextContinuation);
|
1999-03-16 19:36:00 +00:00
|
|
|
#endif
|
2006-05-25 01:30:34 +00:00
|
|
|
|
2010-06-01 23:32:59 +00:00
|
|
|
// If next-in-flow is an overflow container, must remove it first.
|
|
|
|
if (deletedNextContinuation &&
|
|
|
|
deletedNextContinuation->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER) {
|
|
|
|
static_cast<nsContainerFrame*>(deletedNextContinuation->GetParent())
|
|
|
|
->DeleteNextInFlowChild(presContext, deletedNextContinuation, PR_FALSE);
|
|
|
|
deletedNextContinuation = nsnull;
|
|
|
|
}
|
|
|
|
|
2009-08-31 18:25:35 +00:00
|
|
|
aDeletedFrame->Destroy();
|
2006-02-21 21:33:47 +00:00
|
|
|
aDeletedFrame = deletedNextContinuation;
|
1998-12-05 16:02:08 +00:00
|
|
|
|
2006-01-21 10:33:48 +00:00
|
|
|
PRBool haveAdvancedToNextLine = PR_FALSE;
|
2004-08-26 12:38:50 +00:00
|
|
|
// If line is empty, remove it now.
|
2004-10-08 12:17:10 +00:00
|
|
|
if (0 == lineChildCount) {
|
2006-01-21 10:33:48 +00:00
|
|
|
#ifdef NOISY_REMOVE_FRAME
|
|
|
|
printf("DoRemoveFrame: %s line=%p became empty so it will be removed\n",
|
|
|
|
searchingOverflowList?"overflow":"normal", line.get());
|
|
|
|
#endif
|
2004-10-08 12:17:10 +00:00
|
|
|
nsLineBox *cur = line;
|
|
|
|
if (!searchingOverflowList) {
|
|
|
|
line = mLines.erase(line);
|
1999-09-21 05:15:39 +00:00
|
|
|
// Invalidate the space taken up by the line.
|
|
|
|
// XXX We need to do this if we're removing a frame as a result of
|
|
|
|
// a call to RemoveFrame(), but we may not need to do this in all
|
|
|
|
// cases...
|
2010-10-07 04:25:45 +00:00
|
|
|
nsRect visOverflow(cur->GetVisualOverflowArea());
|
2000-04-17 14:40:46 +00:00
|
|
|
#ifdef NOISY_BLOCK_INVALIDATE
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("%p invalidate 10 (%d, %d, %d, %d)\n",
|
2010-10-07 04:25:45 +00:00
|
|
|
this, visOverflow.x, visOverflow.y,
|
|
|
|
visOverflow.width, visOverflow.height);
|
2000-04-17 14:40:46 +00:00
|
|
|
#endif
|
2010-10-07 04:25:45 +00:00
|
|
|
Invalidate(visOverflow);
|
2004-10-08 12:17:10 +00:00
|
|
|
} else {
|
|
|
|
nsLineList* lineList = RemoveOverflowLines();
|
|
|
|
line = lineList->erase(line);
|
|
|
|
if (!lineList->empty()) {
|
|
|
|
SetOverflowLines(lineList);
|
2009-09-29 01:23:33 +00:00
|
|
|
} else {
|
|
|
|
delete lineList;
|
2009-12-25 13:59:08 +00:00
|
|
|
// We just invalidated our iterators. Since we were in
|
|
|
|
// the overflow lines list, which is now empty, set them
|
|
|
|
// so we're at the end of the regular line list.
|
|
|
|
line_start = mLines.begin();
|
|
|
|
line_end = mLines.end();
|
|
|
|
line = line_end;
|
2004-10-08 12:17:10 +00:00
|
|
|
}
|
1998-12-05 16:02:08 +00:00
|
|
|
}
|
2004-10-08 12:17:10 +00:00
|
|
|
cur->Destroy(presShell);
|
|
|
|
|
|
|
|
// If we're removing a line, ReflowDirtyLines isn't going to
|
|
|
|
// know that it needs to slide lines unless something is marked
|
|
|
|
// dirty. So mark the previous margin of the next line dirty if
|
|
|
|
// there is one.
|
|
|
|
if (line != line_end) {
|
|
|
|
line->MarkPreviousMarginDirty();
|
|
|
|
}
|
2006-01-21 10:33:48 +00:00
|
|
|
haveAdvancedToNextLine = PR_TRUE;
|
2004-10-08 12:17:10 +00:00
|
|
|
} else {
|
|
|
|
// Make the line that just lost a frame dirty, and advance to
|
|
|
|
// the next line.
|
2006-02-21 21:33:47 +00:00
|
|
|
if (!deletedNextContinuation || isLastFrameOnLine ||
|
|
|
|
!line->Contains(deletedNextContinuation)) {
|
2004-12-12 18:15:53 +00:00
|
|
|
line->MarkDirty();
|
|
|
|
++line;
|
2006-01-21 10:33:48 +00:00
|
|
|
haveAdvancedToNextLine = PR_TRUE;
|
1998-12-05 16:02:08 +00:00
|
|
|
}
|
2004-10-08 12:17:10 +00:00
|
|
|
}
|
1999-01-05 23:01:54 +00:00
|
|
|
|
2006-02-21 21:33:47 +00:00
|
|
|
if (deletedNextContinuation) {
|
2004-12-12 18:15:53 +00:00
|
|
|
// See if we should keep looking in the current flow's line list.
|
2006-02-21 21:33:47 +00:00
|
|
|
if (deletedNextContinuation->GetParent() != this) {
|
2004-10-08 12:17:10 +00:00
|
|
|
// The deceased frames continuation is not a child of the
|
|
|
|
// current block. So break out of the loop so that we advance
|
|
|
|
// to the next parent.
|
2009-10-13 07:12:54 +00:00
|
|
|
//
|
|
|
|
// If we have a continuation in a different block then all bets are
|
|
|
|
// off regarding whether we are deleting frames without actual content,
|
|
|
|
// so don't propagate FRAMES_ARE_EMPTY any further.
|
|
|
|
aFlags &= ~FRAMES_ARE_EMPTY;
|
2004-10-08 12:17:10 +00:00
|
|
|
break;
|
1999-01-05 23:01:54 +00:00
|
|
|
}
|
2004-12-12 18:15:53 +00:00
|
|
|
|
2006-01-21 10:33:48 +00:00
|
|
|
// If we advanced to the next line then check if we should switch to the
|
|
|
|
// overflow line list.
|
|
|
|
if (haveAdvancedToNextLine) {
|
|
|
|
if (line != line_end && !searchingOverflowList &&
|
2006-02-21 21:33:47 +00:00
|
|
|
!line->Contains(deletedNextContinuation)) {
|
2006-01-21 10:33:48 +00:00
|
|
|
// We have advanced to the next *normal* line but the next-in-flow
|
|
|
|
// is not there - force a switch to the overflow line list.
|
|
|
|
line = line_end;
|
2004-12-12 18:15:53 +00:00
|
|
|
}
|
2006-07-29 09:38:35 +00:00
|
|
|
|
2007-10-07 17:32:07 +00:00
|
|
|
TryAllLines(&line, &line_start, &line_end, &searchingOverflowList);
|
2006-01-21 10:33:48 +00:00
|
|
|
#ifdef NOISY_REMOVE_FRAME
|
2009-10-02 16:27:37 +00:00
|
|
|
printf("DoRemoveFrame: now on %s line=%p\n",
|
|
|
|
searchingOverflowList?"overflow":"normal", line.get());
|
2006-01-21 10:33:48 +00:00
|
|
|
#endif
|
2004-12-12 18:15:53 +00:00
|
|
|
}
|
1998-06-18 16:25:41 +00:00
|
|
|
}
|
2004-10-08 12:17:10 +00:00
|
|
|
}
|
2008-12-03 01:27:19 +00:00
|
|
|
|
|
|
|
if (!(aFlags & FRAMES_ARE_EMPTY) && line.next() != line_end) {
|
2009-05-19 15:54:42 +00:00
|
|
|
line.next()->MarkDirty();
|
2007-09-18 03:00:16 +00:00
|
|
|
line.next()->SetInvalidateTextRuns(PR_TRUE);
|
|
|
|
}
|
1998-06-18 16:25:41 +00:00
|
|
|
|
1999-03-16 19:36:00 +00:00
|
|
|
#ifdef DEBUG
|
1999-04-20 00:27:43 +00:00
|
|
|
VerifyLines(PR_TRUE);
|
1999-03-16 19:36:00 +00:00
|
|
|
#endif
|
2004-08-26 12:38:50 +00:00
|
|
|
|
|
|
|
// Advance to next flow block if the frame has more continuations
|
2009-08-31 18:25:35 +00:00
|
|
|
return RemoveBlockChild(aDeletedFrame, !(aFlags & REMOVE_FIXED_CONTINUATIONS));
|
1998-06-24 17:52:42 +00:00
|
|
|
}
|
1998-06-18 16:25:41 +00:00
|
|
|
|
2007-07-26 04:03:29 +00:00
|
|
|
nsresult
|
|
|
|
nsBlockFrame::StealFrame(nsPresContext* aPresContext,
|
|
|
|
nsIFrame* aChild,
|
|
|
|
PRBool aForceNormal)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(aPresContext && aChild, "null pointer");
|
|
|
|
|
2009-08-31 18:25:36 +00:00
|
|
|
if ((aChild->GetStateBits() & NS_FRAME_OUT_OF_FLOW) &&
|
|
|
|
aChild->GetStyleDisplay()->IsFloating()) {
|
2009-09-18 11:09:36 +00:00
|
|
|
PRBool removed = mFloats.RemoveFrameIfPresent(aChild);
|
2009-08-31 18:25:36 +00:00
|
|
|
if (!removed) {
|
2010-08-06 04:59:20 +00:00
|
|
|
nsFrameList* list = GetPushedFloats();
|
2009-08-31 18:25:36 +00:00
|
|
|
if (list) {
|
2009-09-18 11:09:36 +00:00
|
|
|
removed = list->RemoveFrameIfPresent(aChild);
|
2009-08-31 18:25:36 +00:00
|
|
|
}
|
|
|
|
}
|
2009-09-18 11:09:36 +00:00
|
|
|
return removed ? NS_OK : NS_ERROR_UNEXPECTED;
|
2009-08-31 18:25:36 +00:00
|
|
|
}
|
|
|
|
|
2007-07-26 04:03:29 +00:00
|
|
|
if ((aChild->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER)
|
|
|
|
&& !aForceNormal)
|
|
|
|
return nsContainerFrame::StealFrame(aPresContext, aChild);
|
|
|
|
|
|
|
|
// Find the line and the previous sibling that contains
|
|
|
|
// aChild; we also find the pointer to the line.
|
|
|
|
nsLineList::iterator line = mLines.begin(),
|
2007-10-07 17:32:07 +00:00
|
|
|
line_start = line,
|
2007-07-26 04:03:29 +00:00
|
|
|
line_end = mLines.end();
|
|
|
|
PRBool searchingOverflowList = PR_FALSE;
|
|
|
|
nsIFrame* prevSibling = nsnull;
|
|
|
|
// Make sure we look in the overflow lines even if the normal line
|
|
|
|
// list is empty
|
2007-10-07 17:32:07 +00:00
|
|
|
TryAllLines(&line, &line_start, &line_end, &searchingOverflowList);
|
2007-07-26 04:03:29 +00:00
|
|
|
while (line != line_end) {
|
|
|
|
nsIFrame* frame = line->mFirstChild;
|
|
|
|
PRInt32 n = line->GetChildCount();
|
|
|
|
while (--n >= 0) {
|
|
|
|
if (frame == aChild) {
|
|
|
|
// Disconnect from sibling list
|
2009-09-29 19:47:05 +00:00
|
|
|
if (frame == line->mFirstChild) {
|
2007-07-26 04:03:29 +00:00
|
|
|
line->mFirstChild = frame->GetNextSibling();
|
2009-09-29 19:47:05 +00:00
|
|
|
}
|
|
|
|
if (searchingOverflowList) {
|
|
|
|
// XXXbz If we switch overflow lines to nsFrameList, we should
|
|
|
|
// change this SetNextSibling call.
|
|
|
|
if (prevSibling)
|
|
|
|
prevSibling->SetNextSibling(frame->GetNextSibling());
|
|
|
|
frame->SetNextSibling(nsnull);
|
|
|
|
} else {
|
2009-10-02 16:27:37 +00:00
|
|
|
mFrames.RemoveFrame(frame);
|
2009-09-29 19:47:05 +00:00
|
|
|
}
|
2007-07-26 04:03:29 +00:00
|
|
|
|
|
|
|
// Register removal with the line boxes
|
|
|
|
PRInt32 count = line->GetChildCount();
|
|
|
|
line->SetChildCount(--count);
|
|
|
|
if (count > 0) {
|
|
|
|
line->MarkDirty();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Remove the line box
|
|
|
|
nsLineBox* lineBox = line;
|
|
|
|
if (searchingOverflowList) {
|
|
|
|
// Erase line, but avoid making the overflow line list empty
|
|
|
|
nsLineList* lineList = RemoveOverflowLines();
|
2009-12-25 13:59:08 +00:00
|
|
|
line = lineList->erase(line);
|
2007-07-26 04:03:29 +00:00
|
|
|
if (!lineList->empty()) {
|
|
|
|
nsresult rv = SetOverflowLines(lineList);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2009-09-29 01:23:33 +00:00
|
|
|
} else {
|
|
|
|
delete lineList;
|
2009-12-25 13:59:08 +00:00
|
|
|
// We just invalidated our iterators. Since we were in
|
|
|
|
// the overflow lines list, which is now empty, set them
|
|
|
|
// so we're at the end of the regular line list.
|
|
|
|
line_start = mLines.begin();
|
|
|
|
line_end = mLines.end();
|
|
|
|
line = line_end;
|
2007-07-26 04:03:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2009-12-25 13:59:08 +00:00
|
|
|
line = mLines.erase(line);
|
2007-07-26 04:03:29 +00:00
|
|
|
}
|
|
|
|
lineBox->Destroy(aPresContext->PresShell());
|
|
|
|
if (line != line_end) {
|
|
|
|
// Line disappeared, so tell next line it may have to change position
|
|
|
|
line->MarkPreviousMarginDirty();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ok, we're done
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
prevSibling = frame;
|
|
|
|
frame = frame->GetNextSibling();
|
|
|
|
}
|
|
|
|
++line;
|
2007-10-07 17:32:07 +00:00
|
|
|
TryAllLines(&line, &line_start, &line_end, &searchingOverflowList);
|
2009-09-29 19:47:05 +00:00
|
|
|
if (prevSibling && !prevSibling->GetNextSibling()) {
|
|
|
|
// We just switched to the overflow list. Null out prevSibling
|
|
|
|
prevSibling = nsnull;
|
|
|
|
}
|
2007-07-26 04:03:29 +00:00
|
|
|
}
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
1999-01-15 22:53:39 +00:00
|
|
|
void
|
2004-07-31 23:15:21 +00:00
|
|
|
nsBlockFrame::DeleteNextInFlowChild(nsPresContext* aPresContext,
|
2008-12-03 01:27:19 +00:00
|
|
|
nsIFrame* aNextInFlow,
|
|
|
|
PRBool aDeletingEmptyFrames)
|
1998-09-23 02:25:26 +00:00
|
|
|
{
|
2008-09-20 13:42:03 +00:00
|
|
|
NS_PRECONDITION(aNextInFlow->GetPrevInFlow(), "bad next-in-flow");
|
2002-09-24 22:13:20 +00:00
|
|
|
|
2009-08-31 18:25:37 +00:00
|
|
|
if (aNextInFlow->GetStateBits() &
|
|
|
|
(NS_FRAME_OUT_OF_FLOW | NS_FRAME_IS_OVERFLOW_CONTAINER)) {
|
2008-12-03 01:27:19 +00:00
|
|
|
nsContainerFrame::DeleteNextInFlowChild(aPresContext,
|
|
|
|
aNextInFlow, aDeletingEmptyFrames);
|
2007-07-26 04:03:29 +00:00
|
|
|
}
|
|
|
|
else {
|
2011-01-12 01:09:22 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (aDeletingEmptyFrames) {
|
|
|
|
nsLayoutUtils::AssertTreeOnlyEmptyNextInFlows(aNextInFlow);
|
|
|
|
}
|
|
|
|
#endif
|
2008-12-03 01:27:19 +00:00
|
|
|
DoRemoveFrame(aNextInFlow,
|
|
|
|
aDeletingEmptyFrames ? FRAMES_ARE_EMPTY : 0);
|
2007-07-26 04:03:29 +00:00
|
|
|
}
|
1998-10-02 21:50:53 +00:00
|
|
|
}
|
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
2003-10-13 21:51:02 +00:00
|
|
|
// Float support
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
2008-06-10 23:53:22 +00:00
|
|
|
nsRect
|
2009-04-08 20:52:36 +00:00
|
|
|
nsBlockFrame::AdjustFloatAvailableSpace(nsBlockReflowState& aState,
|
|
|
|
const nsRect& aFloatAvailableSpace,
|
|
|
|
nsIFrame* aFloatFrame)
|
1998-10-02 21:50:53 +00:00
|
|
|
{
|
2001-05-21 23:03:46 +00:00
|
|
|
// Compute the available width. By default, assume the width of the
|
2001-07-19 02:33:43 +00:00
|
|
|
// containing block.
|
2002-03-08 20:25:54 +00:00
|
|
|
nscoord availWidth;
|
2008-06-10 23:53:22 +00:00
|
|
|
const nsStyleDisplay* floatDisplay = aFloatFrame->GetStyleDisplay();
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE != floatDisplay->mDisplay ||
|
|
|
|
eCompatibility_NavQuirks != aState.mPresContext->CompatibilityMode() ) {
|
|
|
|
availWidth = aState.mContentArea.width;
|
2002-05-28 22:50:43 +00:00
|
|
|
}
|
|
|
|
else {
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
// This quirk matches the one in nsBlockReflowState::FlowAndPlaceFloat
|
|
|
|
// give tables only the available space
|
|
|
|
// if they can shrink we may not be constrained to place
|
|
|
|
// them in the next line
|
2009-04-08 20:52:36 +00:00
|
|
|
availWidth = aFloatAvailableSpace.width;
|
2002-03-08 20:25:54 +00:00
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
2005-09-30 21:54:12 +00:00
|
|
|
nscoord availHeight = NS_UNCONSTRAINEDSIZE == aState.mContentArea.height
|
2008-08-12 09:32:10 +00:00
|
|
|
? NS_UNCONSTRAINEDSIZE
|
2010-08-11 19:32:53 +00:00
|
|
|
: NS_MAX(0, aState.mContentArea.YMost() - aState.mY);
|
2001-05-21 23:03:46 +00:00
|
|
|
|
2008-08-12 09:32:10 +00:00
|
|
|
#ifdef DISABLE_FLOAT_BREAKING_IN_COLUMNS
|
|
|
|
if (availHeight != NS_UNCONSTRAINEDSIZE &&
|
|
|
|
nsLayoutUtils::GetClosestFrameOfType(this, nsGkAtoms::columnSetFrame)) {
|
|
|
|
// Tell the float it has unrestricted height, so it won't break.
|
|
|
|
// If the float doesn't actually fit in the column it will fail to be
|
|
|
|
// placed, and either move to the top of the next column or just
|
|
|
|
// overflow.
|
|
|
|
availHeight = NS_UNCONSTRAINEDSIZE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-08-11 19:32:53 +00:00
|
|
|
return nsRect(aState.mContentArea.x,
|
|
|
|
aState.mContentArea.y,
|
2008-06-10 23:53:22 +00:00
|
|
|
availWidth, availHeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord
|
|
|
|
nsBlockFrame::ComputeFloatWidth(nsBlockReflowState& aState,
|
2009-04-08 20:52:36 +00:00
|
|
|
const nsRect& aFloatAvailableSpace,
|
2009-08-31 18:25:35 +00:00
|
|
|
nsIFrame* aFloat)
|
2008-06-10 23:53:22 +00:00
|
|
|
{
|
2009-08-31 18:25:35 +00:00
|
|
|
NS_PRECONDITION(aFloat->GetStateBits() & NS_FRAME_OUT_OF_FLOW,
|
|
|
|
"aFloat must be an out-of-flow frame");
|
2008-06-10 23:53:22 +00:00
|
|
|
// Reflow the float.
|
2009-04-08 20:52:36 +00:00
|
|
|
nsRect availSpace = AdjustFloatAvailableSpace(aState, aFloatAvailableSpace,
|
2009-08-31 18:25:35 +00:00
|
|
|
aFloat);
|
2008-06-10 23:53:22 +00:00
|
|
|
|
2009-08-31 18:25:35 +00:00
|
|
|
nsHTMLReflowState floatRS(aState.mPresContext, aState.mReflowState, aFloat,
|
2008-06-10 23:53:22 +00:00
|
|
|
nsSize(availSpace.width, availSpace.height));
|
|
|
|
return floatRS.ComputedWidth() + floatRS.mComputedBorderPadding.LeftRight() +
|
|
|
|
floatRS.mComputedMargin.LeftRight();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsBlockFrame::ReflowFloat(nsBlockReflowState& aState,
|
2010-08-06 04:59:18 +00:00
|
|
|
const nsRect& aAdjustedAvailableSpace,
|
2009-08-31 18:25:35 +00:00
|
|
|
nsIFrame* aFloat,
|
2008-06-10 23:53:22 +00:00
|
|
|
nsMargin& aFloatMargin,
|
2010-08-06 04:59:19 +00:00
|
|
|
PRBool aFloatPushedDown,
|
2008-06-10 23:53:22 +00:00
|
|
|
nsReflowStatus& aReflowStatus)
|
|
|
|
{
|
2009-08-31 18:25:35 +00:00
|
|
|
NS_PRECONDITION(aFloat->GetStateBits() & NS_FRAME_OUT_OF_FLOW,
|
|
|
|
"aFloat must be an out-of-flow frame");
|
2008-06-10 23:53:22 +00:00
|
|
|
// Reflow the float.
|
|
|
|
aReflowStatus = NS_FRAME_COMPLETE;
|
|
|
|
|
|
|
|
#ifdef NOISY_FLOAT
|
|
|
|
printf("Reflow Float %p in parent %p, availSpace(%d,%d,%d,%d)\n",
|
2009-08-31 18:25:35 +00:00
|
|
|
aFloat, this,
|
2009-04-08 20:52:36 +00:00
|
|
|
aFloatAvailableSpace.x, aFloatAvailableSpace.y,
|
|
|
|
aFloatAvailableSpace.width, aFloatAvailableSpace.height
|
2008-06-10 23:53:22 +00:00
|
|
|
);
|
|
|
|
#endif
|
|
|
|
|
2009-08-31 18:25:35 +00:00
|
|
|
nsHTMLReflowState floatRS(aState.mPresContext, aState.mReflowState, aFloat,
|
2010-08-06 04:59:18 +00:00
|
|
|
nsSize(aAdjustedAvailableSpace.width,
|
|
|
|
aAdjustedAvailableSpace.height));
|
2004-11-25 14:51:00 +00:00
|
|
|
|
2010-08-06 04:59:19 +00:00
|
|
|
// Normally the mIsTopOfPage state is copied from the parent reflow
|
|
|
|
// state. However, when reflowing a float, if we've placed other
|
|
|
|
// floats that force this float *down* or *narrower*, we should unset
|
|
|
|
// the mIsTopOfPage state.
|
|
|
|
// FIXME: This is somewhat redundant with the |isAdjacentWithTop|
|
|
|
|
// variable below, which has the exact same effect. Perhaps it should
|
|
|
|
// be merged into that, except that the test for narrowing here is not
|
|
|
|
// about adjacency with the top, so it seems misleading.
|
|
|
|
if (floatRS.mFlags.mIsTopOfPage &&
|
|
|
|
(aFloatPushedDown ||
|
|
|
|
aAdjustedAvailableSpace.width != aState.mContentArea.width)) {
|
|
|
|
floatRS.mFlags.mIsTopOfPage = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Setup a block reflow context to reflow the float.
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsBlockReflowContext brc(aState.mPresContext, aState.mReflowState);
|
2001-05-21 23:03:46 +00:00
|
|
|
|
2003-10-13 21:51:02 +00:00
|
|
|
// Reflow the float
|
2001-05-21 23:03:46 +00:00
|
|
|
PRBool isAdjacentWithTop = aState.IsAdjacentWithTop();
|
|
|
|
|
2004-11-25 14:51:00 +00:00
|
|
|
nsIFrame* clearanceFrame = nsnull;
|
|
|
|
nsresult rv;
|
|
|
|
do {
|
|
|
|
nsCollapsingMargin margin;
|
|
|
|
PRBool mayNeedRetry = PR_FALSE;
|
2005-03-23 03:35:08 +00:00
|
|
|
floatRS.mDiscoveredClearance = nsnull;
|
|
|
|
// Only first in flow gets a top margin.
|
2009-08-31 18:25:35 +00:00
|
|
|
if (!aFloat->GetPrevInFlow()) {
|
2005-03-23 03:35:08 +00:00
|
|
|
nsBlockReflowContext::ComputeCollapsedTopMargin(floatRS, &margin,
|
|
|
|
clearanceFrame, &mayNeedRetry);
|
2004-11-25 14:51:00 +00:00
|
|
|
|
2005-03-23 03:35:08 +00:00
|
|
|
if (mayNeedRetry && !clearanceFrame) {
|
|
|
|
floatRS.mDiscoveredClearance = &clearanceFrame;
|
2009-01-05 00:39:54 +00:00
|
|
|
// We don't need to push the float manager state because the the block has its own
|
|
|
|
// float manager that will be destroyed and recreated
|
2005-03-23 03:35:08 +00:00
|
|
|
}
|
2004-11-25 14:51:00 +00:00
|
|
|
}
|
|
|
|
|
2010-08-06 04:59:18 +00:00
|
|
|
rv = brc.ReflowBlock(aAdjustedAvailableSpace, PR_TRUE, margin,
|
2004-11-25 14:51:00 +00:00
|
|
|
0, isAdjacentWithTop,
|
2008-04-18 07:40:35 +00:00
|
|
|
nsnull, floatRS,
|
2007-10-02 05:57:45 +00:00
|
|
|
aReflowStatus, aState);
|
2004-11-25 14:51:00 +00:00
|
|
|
} while (NS_SUCCEEDED(rv) && clearanceFrame);
|
|
|
|
|
2003-10-13 21:51:02 +00:00
|
|
|
// An incomplete reflow status means we should split the float
|
2002-06-14 14:30:33 +00:00
|
|
|
// if the height is constrained (bug 145305).
|
2008-06-10 23:53:22 +00:00
|
|
|
if (NS_FRAME_IS_NOT_COMPLETE(aReflowStatus) &&
|
2010-08-06 04:59:18 +00:00
|
|
|
(NS_UNCONSTRAINEDSIZE == aAdjustedAvailableSpace.height))
|
2002-06-14 14:30:33 +00:00
|
|
|
aReflowStatus = NS_FRAME_COMPLETE;
|
2007-07-26 04:03:29 +00:00
|
|
|
|
2005-03-23 03:35:08 +00:00
|
|
|
if (aReflowStatus & NS_FRAME_REFLOW_NEXTINFLOW) {
|
|
|
|
aState.mReflowStatus |= NS_FRAME_REFLOW_NEXTINFLOW;
|
|
|
|
}
|
2004-10-08 12:17:10 +00:00
|
|
|
|
2009-08-31 18:25:35 +00:00
|
|
|
if (aFloat->GetType() == nsGkAtoms::letterFrame) {
|
2004-09-29 02:18:25 +00:00
|
|
|
// We never split floating first letters; an incomplete state for
|
|
|
|
// such frames simply means that there is more content to be
|
|
|
|
// reflowed on the line.
|
|
|
|
if (NS_FRAME_IS_NOT_COMPLETE(aReflowStatus))
|
|
|
|
aReflowStatus = NS_FRAME_COMPLETE;
|
|
|
|
}
|
|
|
|
|
1999-04-01 01:37:36 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
1998-11-11 03:55:55 +00:00
|
|
|
}
|
1999-04-01 01:37:36 +00:00
|
|
|
|
|
|
|
// Capture the margin information for the caller
|
2009-07-15 05:19:31 +00:00
|
|
|
aFloatMargin = floatRS.mComputedMargin; // float margins don't collapse
|
1999-04-01 01:37:36 +00:00
|
|
|
|
|
|
|
const nsHTMLReflowMetrics& metrics = brc.GetMetrics();
|
2001-05-21 23:03:46 +00:00
|
|
|
|
1999-11-30 05:09:08 +00:00
|
|
|
// Set the rect, make sure the view is properly sized and positioned,
|
|
|
|
// and tell the frame we're done reflowing it
|
2001-10-25 01:08:40 +00:00
|
|
|
// XXXldb This seems like the wrong place to be doing this -- shouldn't
|
2003-10-13 21:51:02 +00:00
|
|
|
// we be doing this in nsBlockReflowState::FlowAndPlaceFloat after
|
|
|
|
// we've positioned the float, and shouldn't we be doing the equivalent
|
2001-10-25 01:08:40 +00:00
|
|
|
// of |::PlaceFrameView| here?
|
2009-08-31 18:25:35 +00:00
|
|
|
aFloat->SetSize(nsSize(metrics.width, metrics.height));
|
|
|
|
if (aFloat->HasView()) {
|
|
|
|
nsContainerFrame::SyncFrameViewAfterReflow(aState.mPresContext, aFloat,
|
|
|
|
aFloat->GetView(),
|
2010-10-07 04:25:45 +00:00
|
|
|
metrics.VisualOverflow(),
|
1999-11-30 05:09:08 +00:00
|
|
|
NS_FRAME_NO_MOVE_VIEW);
|
|
|
|
}
|
2003-10-13 21:51:02 +00:00
|
|
|
// Pass floatRS so the frame hierarchy can be used (redoFloatRS has the same hierarchy)
|
2009-08-31 18:25:35 +00:00
|
|
|
aFloat->DidReflow(aState.mPresContext, &floatRS,
|
2003-10-13 21:51:02 +00:00
|
|
|
NS_FRAME_REFLOW_FINISHED);
|
1999-10-21 20:43:48 +00:00
|
|
|
|
2003-10-13 21:51:02 +00:00
|
|
|
#ifdef NOISY_FLOAT
|
|
|
|
printf("end ReflowFloat %p, sized to %d,%d\n",
|
2009-08-31 18:25:35 +00:00
|
|
|
aFloat, metrics.width, metrics.height);
|
2000-06-11 22:14:33 +00:00
|
|
|
#endif
|
2002-07-17 01:48:56 +00:00
|
|
|
|
1999-04-01 01:37:36 +00:00
|
|
|
return NS_OK;
|
1998-11-11 03:55:55 +00:00
|
|
|
}
|
|
|
|
|
2009-08-31 18:25:36 +00:00
|
|
|
PRUint8
|
|
|
|
nsBlockFrame::FindTrailingClear()
|
|
|
|
{
|
|
|
|
// find the break type of the last line
|
|
|
|
for (nsIFrame* b = this; b; b = b->GetPrevInFlow()) {
|
|
|
|
nsBlockFrame* block = static_cast<nsBlockFrame*>(b);
|
|
|
|
line_iterator endLine = block->end_lines();
|
|
|
|
if (endLine != block->begin_lines()) {
|
|
|
|
--endLine;
|
|
|
|
return endLine->GetBreakTypeAfter();
|
|
|
|
}
|
|
|
|
}
|
2009-09-04 21:07:30 +00:00
|
|
|
return NS_STYLE_CLEAR_NONE;
|
2009-08-31 18:25:36 +00:00
|
|
|
}
|
|
|
|
|
2009-08-31 18:25:36 +00:00
|
|
|
nsresult
|
2010-08-06 04:59:20 +00:00
|
|
|
nsBlockFrame::ReflowPushedFloats(nsBlockReflowState& aState,
|
2010-10-07 04:25:45 +00:00
|
|
|
nsOverflowAreas& aOverflowAreas,
|
|
|
|
nsReflowStatus& aStatus)
|
2009-08-31 18:25:36 +00:00
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
2010-08-06 04:59:19 +00:00
|
|
|
for (nsIFrame* f = mFloats.FirstChild(), *next;
|
2010-08-06 04:59:20 +00:00
|
|
|
f && (f->GetStateBits() & NS_FRAME_IS_PUSHED_FLOAT);
|
2010-08-06 04:59:19 +00:00
|
|
|
f = next) {
|
|
|
|
// save next sibling now, since reflowing could push the entire
|
|
|
|
// float, changing its siblings
|
|
|
|
next = f->GetNextSibling();
|
|
|
|
|
2011-01-12 01:09:21 +00:00
|
|
|
// When we push a first-continuation float in a non-initial reflow,
|
|
|
|
// it's possible that we end up with two continuations with the same
|
|
|
|
// parent. This happens if, on the previous reflow of the block or
|
|
|
|
// a previous reflow of the line containing the block, the float was
|
|
|
|
// split between continuations A and B of the parent, but on the
|
|
|
|
// current reflow, none of the float can fit in A.
|
|
|
|
//
|
|
|
|
// When this happens, we might even have the two continuations
|
|
|
|
// out-of-order due to the management of the pushed floats. In
|
|
|
|
// particular, if the float's placeholder was in a pushed line that
|
|
|
|
// we reflowed before it was pushed, and we split the float during
|
|
|
|
// that reflow, we might have the continuation of the float before
|
|
|
|
// the float itself. (In the general case, however, it's correct
|
|
|
|
// for floats in the pushed floats list to come before floats
|
|
|
|
// anchored in pushed lines; however, in this case it's wrong. We
|
|
|
|
// should probably find a way to fix it somehow, since it leads to
|
|
|
|
// incorrect layout in some cases.)
|
|
|
|
//
|
|
|
|
// When we have these out-of-order continuations, we might hit the
|
|
|
|
// next-continuation before the previous-continuation. When that
|
|
|
|
// happens, just push it. When we reflow the next continuation,
|
|
|
|
// we'll either pull all of its content back and destroy it (by
|
|
|
|
// calling DeleteNextInFlowChild), or nsBlockFrame::SplitFloat will
|
|
|
|
// pull it out of its current position and push it again (and
|
|
|
|
// potentially repeat this cycle for the next continuation, although
|
|
|
|
// hopefully then they'll be in the right order).
|
|
|
|
//
|
|
|
|
// We should also need this code for the in-order case if the first
|
|
|
|
// continuation of a float gets moved across more than one
|
|
|
|
// continuation of the containing block. In this case we'd manage
|
|
|
|
// to push the second continuation without this check, but not the
|
|
|
|
// third and later.
|
|
|
|
nsIFrame *prevContinuation = f->GetPrevContinuation();
|
|
|
|
if (prevContinuation && prevContinuation->GetParent() == f->GetParent()) {
|
|
|
|
mFloats.RemoveFrame(f);
|
|
|
|
aState.AppendPushedFloat(f);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2009-08-31 18:25:36 +00:00
|
|
|
if (NS_SUBTREE_DIRTY(f) || aState.mReflowState.ShouldReflowAllKids()) {
|
|
|
|
// Cache old bounds
|
|
|
|
nsRect oldRect = f->GetRect();
|
2010-10-07 04:25:47 +00:00
|
|
|
nsRect oldOverflow = f->GetVisualOverflowRect();
|
2009-08-31 18:25:36 +00:00
|
|
|
|
|
|
|
// Reflow
|
2010-08-06 04:59:20 +00:00
|
|
|
aState.FlowAndPlaceFloat(f);
|
2009-08-31 18:25:36 +00:00
|
|
|
|
|
|
|
// Invalidate if there was a position or size change
|
|
|
|
nsRect rect = f->GetRect();
|
2011-04-19 03:07:23 +00:00
|
|
|
if (!rect.IsEqualInterior(oldRect)) {
|
2009-08-31 18:25:36 +00:00
|
|
|
nsRect dirtyRect = oldOverflow;
|
|
|
|
dirtyRect.MoveBy(oldRect.x, oldRect.y);
|
|
|
|
Invalidate(dirtyRect);
|
|
|
|
|
2010-10-07 04:25:47 +00:00
|
|
|
dirtyRect = f->GetVisualOverflowRect();
|
2009-08-31 18:25:36 +00:00
|
|
|
dirtyRect.MoveBy(rect.x, rect.y);
|
|
|
|
Invalidate(dirtyRect);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Just reload the float region into the space manager
|
|
|
|
nsRect region = nsFloatManager::GetRegionFor(f);
|
|
|
|
aState.mFloatManager->AddFloat(f, region);
|
|
|
|
if (f->GetNextInFlow())
|
|
|
|
NS_MergeReflowStatusInto(&aStatus, NS_FRAME_OVERFLOW_INCOMPLETE);
|
|
|
|
}
|
|
|
|
|
2010-10-07 04:25:45 +00:00
|
|
|
ConsiderChildOverflow(aOverflowAreas, f);
|
2009-08-31 18:25:36 +00:00
|
|
|
}
|
|
|
|
|
2009-08-31 18:25:36 +00:00
|
|
|
// If there are continued floats, then we may need to continue BR clearance
|
|
|
|
if (0 != aState.ClearFloats(0, NS_STYLE_CLEAR_LEFT_AND_RIGHT)) {
|
|
|
|
aState.mFloatBreakType = static_cast<nsBlockFrame*>(GetPrevInFlow())
|
|
|
|
->FindTrailingClear();
|
|
|
|
}
|
|
|
|
|
2009-08-31 18:25:36 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBlockFrame::RecoverFloats(nsFloatManager& aFloatManager)
|
|
|
|
{
|
|
|
|
// Recover our own floats
|
2010-08-06 04:59:20 +00:00
|
|
|
nsIFrame* stop = nsnull; // Stop before we reach pushed floats that
|
2009-08-31 18:25:36 +00:00
|
|
|
// belong to our next-in-flow
|
|
|
|
for (nsIFrame* f = mFloats.FirstChild(); f && f != stop; f = f->GetNextSibling()) {
|
|
|
|
nsRect region = nsFloatManager::GetRegionFor(f);
|
|
|
|
aFloatManager.AddFloat(f, region);
|
|
|
|
if (!stop && f->GetNextInFlow())
|
|
|
|
stop = f->GetNextInFlow();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Recurse into our overflow container children
|
|
|
|
for (nsIFrame* oc = GetFirstChild(nsGkAtoms::overflowContainersList);
|
|
|
|
oc; oc = oc->GetNextSibling()) {
|
|
|
|
RecoverFloatsFor(oc, aFloatManager);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Recurse into our normal children
|
|
|
|
for (nsBlockFrame::line_iterator line = begin_lines(); line != end_lines(); ++line) {
|
|
|
|
if (line->IsBlock()) {
|
|
|
|
RecoverFloatsFor(line->mFirstChild, aFloatManager);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBlockFrame::RecoverFloatsFor(nsIFrame* aFrame,
|
|
|
|
nsFloatManager& aFloatManager)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(aFrame, "null frame");
|
|
|
|
// Only blocks have floats
|
|
|
|
nsBlockFrame* block = nsLayoutUtils::GetAsBlock(aFrame);
|
|
|
|
// Don't recover any state inside a block that has its own space manager
|
|
|
|
// (we don't currently have any blocks like this, though, thanks to our
|
|
|
|
// use of extra frames for 'overflow')
|
|
|
|
if (block && !nsBlockFrame::BlockNeedsFloatManager(block)) {
|
|
|
|
// If the element is relatively positioned, then adjust x and y
|
|
|
|
// accordingly so that we consider relatively positioned frames
|
|
|
|
// at their original position.
|
|
|
|
nsPoint pos = block->GetPosition() - block->GetRelativeOffset();
|
|
|
|
aFloatManager.Translate(pos.x, pos.y);
|
|
|
|
block->RecoverFloats(aFloatManager);
|
|
|
|
aFloatManager.Translate(-pos.x, -pos.y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// Painting, event handling
|
1998-06-24 17:52:42 +00:00
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
PRIntn
|
1999-02-09 17:31:33 +00:00
|
|
|
nsBlockFrame::GetSkipSides() const
|
1998-12-05 16:02:08 +00:00
|
|
|
{
|
2007-10-02 05:57:45 +00:00
|
|
|
if (IS_TRUE_OVERFLOW_CONTAINER(this))
|
2007-07-26 04:03:29 +00:00
|
|
|
return (1 << NS_SIDE_TOP) | (1 << NS_SIDE_BOTTOM);
|
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
PRIntn skip = 0;
|
2007-07-26 04:03:29 +00:00
|
|
|
if (GetPrevInFlow()) {
|
1998-12-05 16:02:08 +00:00
|
|
|
skip |= 1 << NS_SIDE_TOP;
|
1998-09-29 22:32:56 +00:00
|
|
|
}
|
2007-07-26 04:03:29 +00:00
|
|
|
nsIFrame* nif = GetNextInFlow();
|
2007-10-02 05:57:45 +00:00
|
|
|
if (nif && !IS_TRUE_OVERFLOW_CONTAINER(nif)) {
|
1998-12-05 16:02:08 +00:00
|
|
|
skip |= 1 << NS_SIDE_BOTTOM;
|
1998-11-11 03:55:55 +00:00
|
|
|
}
|
1998-12-05 16:02:08 +00:00
|
|
|
return skip;
|
|
|
|
}
|
1998-09-29 22:32:56 +00:00
|
|
|
|
1999-10-19 23:04:19 +00:00
|
|
|
#ifdef DEBUG
|
2010-10-07 04:25:45 +00:00
|
|
|
static void ComputeVisualOverflowArea(nsLineList& aLines,
|
|
|
|
nscoord aWidth, nscoord aHeight,
|
|
|
|
nsRect& aResult)
|
1999-03-22 22:42:30 +00:00
|
|
|
{
|
1999-05-13 00:55:38 +00:00
|
|
|
nscoord xa = 0, ya = 0, xb = aWidth, yb = aHeight;
|
2001-10-25 01:08:40 +00:00
|
|
|
for (nsLineList::iterator line = aLines.begin(), line_end = aLines.end();
|
|
|
|
line != line_end;
|
|
|
|
++line) {
|
1999-03-22 22:42:30 +00:00
|
|
|
// Compute min and max x/y values for the reflowed frame's
|
|
|
|
// combined areas
|
2010-10-07 04:25:45 +00:00
|
|
|
nsRect visOverflow(line->GetVisualOverflowArea());
|
|
|
|
nscoord x = visOverflow.x;
|
|
|
|
nscoord y = visOverflow.y;
|
|
|
|
nscoord xmost = x + visOverflow.width;
|
|
|
|
nscoord ymost = y + visOverflow.height;
|
1999-05-13 00:55:38 +00:00
|
|
|
if (x < xa) {
|
|
|
|
xa = x;
|
1999-03-22 22:42:30 +00:00
|
|
|
}
|
1999-05-13 00:55:38 +00:00
|
|
|
if (xmost > xb) {
|
|
|
|
xb = xmost;
|
1999-03-22 22:42:30 +00:00
|
|
|
}
|
1999-05-13 00:55:38 +00:00
|
|
|
if (y < ya) {
|
|
|
|
ya = y;
|
1999-03-22 22:42:30 +00:00
|
|
|
}
|
1999-05-13 00:55:38 +00:00
|
|
|
if (ymost > yb) {
|
|
|
|
yb = ymost;
|
1999-03-22 22:42:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-05-13 00:55:38 +00:00
|
|
|
aResult.x = xa;
|
|
|
|
aResult.y = ya;
|
|
|
|
aResult.width = xb - xa;
|
|
|
|
aResult.height = yb - ya;
|
1999-03-22 22:42:30 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
PRBool
|
|
|
|
nsBlockFrame::IsVisibleInSelection(nsISelection* aSelection)
|
2001-03-08 02:46:44 +00:00
|
|
|
{
|
2006-01-26 02:29:17 +00:00
|
|
|
nsCOMPtr<nsIDOMHTMLHtmlElement> html(do_QueryInterface(mContent));
|
|
|
|
nsCOMPtr<nsIDOMHTMLBodyElement> body(do_QueryInterface(mContent));
|
|
|
|
if (html || body)
|
|
|
|
return PR_TRUE;
|
2001-03-08 02:46:44 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(mContent));
|
|
|
|
PRBool visible;
|
|
|
|
nsresult rv = aSelection->ContainsNode(node, PR_TRUE, &visible);
|
|
|
|
return NS_SUCCEEDED(rv) && visible;
|
2001-03-08 02:46:44 +00:00
|
|
|
}
|
|
|
|
|
2002-12-11 04:00:18 +00:00
|
|
|
/* virtual */ void
|
2008-06-12 22:02:32 +00:00
|
|
|
nsBlockFrame::PaintTextDecorationLine(gfxContext* aCtx,
|
2008-03-13 02:36:58 +00:00
|
|
|
const nsPoint& aPt,
|
2006-01-26 02:29:17 +00:00
|
|
|
nsLineBox* aLine,
|
|
|
|
nscolor aColor,
|
2011-03-31 12:27:03 +00:00
|
|
|
PRUint8 aStyle,
|
2008-03-13 02:36:58 +00:00
|
|
|
gfxFloat aOffset,
|
|
|
|
gfxFloat aAscent,
|
|
|
|
gfxFloat aSize,
|
2007-08-06 08:15:00 +00:00
|
|
|
const PRUint8 aDecoration)
|
2002-12-11 04:00:18 +00:00
|
|
|
{
|
2006-01-26 02:29:17 +00:00
|
|
|
NS_ASSERTION(!aLine->IsBlock(), "Why did we ask for decorations on a block?");
|
2001-04-25 19:52:49 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
nscoord start = aLine->mBounds.x;
|
|
|
|
nscoord width = aLine->mBounds.width;
|
2001-03-08 02:46:44 +00:00
|
|
|
|
2009-09-18 18:18:35 +00:00
|
|
|
AdjustForTextIndent(aLine, start, width);
|
|
|
|
|
|
|
|
// Only paint if we have a positive width
|
|
|
|
if (width > 0) {
|
|
|
|
gfxPoint pt(PresContext()->AppUnitsToGfxUnits(start + aPt.x),
|
|
|
|
PresContext()->AppUnitsToGfxUnits(aLine->mBounds.y + aPt.y));
|
|
|
|
gfxSize size(PresContext()->AppUnitsToGfxUnits(width), aSize);
|
|
|
|
nsCSSRendering::PaintDecorationLine(
|
|
|
|
aCtx, aColor, pt, size,
|
|
|
|
PresContext()->AppUnitsToGfxUnits(aLine->GetAscent()),
|
2011-03-31 12:27:03 +00:00
|
|
|
aOffset, aDecoration, aStyle);
|
2009-09-18 18:18:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*virtual*/ void
|
|
|
|
nsBlockFrame::AdjustForTextIndent(const nsLineBox* aLine,
|
|
|
|
nscoord& start,
|
|
|
|
nscoord& width)
|
|
|
|
{
|
2007-11-15 06:12:17 +00:00
|
|
|
if (!GetPrevContinuation() && aLine == begin_lines().get()) {
|
2006-01-26 02:29:17 +00:00
|
|
|
// Adjust for the text-indent. See similar code in
|
|
|
|
// nsLineLayout::BeginLineReflow.
|
2010-08-31 16:05:12 +00:00
|
|
|
const nsStyleCoord &textIndent = GetStyleText()->mTextIndent;
|
|
|
|
nscoord pctBasis = 0;
|
|
|
|
if (textIndent.HasPercent()) {
|
|
|
|
// Only work out the percentage basis if we need to.
|
2006-01-26 02:29:17 +00:00
|
|
|
// It's a percentage of the containing block width.
|
|
|
|
nsIFrame* containingBlock =
|
|
|
|
nsHTMLReflowState::GetContainingBlockFor(this);
|
|
|
|
NS_ASSERTION(containingBlock, "Must have containing block!");
|
2010-08-31 16:05:12 +00:00
|
|
|
pctBasis = containingBlock->GetContentRect().width;
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
2010-08-31 16:05:12 +00:00
|
|
|
nscoord indent = nsRuleNode::ComputeCoordPercentCalc(textIndent, pctBasis);
|
2006-01-26 02:29:17 +00:00
|
|
|
|
|
|
|
// Adjust the start position and the width of the decoration by the
|
|
|
|
// value of the indent. Note that indent can be negative; that's OK.
|
|
|
|
// It'll just increase the width (which can also happen to be
|
|
|
|
// negative!).
|
|
|
|
start += indent;
|
|
|
|
width -= indent;
|
1999-10-08 04:45:12 +00:00
|
|
|
}
|
1998-12-05 16:02:08 +00:00
|
|
|
}
|
1998-06-25 16:33:10 +00:00
|
|
|
|
2004-03-07 18:04:24 +00:00
|
|
|
#ifdef DEBUG
|
2006-01-26 02:29:17 +00:00
|
|
|
static void DebugOutputDrawLine(PRInt32 aDepth, nsLineBox* aLine, PRBool aDrawn) {
|
|
|
|
if (nsBlockFrame::gNoisyDamageRepair) {
|
2004-03-07 18:04:24 +00:00
|
|
|
nsFrame::IndentBy(stdout, aDepth+1);
|
2010-10-07 04:25:45 +00:00
|
|
|
nsRect lineArea = aLine->GetVisualOverflowArea();
|
2004-03-07 18:04:24 +00:00
|
|
|
printf("%s line=%p bounds=%d,%d,%d,%d ca=%d,%d,%d,%d\n",
|
|
|
|
aDrawn ? "draw" : "skip",
|
2007-07-08 07:08:04 +00:00
|
|
|
static_cast<void*>(aLine),
|
2004-03-07 18:04:24 +00:00
|
|
|
aLine->mBounds.x, aLine->mBounds.y,
|
|
|
|
aLine->mBounds.width, aLine->mBounds.height,
|
|
|
|
lineArea.x, lineArea.y,
|
|
|
|
lineArea.width, lineArea.height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
static nsresult
|
|
|
|
DisplayLine(nsDisplayListBuilder* aBuilder, const nsRect& aLineArea,
|
|
|
|
const nsRect& aDirtyRect, nsBlockFrame::line_iterator& aLine,
|
|
|
|
PRInt32 aDepth, PRInt32& aDrawnLines, const nsDisplayListSet& aLists,
|
|
|
|
nsBlockFrame* aFrame) {
|
2004-03-07 18:04:24 +00:00
|
|
|
// If the line's combined area (which includes child frames that
|
|
|
|
// stick outside of the line's bounding box or our bounding box)
|
|
|
|
// intersects the dirty rect then paint the line.
|
2006-01-26 02:29:17 +00:00
|
|
|
PRBool intersect = aLineArea.Intersects(aDirtyRect);
|
2004-03-07 18:04:24 +00:00
|
|
|
#ifdef DEBUG
|
2006-01-26 02:29:17 +00:00
|
|
|
if (nsBlockFrame::gLamePaintMetrics) {
|
|
|
|
aDrawnLines++;
|
2004-03-07 18:04:24 +00:00
|
|
|
}
|
2006-01-26 02:29:17 +00:00
|
|
|
DebugOutputDrawLine(aDepth, aLine.get(), intersect);
|
|
|
|
#endif
|
2006-04-27 02:45:03 +00:00
|
|
|
// The line might contain a placeholder for a visible out-of-flow, in which
|
|
|
|
// case we need to descend into it. If there is such a placeholder, we will
|
|
|
|
// have NS_FRAME_FORCE_DISPLAY_LIST_DESCEND_INTO set.
|
2010-12-07 13:54:50 +00:00
|
|
|
// In particular, we really want to check ShouldDescendIntoFrame()
|
|
|
|
// on all the frames on the line, but that might be expensive. So
|
|
|
|
// we approximate it by checking it on aFrame; if it's true for any
|
|
|
|
// frame in the line, it's also true for aFrame.
|
|
|
|
if (!intersect && !aBuilder->ShouldDescendIntoFrame(aFrame))
|
2006-01-26 02:29:17 +00:00
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
nsresult rv;
|
|
|
|
nsDisplayList aboveTextDecorations;
|
|
|
|
PRBool lineInline = aLine->IsInline();
|
|
|
|
if (lineInline) {
|
|
|
|
// Display the text-decoration for the hypothetical anonymous inline box
|
|
|
|
// that wraps these inlines
|
|
|
|
rv = aFrame->DisplayTextDecorations(aBuilder, aLists.Content(),
|
|
|
|
&aboveTextDecorations, aLine);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Block-level child backgrounds go on the blockBorderBackgrounds list ...
|
|
|
|
// Inline-level child backgrounds go on the regular child content list.
|
|
|
|
nsDisplayListSet childLists(aLists,
|
|
|
|
lineInline ? aLists.Content() : aLists.BlockBorderBackgrounds());
|
|
|
|
nsIFrame* kid = aLine->mFirstChild;
|
|
|
|
PRInt32 n = aLine->GetChildCount();
|
|
|
|
while (--n >= 0) {
|
|
|
|
rv = aFrame->BuildDisplayListForChild(aBuilder, kid, aDirtyRect, childLists,
|
|
|
|
lineInline ? nsIFrame::DISPLAY_CHILD_INLINE : 0);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
kid = kid->GetNextSibling();
|
2004-03-07 18:04:24 +00:00
|
|
|
}
|
2006-01-26 02:29:17 +00:00
|
|
|
|
|
|
|
aLists.Content()->AppendToTop(&aboveTextDecorations);
|
|
|
|
return NS_OK;
|
2004-03-07 18:04:24 +00:00
|
|
|
}
|
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBlockFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
1998-12-05 16:02:08 +00:00
|
|
|
{
|
2004-03-07 18:04:24 +00:00
|
|
|
PRInt32 drawnLines; // Will only be used if set (gLamePaintMetrics).
|
1999-03-22 20:46:09 +00:00
|
|
|
PRInt32 depth = 0;
|
2004-03-07 18:50:11 +00:00
|
|
|
#ifdef DEBUG
|
1999-10-19 23:04:19 +00:00
|
|
|
if (gNoisyDamageRepair) {
|
|
|
|
depth = GetDepth();
|
2006-01-26 02:29:17 +00:00
|
|
|
nsRect ca;
|
2010-10-07 04:25:45 +00:00
|
|
|
::ComputeVisualOverflowArea(mLines, mRect.width, mRect.height, ca);
|
2006-01-26 02:29:17 +00:00
|
|
|
nsFrame::IndentBy(stdout, depth);
|
|
|
|
ListTag(stdout);
|
|
|
|
printf(": bounds=%d,%d,%d,%d dirty(absolute)=%d,%d,%d,%d ca=%d,%d,%d,%d\n",
|
|
|
|
mRect.x, mRect.y, mRect.width, mRect.height,
|
|
|
|
aDirtyRect.x, aDirtyRect.y, aDirtyRect.width, aDirtyRect.height,
|
|
|
|
ca.x, ca.y, ca.width, ca.height);
|
1999-10-19 23:04:19 +00:00
|
|
|
}
|
2000-11-27 23:23:28 +00:00
|
|
|
PRTime start = LL_ZERO; // Initialize these variables to silence the compiler.
|
1999-10-19 23:04:19 +00:00
|
|
|
if (gLamePaintMetrics) {
|
|
|
|
start = PR_Now();
|
|
|
|
drawnLines = 0;
|
1999-03-22 20:46:09 +00:00
|
|
|
}
|
|
|
|
#endif
|
1999-10-19 23:04:19 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
DisplayBorderBackgroundOutline(aBuilder, aLists);
|
2007-07-26 04:03:29 +00:00
|
|
|
|
|
|
|
if (GetPrevInFlow()) {
|
|
|
|
DisplayOverflowContainers(aBuilder, aDirtyRect, aLists);
|
2009-08-31 18:25:36 +00:00
|
|
|
for (nsIFrame* f = mFloats.FirstChild(); f; f = f->GetNextSibling()) {
|
2010-08-06 04:59:20 +00:00
|
|
|
if (f->GetStateBits() & NS_FRAME_IS_PUSHED_FLOAT)
|
2009-08-31 18:25:36 +00:00
|
|
|
BuildDisplayListForChild(aBuilder, f, aDirtyRect, aLists);
|
|
|
|
}
|
2007-07-26 04:03:29 +00:00
|
|
|
}
|
|
|
|
|
2009-07-28 12:51:09 +00:00
|
|
|
aBuilder->MarkFramesForDisplayList(this, mFloats, aDirtyRect);
|
2006-01-26 02:29:17 +00:00
|
|
|
|
2006-04-27 02:45:03 +00:00
|
|
|
// Don't use the line cursor if we might have a descendant placeholder ...
|
|
|
|
// it might skip lines that contain placeholders but don't themselves
|
|
|
|
// intersect with the dirty area.
|
2010-12-07 13:54:50 +00:00
|
|
|
// In particular, we really want to check ShouldDescendIntoFrame()
|
|
|
|
// on all our child frames, but that might be expensive. So we
|
|
|
|
// approximate it by checking it on |this|; if it's true for any
|
|
|
|
// frame in our child list, it's also true for |this|.
|
|
|
|
nsLineBox* cursor = aBuilder->ShouldDescendIntoFrame(this) ?
|
|
|
|
nsnull : GetFirstLineContaining(aDirtyRect.y);
|
2004-03-07 18:04:24 +00:00
|
|
|
line_iterator line_end = end_lines();
|
2006-01-26 02:29:17 +00:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
2004-03-07 18:04:24 +00:00
|
|
|
if (cursor) {
|
|
|
|
for (line_iterator line = mLines.begin(cursor);
|
|
|
|
line != line_end;
|
|
|
|
++line) {
|
2010-10-07 04:25:45 +00:00
|
|
|
nsRect lineArea = line->GetVisualOverflowArea();
|
2004-03-07 18:04:24 +00:00
|
|
|
if (!lineArea.IsEmpty()) {
|
|
|
|
// Because we have a cursor, the combinedArea.ys are non-decreasing.
|
|
|
|
// Once we've passed aDirtyRect.YMost(), we can never see it again.
|
|
|
|
if (lineArea.y >= aDirtyRect.YMost()) {
|
|
|
|
break;
|
|
|
|
}
|
2006-01-26 02:29:17 +00:00
|
|
|
rv = DisplayLine(aBuilder, lineArea, aDirtyRect, line, depth, drawnLines,
|
|
|
|
aLists, this);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
break;
|
1998-12-05 16:02:08 +00:00
|
|
|
}
|
|
|
|
}
|
2004-03-07 18:04:24 +00:00
|
|
|
} else {
|
|
|
|
PRBool nonDecreasingYs = PR_TRUE;
|
|
|
|
PRInt32 lineCount = 0;
|
|
|
|
nscoord lastY = PR_INT32_MIN;
|
|
|
|
nscoord lastYMost = PR_INT32_MIN;
|
|
|
|
for (line_iterator line = begin_lines();
|
|
|
|
line != line_end;
|
|
|
|
++line) {
|
2010-10-07 04:25:45 +00:00
|
|
|
nsRect lineArea = line->GetVisualOverflowArea();
|
2006-01-26 02:29:17 +00:00
|
|
|
rv = DisplayLine(aBuilder, lineArea, aDirtyRect, line, depth, drawnLines,
|
|
|
|
aLists, this);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
break;
|
2004-03-07 18:04:24 +00:00
|
|
|
if (!lineArea.IsEmpty()) {
|
|
|
|
if (lineArea.y < lastY
|
|
|
|
|| lineArea.YMost() < lastYMost) {
|
|
|
|
nonDecreasingYs = PR_FALSE;
|
|
|
|
}
|
|
|
|
lastY = lineArea.y;
|
|
|
|
lastYMost = lineArea.YMost();
|
1999-03-22 20:46:09 +00:00
|
|
|
}
|
2004-03-07 18:04:24 +00:00
|
|
|
lineCount++;
|
|
|
|
}
|
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
if (NS_SUCCEEDED(rv) && nonDecreasingYs && lineCount >= MIN_LINES_NEEDING_CURSOR) {
|
2004-03-07 18:04:24 +00:00
|
|
|
SetupLineCursor();
|
1999-03-22 20:46:09 +00:00
|
|
|
}
|
1998-06-18 16:25:41 +00:00
|
|
|
}
|
1999-02-09 17:31:33 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
if (NS_SUCCEEDED(rv) && (nsnull != mBullet) && HaveOutsideBullet()) {
|
|
|
|
// Display outside bullets manually
|
|
|
|
rv = BuildDisplayListForChild(aBuilder, mBullet, aDirtyRect, aLists);
|
1999-02-09 17:31:33 +00:00
|
|
|
}
|
1999-10-19 23:04:19 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (gLamePaintMetrics) {
|
|
|
|
PRTime end = PR_Now();
|
|
|
|
|
2001-10-25 01:08:40 +00:00
|
|
|
PRInt32 numLines = mLines.size();
|
1999-10-19 23:04:19 +00:00
|
|
|
if (!numLines) numLines = 1;
|
|
|
|
PRTime lines, deltaPerLine, delta;
|
|
|
|
LL_I2L(lines, numLines);
|
|
|
|
LL_SUB(delta, end, start);
|
|
|
|
LL_DIV(deltaPerLine, delta, lines);
|
|
|
|
|
|
|
|
ListTag(stdout);
|
|
|
|
char buf[400];
|
|
|
|
PR_snprintf(buf, sizeof(buf),
|
|
|
|
": %lld elapsed (%lld per line) lines=%d drawn=%d skip=%d",
|
|
|
|
delta, deltaPerLine,
|
|
|
|
numLines, drawnLines, numLines - drawnLines);
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("%s\n", buf);
|
1999-10-19 23:04:19 +00:00
|
|
|
}
|
|
|
|
#endif
|
2006-01-26 02:29:17 +00:00
|
|
|
|
|
|
|
return rv;
|
1998-12-05 16:02:08 +00:00
|
|
|
}
|
1998-06-24 17:52:42 +00:00
|
|
|
|
2004-06-04 19:28:36 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2010-06-28 12:02:03 +00:00
|
|
|
already_AddRefed<nsAccessible>
|
|
|
|
nsBlockFrame::CreateAccessible()
|
2004-06-04 19:28:36 +00:00
|
|
|
{
|
2011-01-28 04:38:14 +00:00
|
|
|
nsAccessibilityService* accService = nsIPresShell::AccService();
|
2010-06-28 12:02:03 +00:00
|
|
|
if (!accService) {
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsPresContext* presContext = PresContext();
|
2004-06-04 19:28:36 +00:00
|
|
|
|
2006-07-11 22:14:09 +00:00
|
|
|
// block frame may be for <hr>
|
2006-12-26 17:47:52 +00:00
|
|
|
if (mContent->Tag() == nsGkAtoms::hr) {
|
2010-06-28 12:02:03 +00:00
|
|
|
return accService->CreateHTMLHRAccessible(mContent,
|
|
|
|
presContext->PresShell());
|
2006-04-27 16:23:09 +00:00
|
|
|
}
|
|
|
|
|
2010-06-28 12:02:03 +00:00
|
|
|
if (!mBullet || !presContext) {
|
2008-04-21 17:19:32 +00:00
|
|
|
if (!mContent->GetParent()) {
|
2006-07-11 22:14:09 +00:00
|
|
|
// Don't create accessible objects for the root content node, they are redundant with
|
|
|
|
// the nsDocAccessible object created with the document node
|
2010-06-28 12:02:03 +00:00
|
|
|
return nsnull;
|
2006-07-11 22:14:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMHTMLDocument> htmlDoc =
|
|
|
|
do_QueryInterface(mContent->GetDocument());
|
|
|
|
if (htmlDoc) {
|
|
|
|
nsCOMPtr<nsIDOMHTMLElement> body;
|
|
|
|
htmlDoc->GetBody(getter_AddRefs(body));
|
|
|
|
if (SameCOMIdentity(body, mContent)) {
|
|
|
|
// Don't create accessible objects for the body, they are redundant with
|
|
|
|
// the nsDocAccessible object created with the document node
|
2010-06-28 12:02:03 +00:00
|
|
|
return nsnull;
|
2006-07-11 22:14:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Not a bullet, treat as normal HTML container
|
2010-06-28 12:02:03 +00:00
|
|
|
return accService->CreateHyperTextAccessible(mContent,
|
|
|
|
presContext->PresShell());
|
2004-06-04 19:28:36 +00:00
|
|
|
}
|
|
|
|
|
2006-07-11 22:14:09 +00:00
|
|
|
// Create special list bullet accessible
|
2010-10-14 09:05:22 +00:00
|
|
|
return accService->CreateHTMLLIAccessible(mContent, presContext->PresShell());
|
2004-06-04 19:28:36 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-09-11 10:46:36 +00:00
|
|
|
void nsBlockFrame::ClearLineCursor()
|
|
|
|
{
|
2004-03-07 18:04:24 +00:00
|
|
|
if (!(GetStateBits() & NS_BLOCK_HAS_LINE_CURSOR)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-03-29 01:46:55 +00:00
|
|
|
Properties().Delete(LineCursorProperty());
|
2004-03-07 18:04:24 +00:00
|
|
|
RemoveStateBits(NS_BLOCK_HAS_LINE_CURSOR);
|
|
|
|
}
|
|
|
|
|
2009-09-11 10:46:36 +00:00
|
|
|
void nsBlockFrame::SetupLineCursor()
|
|
|
|
{
|
2004-03-07 18:04:24 +00:00
|
|
|
if (GetStateBits() & NS_BLOCK_HAS_LINE_CURSOR
|
|
|
|
|| mLines.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-03-29 01:46:55 +00:00
|
|
|
Properties().Set(LineCursorProperty(), mLines.front());
|
2004-03-07 18:04:24 +00:00
|
|
|
AddStateBits(NS_BLOCK_HAS_LINE_CURSOR);
|
|
|
|
}
|
|
|
|
|
2009-09-11 10:46:36 +00:00
|
|
|
nsLineBox* nsBlockFrame::GetFirstLineContaining(nscoord y)
|
|
|
|
{
|
2004-03-07 18:04:24 +00:00
|
|
|
if (!(GetStateBits() & NS_BLOCK_HAS_LINE_CURSOR)) {
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
2010-03-29 01:46:55 +00:00
|
|
|
FrameProperties props = Properties();
|
|
|
|
|
2007-07-08 07:08:04 +00:00
|
|
|
nsLineBox* property = static_cast<nsLineBox*>
|
2010-03-29 01:46:55 +00:00
|
|
|
(props.Get(LineCursorProperty()));
|
2004-03-07 18:04:24 +00:00
|
|
|
line_iterator cursor = mLines.begin(property);
|
2010-10-07 04:25:45 +00:00
|
|
|
nsRect cursorArea = cursor->GetVisualOverflowArea();
|
2004-03-07 18:04:24 +00:00
|
|
|
|
|
|
|
while ((cursorArea.IsEmpty() || cursorArea.YMost() > y)
|
|
|
|
&& cursor != mLines.front()) {
|
|
|
|
cursor = cursor.prev();
|
2010-10-07 04:25:45 +00:00
|
|
|
cursorArea = cursor->GetVisualOverflowArea();
|
2004-03-07 18:04:24 +00:00
|
|
|
}
|
|
|
|
while ((cursorArea.IsEmpty() || cursorArea.YMost() <= y)
|
|
|
|
&& cursor != mLines.back()) {
|
|
|
|
cursor = cursor.next();
|
2010-10-07 04:25:45 +00:00
|
|
|
cursorArea = cursor->GetVisualOverflowArea();
|
2004-03-07 18:04:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (cursor.get() != property) {
|
2010-03-29 01:46:55 +00:00
|
|
|
props.Set(LineCursorProperty(), cursor.get());
|
2004-03-07 18:04:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return cursor.get();
|
|
|
|
}
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
/* virtual */ void
|
|
|
|
nsBlockFrame::ChildIsDirty(nsIFrame* aChild)
|
2001-09-05 20:27:19 +00:00
|
|
|
{
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
// See if the child is absolutely positioned
|
|
|
|
if (aChild->GetStateBits() & NS_FRAME_OUT_OF_FLOW &&
|
|
|
|
aChild->GetStyleDisplay()->IsAbsolutelyPositioned()) {
|
|
|
|
// do nothing
|
|
|
|
} else if (aChild == mBullet && HaveOutsideBullet()) {
|
|
|
|
// The bullet lives in the first line, unless the first line has
|
|
|
|
// height 0 and there is a second line, in which case it lives
|
|
|
|
// in the second line.
|
|
|
|
line_iterator bulletLine = begin_lines();
|
|
|
|
if (bulletLine != end_lines() && bulletLine->mBounds.height == 0 &&
|
|
|
|
bulletLine != mLines.back()) {
|
|
|
|
bulletLine = bulletLine.next();
|
2000-05-09 05:06:16 +00:00
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
|
|
|
if (bulletLine != end_lines()) {
|
|
|
|
MarkLineDirty(bulletLine);
|
2004-04-13 01:38:10 +00:00
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
// otherwise we have an empty line list, and ReflowDirtyLines
|
|
|
|
// will handle reflowing the bullet.
|
|
|
|
} else {
|
2007-09-18 03:00:16 +00:00
|
|
|
// Mark the line containing the child frame dirty. We would rather do this
|
|
|
|
// in MarkIntrinsicWidthsDirty but that currently won't tell us which
|
|
|
|
// child is being dirtied.
|
2008-02-27 09:53:48 +00:00
|
|
|
PRBool isValid;
|
|
|
|
nsBlockInFlowLineIterator iter(this, aChild, &isValid);
|
|
|
|
if (isValid) {
|
2008-10-12 19:26:06 +00:00
|
|
|
iter.GetContainer()->MarkLineDirty(iter.GetLine(), iter.GetLineList());
|
2007-09-18 03:00:16 +00:00
|
|
|
}
|
2000-01-12 08:28:24 +00:00
|
|
|
}
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsBlockFrameSuper::ChildIsDirty(aChild);
|
2000-01-12 08:28:24 +00:00
|
|
|
}
|
|
|
|
|
1999-02-25 05:31:15 +00:00
|
|
|
NS_IMETHODIMP
|
2006-03-09 18:55:21 +00:00
|
|
|
nsBlockFrame::Init(nsIContent* aContent,
|
1999-02-25 05:31:15 +00:00
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
|
|
|
if (aPrevInFlow) {
|
2009-01-04 19:52:38 +00:00
|
|
|
// Copy over the block frame type flags
|
1999-02-25 05:31:15 +00:00
|
|
|
nsBlockFrame* blockFrame = (nsBlockFrame*)aPrevInFlow;
|
|
|
|
|
2009-12-22 23:44:35 +00:00
|
|
|
// Don't copy NS_BLOCK_HAS_FIRST_LETTER_CHILD as that is set on the first
|
|
|
|
// continuation only.
|
2006-08-06 03:27:00 +00:00
|
|
|
SetFlags(blockFrame->mState &
|
2009-12-22 23:44:35 +00:00
|
|
|
(NS_BLOCK_FLAGS_MASK &
|
|
|
|
(~NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET &
|
|
|
|
~NS_BLOCK_HAS_FIRST_LETTER_CHILD)));
|
1999-02-25 05:31:15 +00:00
|
|
|
}
|
1999-03-19 23:05:56 +00:00
|
|
|
|
2006-03-26 21:30:36 +00:00
|
|
|
nsresult rv = nsBlockFrameSuper::Init(aContent, aParent, aPrevInFlow);
|
2004-09-28 18:37:50 +00:00
|
|
|
|
2007-10-11 11:41:04 +00:00
|
|
|
if (!aPrevInFlow ||
|
|
|
|
aPrevInFlow->GetStateBits() & NS_BLOCK_NEEDS_BIDI_RESOLUTION)
|
2007-09-03 06:51:11 +00:00
|
|
|
AddStateBits(NS_BLOCK_NEEDS_BIDI_RESOLUTION);
|
|
|
|
|
1999-03-29 23:44:45 +00:00
|
|
|
return rv;
|
1999-02-25 05:31:15 +00:00
|
|
|
}
|
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
NS_IMETHODIMP
|
2006-04-10 00:16:29 +00:00
|
|
|
nsBlockFrame::SetInitialChildList(nsIAtom* aListName,
|
2009-07-28 12:53:20 +00:00
|
|
|
nsFrameList& aChildList)
|
1998-12-05 16:02:08 +00:00
|
|
|
{
|
1999-02-26 17:04:44 +00:00
|
|
|
nsresult rv = NS_OK;
|
1998-06-24 17:52:42 +00:00
|
|
|
|
2011-04-29 23:02:33 +00:00
|
|
|
if (nsGkAtoms::floatList == aListName) {
|
2003-10-13 21:51:02 +00:00
|
|
|
mFloats.SetFrames(aChildList);
|
1999-02-26 17:04:44 +00:00
|
|
|
}
|
|
|
|
else {
|
2007-03-30 21:11:41 +00:00
|
|
|
nsPresContext* presContext = PresContext();
|
1999-04-20 00:27:43 +00:00
|
|
|
|
2007-05-02 20:32:17 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
// The only times a block that is an anonymous box is allowed to have a
|
|
|
|
// first-letter frame are when it's the block inside a non-anonymous cell,
|
|
|
|
// the block inside a fieldset, a scrolled content block, or a column
|
|
|
|
// content block. Note that this means that blocks which are the anonymous
|
2007-11-26 00:15:20 +00:00
|
|
|
// block in {ib} splits do NOT get first-letter frames. Note that
|
|
|
|
// NS_BLOCK_HAS_FIRST_LETTER_STYLE gets set on all continuations of the
|
|
|
|
// block.
|
2009-10-29 21:17:56 +00:00
|
|
|
nsIAtom *pseudo = GetStyleContext()->GetPseudo();
|
2007-05-02 20:32:17 +00:00
|
|
|
PRBool haveFirstLetterStyle =
|
|
|
|
(!pseudo ||
|
|
|
|
(pseudo == nsCSSAnonBoxes::cellContent &&
|
2009-10-29 21:17:56 +00:00
|
|
|
mParent->GetStyleContext()->GetPseudo() == nsnull) ||
|
2007-05-02 20:32:17 +00:00
|
|
|
pseudo == nsCSSAnonBoxes::fieldsetContent ||
|
|
|
|
pseudo == nsCSSAnonBoxes::scrolledContent ||
|
|
|
|
pseudo == nsCSSAnonBoxes::columnContent) &&
|
2007-10-11 04:36:48 +00:00
|
|
|
!IsFrameOfType(eMathML) &&
|
2007-05-02 20:32:17 +00:00
|
|
|
nsRefPtr<nsStyleContext>(GetFirstLetterStyle(presContext)) != nsnull;
|
|
|
|
NS_ASSERTION(haveFirstLetterStyle ==
|
2007-04-16 00:42:54 +00:00
|
|
|
((mState & NS_BLOCK_HAS_FIRST_LETTER_STYLE) != 0),
|
|
|
|
"NS_BLOCK_HAS_FIRST_LETTER_STYLE state out of sync");
|
2007-05-02 20:32:17 +00:00
|
|
|
#endif
|
2007-04-16 00:42:54 +00:00
|
|
|
|
2005-02-07 01:58:25 +00:00
|
|
|
rv = AddFrames(aChildList, nsnull);
|
1999-02-26 17:04:44 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
1998-06-18 16:25:41 +00:00
|
|
|
|
2010-06-11 19:23:13 +00:00
|
|
|
// Create a list bullet if this is a list-item. Note that this is
|
|
|
|
// done here so that RenumberLists will work (it needs the bullets
|
|
|
|
// to store the bullet numbers). Also note that due to various
|
|
|
|
// wrapper frames (scrollframes, columns) we want to use the
|
|
|
|
// outermost (primary, ideally, but it's not set yet when we get
|
|
|
|
// here) frame of our content for the display check. On the other
|
|
|
|
// hand, we look at ourselves for the GetPrevInFlow() check, since
|
|
|
|
// for a columnset we don't want a bullet per column. Note that
|
|
|
|
// the outermost frame for the content is the primary frame in
|
|
|
|
// most cases; the ones when it's not (like tables) can't be
|
|
|
|
// NS_STYLE_DISPLAY_LIST_ITEM).
|
|
|
|
nsIFrame* possibleListItem = this;
|
|
|
|
while (1) {
|
|
|
|
nsIFrame* parent = possibleListItem->GetParent();
|
|
|
|
if (parent->GetContent() != GetContent()) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
possibleListItem = parent;
|
|
|
|
}
|
2006-02-21 21:33:47 +00:00
|
|
|
if ((nsnull == GetPrevInFlow()) &&
|
2010-06-11 19:23:13 +00:00
|
|
|
(NS_STYLE_DISPLAY_LIST_ITEM ==
|
|
|
|
possibleListItem->GetStyleDisplay()->mDisplay) &&
|
1999-02-26 17:04:44 +00:00
|
|
|
(nsnull == mBullet)) {
|
|
|
|
// Resolve style for the bullet frame
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleList* styleList = GetStyleList();
|
2009-12-11 07:37:40 +00:00
|
|
|
nsCSSPseudoElements::Type pseudoType;
|
2002-02-21 01:36:16 +00:00
|
|
|
switch (styleList->mListStyleType) {
|
|
|
|
case NS_STYLE_LIST_STYLE_DISC:
|
|
|
|
case NS_STYLE_LIST_STYLE_CIRCLE:
|
|
|
|
case NS_STYLE_LIST_STYLE_SQUARE:
|
2009-12-11 07:37:40 +00:00
|
|
|
pseudoType = nsCSSPseudoElements::ePseudo_mozListBullet;
|
2002-02-21 01:36:16 +00:00
|
|
|
break;
|
|
|
|
default:
|
2009-12-11 07:37:40 +00:00
|
|
|
pseudoType = nsCSSPseudoElements::ePseudo_mozListNumber;
|
2002-02-21 01:36:16 +00:00
|
|
|
break;
|
|
|
|
}
|
2004-01-28 00:18:22 +00:00
|
|
|
|
2006-04-10 00:16:29 +00:00
|
|
|
nsIPresShell *shell = presContext->PresShell();
|
2004-01-28 00:18:22 +00:00
|
|
|
|
2007-08-02 22:07:52 +00:00
|
|
|
nsStyleContext* parentStyle =
|
2009-12-11 07:37:40 +00:00
|
|
|
CorrectStyleParentFrame(this,
|
|
|
|
nsCSSPseudoElements::GetPseudoAtom(pseudoType))->GetStyleContext();
|
2004-01-28 00:18:22 +00:00
|
|
|
nsRefPtr<nsStyleContext> kidSC = shell->StyleSet()->
|
2010-04-30 13:12:06 +00:00
|
|
|
ResolvePseudoElementStyle(mContent->AsElement(), pseudoType,
|
|
|
|
parentStyle);
|
1999-02-26 17:04:44 +00:00
|
|
|
|
|
|
|
// Create bullet frame
|
2006-03-26 21:30:36 +00:00
|
|
|
nsBulletFrame* bullet = new (shell) nsBulletFrame(kidSC);
|
2005-08-31 19:38:59 +00:00
|
|
|
if (nsnull == bullet) {
|
1999-02-26 17:04:44 +00:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
2006-03-26 21:30:36 +00:00
|
|
|
bullet->Init(mContent, this, nsnull);
|
1998-07-02 00:04:12 +00:00
|
|
|
|
1999-02-26 17:04:44 +00:00
|
|
|
// If the list bullet frame should be positioned inside then add
|
|
|
|
// it to the flow now.
|
1999-04-20 00:27:43 +00:00
|
|
|
if (NS_STYLE_LIST_STYLE_POSITION_INSIDE ==
|
|
|
|
styleList->mListStylePosition) {
|
2009-09-29 19:47:05 +00:00
|
|
|
nsFrameList bulletList(bullet, bullet);
|
|
|
|
AddFrames(bulletList, nsnull);
|
1999-02-26 17:04:44 +00:00
|
|
|
mState &= ~NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mState |= NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET;
|
|
|
|
}
|
2005-08-31 19:38:59 +00:00
|
|
|
|
|
|
|
mBullet = bullet;
|
1998-07-02 00:04:12 +00:00
|
|
|
}
|
1998-06-24 17:52:42 +00:00
|
|
|
}
|
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
return NS_OK;
|
2009-09-11 10:46:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsBlockFrame::BulletIsEmpty() const
|
|
|
|
{
|
2010-06-14 20:06:48 +00:00
|
|
|
NS_ASSERTION(mContent->GetPrimaryFrame()->GetStyleDisplay()->mDisplay ==
|
|
|
|
NS_STYLE_DISPLAY_LIST_ITEM &&
|
2009-09-11 10:46:36 +00:00
|
|
|
HaveOutsideBullet(),
|
|
|
|
"should only care when we have an outside bullet");
|
|
|
|
const nsStyleList* list = GetStyleList();
|
|
|
|
return list->mListStyleType == NS_STYLE_LIST_STYLE_NONE &&
|
2009-12-11 04:02:13 +00:00
|
|
|
!list->GetListStyleImage();
|
1998-06-24 17:52:42 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 09:05:22 +00:00
|
|
|
void
|
|
|
|
nsBlockFrame::GetBulletText(nsAString& aText) const
|
|
|
|
{
|
|
|
|
aText.Truncate();
|
|
|
|
|
|
|
|
const nsStyleList* myList = GetStyleList();
|
|
|
|
if (myList->GetListStyleImage() ||
|
2010-10-15 15:34:24 +00:00
|
|
|
myList->mListStyleType == NS_STYLE_LIST_STYLE_DISC) {
|
|
|
|
aText.Assign(kDiscCharacter);
|
|
|
|
}
|
|
|
|
else if (myList->mListStyleType == NS_STYLE_LIST_STYLE_CIRCLE) {
|
|
|
|
aText.Assign(kCircleCharacter);
|
|
|
|
}
|
|
|
|
else if (myList->mListStyleType == NS_STYLE_LIST_STYLE_SQUARE) {
|
|
|
|
aText.Assign(kSquareCharacter);
|
2010-10-14 09:05:22 +00:00
|
|
|
}
|
|
|
|
else if (myList->mListStyleType != NS_STYLE_LIST_STYLE_NONE) {
|
|
|
|
nsAutoString text;
|
|
|
|
mBullet->GetListItemText(*myList, text);
|
|
|
|
aText = text;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-28 13:59:54 +00:00
|
|
|
bool
|
|
|
|
nsBlockFrame::HasBullet() const
|
|
|
|
{
|
|
|
|
if (mBullet) {
|
|
|
|
const nsStyleList* styleList = GetStyleList();
|
|
|
|
return styleList->GetListStyleImage() ||
|
|
|
|
styleList->mListStyleType != NS_STYLE_LIST_STYLE_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2005-05-17 03:15:14 +00:00
|
|
|
// static
|
1999-07-14 17:26:20 +00:00
|
|
|
PRBool
|
|
|
|
nsBlockFrame::FrameStartsCounterScope(nsIFrame* aFrame)
|
|
|
|
{
|
2005-05-17 03:15:14 +00:00
|
|
|
nsIContent* content = aFrame->GetContent();
|
2009-08-24 20:02:07 +00:00
|
|
|
if (!content || !content->IsHTML())
|
2005-04-01 23:07:00 +00:00
|
|
|
return PR_FALSE;
|
2005-09-24 18:43:15 +00:00
|
|
|
|
|
|
|
nsIAtom *localName = content->NodeInfo()->NameAtom();
|
2006-12-26 17:47:52 +00:00
|
|
|
return localName == nsGkAtoms::ol ||
|
|
|
|
localName == nsGkAtoms::ul ||
|
|
|
|
localName == nsGkAtoms::dir ||
|
|
|
|
localName == nsGkAtoms::menu;
|
1999-07-14 17:26:20 +00:00
|
|
|
}
|
|
|
|
|
2007-05-06 19:16:51 +00:00
|
|
|
PRBool
|
2004-07-31 23:15:21 +00:00
|
|
|
nsBlockFrame::RenumberLists(nsPresContext* aPresContext)
|
1999-07-14 17:26:20 +00:00
|
|
|
{
|
|
|
|
if (!FrameStartsCounterScope(this)) {
|
|
|
|
// If this frame doesn't start a counter scope then we don't need
|
|
|
|
// to renumber child list items.
|
2007-05-06 19:16:51 +00:00
|
|
|
return PR_FALSE;
|
1999-07-14 17:26:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Setup initial list ordinal value
|
|
|
|
// XXX Map html's start property to counter-reset style
|
|
|
|
PRInt32 ordinal = 1;
|
2002-05-23 00:00:34 +00:00
|
|
|
|
2005-01-12 19:45:38 +00:00
|
|
|
nsGenericHTMLElement *hc = nsGenericHTMLElement::FromContent(mContent);
|
2002-05-23 00:00:34 +00:00
|
|
|
|
|
|
|
if (hc) {
|
2006-12-26 17:47:52 +00:00
|
|
|
const nsAttrValue* attr = hc->GetParsedAttr(nsGkAtoms::start);
|
2005-01-25 00:02:58 +00:00
|
|
|
if (attr && attr->Type() == nsAttrValue::eInteger) {
|
|
|
|
ordinal = attr->GetIntegerValue();
|
1999-07-14 17:26:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get to first-in-flow
|
1999-09-16 19:56:36 +00:00
|
|
|
nsBlockFrame* block = (nsBlockFrame*) GetFirstInFlow();
|
2007-05-06 19:16:51 +00:00
|
|
|
return RenumberListsInBlock(aPresContext, block, &ordinal, 0);
|
1999-07-14 17:26:20 +00:00
|
|
|
}
|
|
|
|
|
1999-09-17 23:16:43 +00:00
|
|
|
PRBool
|
2004-07-31 23:15:21 +00:00
|
|
|
nsBlockFrame::RenumberListsInBlock(nsPresContext* aPresContext,
|
2000-01-22 01:16:50 +00:00
|
|
|
nsBlockFrame* aBlockFrame,
|
2000-07-28 09:02:34 +00:00
|
|
|
PRInt32* aOrdinal,
|
|
|
|
PRInt32 aDepth)
|
1999-09-17 23:16:43 +00:00
|
|
|
{
|
2008-02-24 07:31:29 +00:00
|
|
|
// Examine each line in the block
|
|
|
|
PRBool foundValidLine;
|
|
|
|
nsBlockInFlowLineIterator bifLineIter(aBlockFrame, &foundValidLine);
|
|
|
|
|
|
|
|
if (!foundValidLine)
|
|
|
|
return PR_FALSE;
|
|
|
|
|
1999-09-17 23:16:43 +00:00
|
|
|
PRBool renumberedABullet = PR_FALSE;
|
|
|
|
|
2008-02-24 07:31:29 +00:00
|
|
|
do {
|
|
|
|
nsLineList::iterator line = bifLineIter.GetLine();
|
|
|
|
nsIFrame* kid = line->mFirstChild;
|
|
|
|
PRInt32 n = line->GetChildCount();
|
|
|
|
while (--n >= 0) {
|
|
|
|
PRBool kidRenumberedABullet = RenumberListsFor(aPresContext, kid, aOrdinal, aDepth);
|
|
|
|
if (kidRenumberedABullet) {
|
|
|
|
line->MarkDirty();
|
|
|
|
renumberedABullet = PR_TRUE;
|
1999-09-17 23:16:43 +00:00
|
|
|
}
|
2008-02-24 07:31:29 +00:00
|
|
|
kid = kid->GetNextSibling();
|
1999-09-17 23:16:43 +00:00
|
|
|
}
|
2008-02-24 07:31:29 +00:00
|
|
|
} while (bifLineIter.Next());
|
1999-09-17 23:16:43 +00:00
|
|
|
|
|
|
|
return renumberedABullet;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
2004-07-31 23:15:21 +00:00
|
|
|
nsBlockFrame::RenumberListsFor(nsPresContext* aPresContext,
|
2000-01-22 01:16:50 +00:00
|
|
|
nsIFrame* aKid,
|
2000-07-28 09:02:34 +00:00
|
|
|
PRInt32* aOrdinal,
|
|
|
|
PRInt32 aDepth)
|
1999-09-17 23:16:43 +00:00
|
|
|
{
|
2001-07-04 02:00:05 +00:00
|
|
|
NS_PRECONDITION(aPresContext && aKid && aOrdinal, "null params are immoral!");
|
2001-02-02 21:17:01 +00:00
|
|
|
|
2000-06-14 23:15:59 +00:00
|
|
|
// add in a sanity check for absurdly deep frame trees. See bug 42138
|
2000-07-28 09:02:34 +00:00
|
|
|
if (MAX_DEPTH_FOR_LIST_RENUMBERING < aDepth)
|
2000-06-14 23:15:59 +00:00
|
|
|
return PR_FALSE;
|
|
|
|
|
2001-02-02 21:17:01 +00:00
|
|
|
// if the frame is a placeholder, then get the out of flow frame
|
2005-04-14 15:30:35 +00:00
|
|
|
nsIFrame* kid = nsPlaceholderFrame::GetRealFrameFor(aKid);
|
2011-04-04 11:41:02 +00:00
|
|
|
const nsStyleDisplay* display = kid->GetStyleDisplay();
|
1999-07-14 17:26:20 +00:00
|
|
|
|
2005-03-28 21:05:04 +00:00
|
|
|
// drill down through any wrappers to the real frame
|
|
|
|
kid = kid->GetContentInsertionFrame();
|
|
|
|
|
2008-02-24 07:31:29 +00:00
|
|
|
// possible there is no content insertion frame
|
|
|
|
if (!kid)
|
|
|
|
return PR_FALSE;
|
|
|
|
|
|
|
|
PRBool kidRenumberedABullet = PR_FALSE;
|
|
|
|
|
1999-09-17 23:16:43 +00:00
|
|
|
// If the frame is a list-item and the frame implements our
|
2001-06-07 02:09:38 +00:00
|
|
|
// block frame API then get its bullet and set the list item
|
1999-09-17 23:16:43 +00:00
|
|
|
// ordinal.
|
|
|
|
if (NS_STYLE_DISPLAY_LIST_ITEM == display->mDisplay) {
|
2001-06-07 02:09:38 +00:00
|
|
|
// Make certain that the frame is a block frame in case
|
1999-09-17 23:16:43 +00:00
|
|
|
// something foreign has crept in.
|
2008-07-13 22:10:23 +00:00
|
|
|
nsBlockFrame* listItem = nsLayoutUtils::GetAsBlock(kid);
|
|
|
|
if (listItem) {
|
1999-09-17 23:16:43 +00:00
|
|
|
if (nsnull != listItem->mBullet) {
|
|
|
|
PRBool changed;
|
|
|
|
*aOrdinal = listItem->mBullet->SetListItemOrdinal(*aOrdinal,
|
|
|
|
&changed);
|
|
|
|
if (changed) {
|
|
|
|
kidRenumberedABullet = PR_TRUE;
|
2002-04-11 14:01:11 +00:00
|
|
|
|
2008-10-11 01:41:10 +00:00
|
|
|
// The ordinal changed - mark the bullet frame dirty.
|
|
|
|
listItem->ChildIsDirty(listItem->mBullet);
|
1999-07-14 17:26:20 +00:00
|
|
|
}
|
|
|
|
}
|
1999-09-17 23:16:43 +00:00
|
|
|
|
|
|
|
// XXX temporary? if the list-item has child list-items they
|
|
|
|
// should be numbered too; especially since the list-item is
|
2001-06-07 02:09:38 +00:00
|
|
|
// itself (ASSUMED!) not to be a counter-resetter.
|
2000-07-28 09:02:34 +00:00
|
|
|
PRBool meToo = RenumberListsInBlock(aPresContext, listItem, aOrdinal, aDepth + 1);
|
1999-09-17 23:16:43 +00:00
|
|
|
if (meToo) {
|
|
|
|
kidRenumberedABullet = PR_TRUE;
|
1999-07-14 17:26:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-09-17 23:16:43 +00:00
|
|
|
else if (NS_STYLE_DISPLAY_BLOCK == display->mDisplay) {
|
2001-02-02 21:17:01 +00:00
|
|
|
if (FrameStartsCounterScope(kid)) {
|
1999-09-17 23:16:43 +00:00
|
|
|
// Don't bother recursing into a block frame that is a new
|
|
|
|
// counter scope. Any list-items in there will be handled by
|
|
|
|
// it.
|
|
|
|
}
|
|
|
|
else {
|
2001-06-07 02:09:38 +00:00
|
|
|
// If the display=block element is a block frame then go ahead
|
|
|
|
// and recurse into it, as it might have child list-items.
|
2008-07-13 22:10:23 +00:00
|
|
|
nsBlockFrame* kidBlock = nsLayoutUtils::GetAsBlock(kid);
|
|
|
|
if (kidBlock) {
|
2000-07-28 09:02:34 +00:00
|
|
|
kidRenumberedABullet = RenumberListsInBlock(aPresContext, kidBlock, aOrdinal, aDepth + 1);
|
1999-09-17 23:16:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return kidRenumberedABullet;
|
1999-07-14 17:26:20 +00:00
|
|
|
}
|
1998-10-16 20:22:39 +00:00
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
void
|
1999-02-18 22:22:55 +00:00
|
|
|
nsBlockFrame::ReflowBullet(nsBlockReflowState& aState,
|
2008-02-10 21:49:24 +00:00
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
nscoord aLineTop)
|
1998-06-18 16:25:41 +00:00
|
|
|
{
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
const nsHTMLReflowState &rs = aState.mReflowState;
|
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
// Reflow the bullet now
|
|
|
|
nsSize availSize;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
// Make up a width since it doesn't really matter (XXX).
|
2010-08-11 19:32:53 +00:00
|
|
|
availSize.width = aState.mContentArea.width;
|
1998-12-05 16:02:08 +00:00
|
|
|
availSize.height = NS_UNCONSTRAINEDSIZE;
|
2002-05-10 18:22:41 +00:00
|
|
|
|
|
|
|
// Get the reason right.
|
|
|
|
// XXXwaterson Should this look just like the logic in
|
|
|
|
// nsBlockReflowContext::ReflowBlock and nsLineLayout::ReflowFrame?
|
|
|
|
nsHTMLReflowState reflowState(aState.mPresContext, rs,
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
mBullet, availSize);
|
1999-10-30 02:52:11 +00:00
|
|
|
nsReflowStatus status;
|
1999-11-24 06:03:41 +00:00
|
|
|
mBullet->WillReflow(aState.mPresContext);
|
|
|
|
mBullet->Reflow(aState.mPresContext, aMetrics, reflowState, status);
|
1998-11-19 03:52:29 +00:00
|
|
|
|
2009-04-08 20:52:36 +00:00
|
|
|
// Get the float available space using our saved state from before we
|
|
|
|
// started reflowing the block, so that we ignore any floats inside
|
|
|
|
// the block.
|
|
|
|
// FIXME: aLineTop isn't actually set correctly by some callers, since
|
|
|
|
// they reposition the line.
|
2009-04-08 20:52:37 +00:00
|
|
|
nsRect floatAvailSpace =
|
2010-08-06 04:59:18 +00:00
|
|
|
aState.GetFloatAvailableSpaceWithState(aLineTop,
|
2009-04-08 20:52:37 +00:00
|
|
|
&aState.mFloatManagerStateBefore)
|
|
|
|
.mRect;
|
2009-04-08 20:52:36 +00:00
|
|
|
// FIXME (bug 25888): need to check the entire region that the first
|
|
|
|
// line overlaps, not just the top pixel.
|
|
|
|
|
|
|
|
// Place the bullet now. We want to place the bullet relative to the
|
|
|
|
// border-box of the associated block (using the right/left margin of
|
|
|
|
// the bullet frame as separation). However, if a line box would be
|
|
|
|
// displaced by floats that are *outside* the associated block, we
|
|
|
|
// want to displace it by the same amount. That is, we act as though
|
|
|
|
// the edge of the floats is the content-edge of the block, and place
|
|
|
|
// the bullet at a position offset from there by the block's padding,
|
|
|
|
// the block's border, and the bullet frame's margin.
|
|
|
|
nscoord x;
|
|
|
|
if (rs.mStyleVisibility->mDirection == NS_STYLE_DIRECTION_LTR) {
|
2010-08-11 19:32:53 +00:00
|
|
|
// The floatAvailSpace.x gives us the content/float edge. Then we
|
|
|
|
// subtract out the left border/padding and the bullet's width and
|
|
|
|
// margin to offset the position.
|
|
|
|
x = floatAvailSpace.x - rs.mComputedBorderPadding.left
|
|
|
|
- reflowState.mComputedMargin.right - aMetrics.width;
|
2009-04-08 20:52:36 +00:00
|
|
|
} else {
|
2010-08-11 19:32:53 +00:00
|
|
|
// The XMost() of the available space give us offsets from the left
|
|
|
|
// border edge. Then we add the right border/padding and the
|
|
|
|
// bullet's margin to offset the position.
|
|
|
|
x = floatAvailSpace.XMost() + rs.mComputedBorderPadding.right
|
2009-04-08 20:52:36 +00:00
|
|
|
+ reflowState.mComputedMargin.left;
|
|
|
|
}
|
1999-02-18 22:22:55 +00:00
|
|
|
|
|
|
|
// Approximate the bullets position; vertical alignment will provide
|
|
|
|
// the final vertical location.
|
2010-08-11 19:32:53 +00:00
|
|
|
nscoord y = aState.mContentArea.y;
|
2003-06-26 11:30:17 +00:00
|
|
|
mBullet->SetRect(nsRect(x, y, aMetrics.width, aMetrics.height));
|
2001-12-07 14:51:12 +00:00
|
|
|
mBullet->DidReflow(aState.mPresContext, &aState.mReflowState, NS_FRAME_REFLOW_FINISHED);
|
1998-12-05 16:02:08 +00:00
|
|
|
}
|
1998-07-22 05:02:07 +00:00
|
|
|
|
2005-03-23 03:35:08 +00:00
|
|
|
// This is used to scan frames for any float placeholders, add their
|
2009-09-18 11:09:36 +00:00
|
|
|
// floats to the list represented by aList, and remove the
|
2006-08-22 03:04:18 +00:00
|
|
|
// floats from whatever list they might be in. We don't search descendants
|
|
|
|
// that are float containing blocks. The floats must be children of 'this'.
|
2009-09-18 11:09:36 +00:00
|
|
|
void nsBlockFrame::CollectFloats(nsIFrame* aFrame, nsFrameList& aList,
|
2007-04-21 00:42:58 +00:00
|
|
|
PRBool aFromOverflow, PRBool aCollectSiblings) {
|
2004-06-27 02:01:06 +00:00
|
|
|
while (aFrame) {
|
2006-08-22 03:04:18 +00:00
|
|
|
// Don't descend into float containing blocks.
|
|
|
|
if (!aFrame->IsFloatContainingBlock()) {
|
2009-11-16 21:00:07 +00:00
|
|
|
nsIFrame *outOfFlowFrame =
|
|
|
|
aFrame->GetType() == nsGkAtoms::placeholderFrame ?
|
|
|
|
nsLayoutUtils::GetFloatFromPlaceholder(aFrame) : nsnull;
|
2004-09-13 13:35:46 +00:00
|
|
|
if (outOfFlowFrame) {
|
2010-08-06 04:59:20 +00:00
|
|
|
if (outOfFlowFrame->GetStateBits() & NS_FRAME_IS_PUSHED_FLOAT) {
|
2010-08-06 04:59:19 +00:00
|
|
|
if (outOfFlowFrame->GetParent() == this) {
|
2010-08-06 04:59:20 +00:00
|
|
|
nsFrameList* list = GetPushedFloats();
|
2010-08-06 04:59:19 +00:00
|
|
|
if (!list || !list->RemoveFrameIfPresent(outOfFlowFrame)) {
|
2010-08-19 13:38:00 +00:00
|
|
|
if (aFromOverflow) {
|
|
|
|
nsAutoOOFFrameList oofs(this);
|
|
|
|
oofs.mList.RemoveFrame(outOfFlowFrame);
|
|
|
|
} else {
|
|
|
|
mFloats.RemoveFrame(outOfFlowFrame);
|
|
|
|
}
|
2010-08-06 04:59:19 +00:00
|
|
|
}
|
|
|
|
aList.AppendFrame(nsnull, outOfFlowFrame);
|
|
|
|
}
|
2010-08-19 13:38:00 +00:00
|
|
|
// FIXME: By not pulling floats whose parent is one of our
|
|
|
|
// later siblings, are we risking the pushed floats getting
|
|
|
|
// out-of-order?
|
2004-09-13 13:35:46 +00:00
|
|
|
} else {
|
2010-08-06 04:59:19 +00:00
|
|
|
// Make sure that its parent is us. Otherwise we don't want
|
|
|
|
// to mess around with it because it belongs to someone
|
|
|
|
// else. I think this could happen if the overflow lines
|
|
|
|
// contain a block descendant which owns its own floats.
|
|
|
|
NS_ASSERTION(outOfFlowFrame->GetParent() == this,
|
|
|
|
"Out of flow frame doesn't have the expected parent");
|
|
|
|
if (aFromOverflow) {
|
|
|
|
nsAutoOOFFrameList oofs(this);
|
|
|
|
oofs.mList.RemoveFrame(outOfFlowFrame);
|
|
|
|
} else {
|
|
|
|
mFloats.RemoveFrame(outOfFlowFrame);
|
|
|
|
}
|
|
|
|
aList.AppendFrame(nsnull, outOfFlowFrame);
|
2004-06-27 02:01:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-24 20:21:41 +00:00
|
|
|
CollectFloats(aFrame->GetFirstChild(nsnull),
|
2009-09-18 11:09:36 +00:00
|
|
|
aList, aFromOverflow, PR_TRUE);
|
2007-09-24 20:21:41 +00:00
|
|
|
// Note: Even though we're calling CollectFloats on aFrame's overflow
|
|
|
|
// list, we'll pass down aFromOverflow unchanged because we're still
|
2007-09-24 20:25:38 +00:00
|
|
|
// traversing the regular-children subtree of the 'this' frame.
|
2007-09-24 20:21:41 +00:00
|
|
|
CollectFloats(aFrame->GetFirstChild(nsGkAtoms::overflowList),
|
2009-09-18 11:09:36 +00:00
|
|
|
aList, aFromOverflow, PR_TRUE);
|
2004-06-27 02:01:06 +00:00
|
|
|
}
|
2007-04-21 00:42:58 +00:00
|
|
|
if (!aCollectSiblings)
|
|
|
|
break;
|
2004-06-27 02:01:06 +00:00
|
|
|
aFrame = aFrame->GetNextSibling();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-05 16:02:08 +00:00
|
|
|
void
|
2006-04-09 22:56:27 +00:00
|
|
|
nsBlockFrame::CheckFloats(nsBlockReflowState& aState)
|
1998-12-05 16:02:08 +00:00
|
|
|
{
|
2006-04-09 22:56:27 +00:00
|
|
|
#ifdef DEBUG
|
2007-11-30 01:49:01 +00:00
|
|
|
// If any line is still dirty, that must mean we're going to reflow this
|
|
|
|
// block again soon (e.g. because we bailed out after noticing that
|
|
|
|
// clearance was imposed), so don't worry if the floats are out of sync.
|
|
|
|
PRBool anyLineDirty = PR_FALSE;
|
|
|
|
|
2006-04-09 22:56:27 +00:00
|
|
|
// Check that the float list is what we would have built
|
2009-02-03 14:42:18 +00:00
|
|
|
nsAutoTArray<nsIFrame*, 8> lineFloats;
|
2001-10-25 01:08:40 +00:00
|
|
|
for (line_iterator line = begin_lines(), line_end = end_lines();
|
2006-04-09 22:56:27 +00:00
|
|
|
line != line_end; ++line) {
|
2003-10-13 21:51:02 +00:00
|
|
|
if (line->HasFloats()) {
|
|
|
|
nsFloatCache* fc = line->GetFirstFloat();
|
1999-09-15 00:28:10 +00:00
|
|
|
while (fc) {
|
2009-08-31 18:25:35 +00:00
|
|
|
lineFloats.AppendElement(fc->mFloat);
|
1999-09-15 00:28:10 +00:00
|
|
|
fc = fc->Next();
|
1998-12-05 16:02:08 +00:00
|
|
|
}
|
|
|
|
}
|
2007-11-30 01:49:01 +00:00
|
|
|
if (line->IsDirty()) {
|
|
|
|
anyLineDirty = PR_TRUE;
|
|
|
|
}
|
1998-11-19 03:52:29 +00:00
|
|
|
}
|
2006-04-09 22:56:27 +00:00
|
|
|
|
2009-02-03 14:42:18 +00:00
|
|
|
nsAutoTArray<nsIFrame*, 8> storedFloats;
|
2006-04-09 22:56:27 +00:00
|
|
|
PRBool equal = PR_TRUE;
|
2009-02-03 14:42:18 +00:00
|
|
|
PRUint32 i = 0;
|
2006-04-09 22:56:27 +00:00
|
|
|
for (nsIFrame* f = mFloats.FirstChild(); f; f = f->GetNextSibling()) {
|
2010-08-06 04:59:20 +00:00
|
|
|
if (f->GetStateBits() & NS_FRAME_IS_PUSHED_FLOAT)
|
2009-08-31 18:25:36 +00:00
|
|
|
continue;
|
2006-04-09 22:56:27 +00:00
|
|
|
storedFloats.AppendElement(f);
|
2009-02-03 14:42:18 +00:00
|
|
|
if (i < lineFloats.Length() && lineFloats.ElementAt(i) != f) {
|
2006-04-09 22:56:27 +00:00
|
|
|
equal = PR_FALSE;
|
|
|
|
}
|
|
|
|
++i;
|
1998-11-19 03:52:29 +00:00
|
|
|
}
|
2004-05-05 02:30:33 +00:00
|
|
|
|
2009-02-03 14:42:18 +00:00
|
|
|
if ((!equal || lineFloats.Length() != storedFloats.Length()) && !anyLineDirty) {
|
2006-04-09 22:56:27 +00:00
|
|
|
NS_WARNING("nsBlockFrame::CheckFloats: Explicit float list is out of sync with float cache");
|
2006-06-07 01:39:48 +00:00
|
|
|
#if defined(DEBUG_roc)
|
2009-08-20 21:52:48 +00:00
|
|
|
nsFrame::RootFrameList(PresContext(), stdout, 0);
|
2009-02-03 14:42:18 +00:00
|
|
|
for (i = 0; i < lineFloats.Length(); ++i) {
|
2006-04-09 22:56:27 +00:00
|
|
|
printf("Line float: %p\n", lineFloats.ElementAt(i));
|
|
|
|
}
|
2009-02-03 14:42:18 +00:00
|
|
|
for (i = 0; i < storedFloats.Length(); ++i) {
|
2006-04-09 22:56:27 +00:00
|
|
|
printf("Stored float: %p\n", storedFloats.ElementAt(i));
|
2004-05-05 02:30:33 +00:00
|
|
|
}
|
2006-06-07 01:39:48 +00:00
|
|
|
#endif
|
2004-05-05 02:30:33 +00:00
|
|
|
}
|
2006-04-09 22:56:27 +00:00
|
|
|
#endif
|
|
|
|
|
2009-09-24 02:39:21 +00:00
|
|
|
const nsFrameList* oofs = GetOverflowOutOfFlows();
|
|
|
|
if (oofs && oofs->NotEmpty()) {
|
2009-01-05 00:39:54 +00:00
|
|
|
// Floats that were pushed should be removed from our float
|
|
|
|
// manager. Otherwise the float manager's YMost or XMost might
|
2006-04-09 22:56:27 +00:00
|
|
|
// be larger than necessary, causing this block to get an
|
|
|
|
// incorrect desired height (or width). Some of these floats
|
2009-01-05 00:39:54 +00:00
|
|
|
// may not actually have been added to the float manager because
|
2006-04-09 22:56:27 +00:00
|
|
|
// they weren't reflowed before being pushed; that's OK,
|
|
|
|
// RemoveRegions will ignore them. It is safe to do this here
|
2009-01-05 00:39:54 +00:00
|
|
|
// because we know from here on the float manager will only be
|
2006-04-09 22:56:27 +00:00
|
|
|
// used for its XMost and YMost, not to place new floats and
|
|
|
|
// lines.
|
2009-09-24 02:39:21 +00:00
|
|
|
aState.mFloatManager->RemoveTrailingRegions(oofs->FirstChild());
|
2006-04-09 22:56:27 +00:00
|
|
|
}
|
1998-12-05 16:02:08 +00:00
|
|
|
}
|
1998-10-30 22:10:10 +00:00
|
|
|
|
2007-02-18 23:53:25 +00:00
|
|
|
/* static */
|
|
|
|
PRBool
|
|
|
|
nsBlockFrame::BlockIsMarginRoot(nsIFrame* aBlock)
|
2004-09-28 18:37:50 +00:00
|
|
|
{
|
2007-02-18 23:53:25 +00:00
|
|
|
NS_PRECONDITION(aBlock, "Must have a frame");
|
2008-07-13 22:10:23 +00:00
|
|
|
NS_ASSERTION(nsLayoutUtils::GetAsBlock(aBlock), "aBlock must be a block");
|
2007-02-18 23:53:25 +00:00
|
|
|
|
|
|
|
nsIFrame* parent = aBlock->GetParent();
|
|
|
|
return (aBlock->GetStateBits() & NS_BLOCK_MARGIN_ROOT) ||
|
|
|
|
(parent && !parent->IsFloatContainingBlock() &&
|
|
|
|
parent->GetType() != nsGkAtoms::columnSetFrame);
|
|
|
|
}
|
2004-09-28 18:37:50 +00:00
|
|
|
|
2007-02-18 23:53:25 +00:00
|
|
|
/* static */
|
|
|
|
PRBool
|
2009-01-05 00:39:54 +00:00
|
|
|
nsBlockFrame::BlockNeedsFloatManager(nsIFrame* aBlock)
|
2007-02-18 23:53:25 +00:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(aBlock, "Must have a frame");
|
2008-07-13 22:10:23 +00:00
|
|
|
NS_ASSERTION(nsLayoutUtils::GetAsBlock(aBlock), "aBlock must be a block");
|
2004-09-28 18:37:50 +00:00
|
|
|
|
2007-02-18 23:53:25 +00:00
|
|
|
nsIFrame* parent = aBlock->GetParent();
|
2009-01-05 00:39:54 +00:00
|
|
|
return (aBlock->GetStateBits() & NS_BLOCK_FLOAT_MGR) ||
|
2007-02-18 23:53:25 +00:00
|
|
|
(parent && !parent->IsFloatContainingBlock());
|
2004-09-28 18:37:50 +00:00
|
|
|
}
|
2008-01-29 07:40:05 +00:00
|
|
|
|
|
|
|
/* static */
|
|
|
|
PRBool
|
|
|
|
nsBlockFrame::BlockCanIntersectFloats(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
return aFrame->IsFrameOfType(nsIFrame::eBlockFrame) &&
|
|
|
|
!aFrame->IsFrameOfType(nsIFrame::eReplaced) &&
|
2009-01-05 00:39:54 +00:00
|
|
|
!(aFrame->GetStateBits() & NS_BLOCK_FLOAT_MGR);
|
2008-01-29 07:40:05 +00:00
|
|
|
}
|
|
|
|
|
2008-04-15 01:05:17 +00:00
|
|
|
// Note that this width can vary based on the vertical position.
|
|
|
|
// However, the cases where it varies are the cases where the width fits
|
|
|
|
// in the available space given, which means that variation shouldn't
|
|
|
|
// matter.
|
2008-01-29 07:40:05 +00:00
|
|
|
/* static */
|
2008-04-15 01:05:17 +00:00
|
|
|
nsBlockFrame::ReplacedElementWidthToClear
|
2008-01-29 07:40:05 +00:00
|
|
|
nsBlockFrame::WidthToClearPastFloats(nsBlockReflowState& aState,
|
2009-04-08 20:52:37 +00:00
|
|
|
const nsRect& aFloatAvailableSpace,
|
2008-01-29 07:40:05 +00:00
|
|
|
nsIFrame* aFrame)
|
|
|
|
{
|
2008-04-15 01:05:17 +00:00
|
|
|
nscoord leftOffset, rightOffset;
|
|
|
|
nsCSSOffsetState offsetState(aFrame, aState.mReflowState.rendContext,
|
|
|
|
aState.mContentArea.width);
|
|
|
|
|
|
|
|
ReplacedElementWidthToClear result;
|
2008-01-29 07:40:05 +00:00
|
|
|
// A table outer frame is an exception in that it is a block child
|
|
|
|
// that is not a containing block for its children.
|
|
|
|
if (aFrame->GetType() == nsGkAtoms::tableOuterFrame) {
|
|
|
|
nsIFrame *innerTable = aFrame->GetFirstChild(nsnull);
|
|
|
|
nsIFrame *caption = aFrame->GetFirstChild(nsGkAtoms::captionList);
|
2008-04-15 01:05:17 +00:00
|
|
|
|
|
|
|
nsMargin tableMargin, captionMargin;
|
|
|
|
{
|
|
|
|
nsCSSOffsetState tableOS(innerTable, aState.mReflowState.rendContext,
|
|
|
|
aState.mContentArea.width);
|
|
|
|
tableMargin = tableOS.mComputedMargin;
|
|
|
|
}
|
|
|
|
|
2008-01-29 07:40:05 +00:00
|
|
|
if (caption) {
|
2008-04-15 01:05:17 +00:00
|
|
|
nsCSSOffsetState captionOS(caption, aState.mReflowState.rendContext,
|
|
|
|
aState.mContentArea.width);
|
|
|
|
captionMargin = captionOS.mComputedMargin;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRUint8 captionSide;
|
|
|
|
if (!caption ||
|
|
|
|
((captionSide = caption->GetStyleTableBorder()->mCaptionSide)
|
|
|
|
== NS_STYLE_CAPTION_SIDE_TOP ||
|
|
|
|
captionSide == NS_STYLE_CAPTION_SIDE_BOTTOM)) {
|
|
|
|
result.marginLeft = tableMargin.left;
|
|
|
|
result.marginRight = tableMargin.right;
|
|
|
|
} else if (captionSide == NS_STYLE_CAPTION_SIDE_TOP_OUTSIDE ||
|
|
|
|
captionSide == NS_STYLE_CAPTION_SIDE_BOTTOM_OUTSIDE) {
|
|
|
|
// FIXME: This doesn't treat the caption and table independently,
|
|
|
|
// since we adjust by only the smaller margin, and the table outer
|
|
|
|
// frame doesn't know about it.
|
2009-09-16 15:01:36 +00:00
|
|
|
result.marginLeft = NS_MIN(tableMargin.left, captionMargin.left);
|
|
|
|
result.marginRight = NS_MIN(tableMargin.right, captionMargin.right);
|
2008-04-15 01:05:17 +00:00
|
|
|
} else {
|
|
|
|
NS_ASSERTION(captionSide == NS_STYLE_CAPTION_SIDE_LEFT ||
|
|
|
|
captionSide == NS_STYLE_CAPTION_SIDE_RIGHT,
|
|
|
|
"unexpected caption-side");
|
|
|
|
if (captionSide == NS_STYLE_CAPTION_SIDE_LEFT) {
|
|
|
|
result.marginLeft = captionMargin.left;
|
|
|
|
result.marginRight = tableMargin.right;
|
|
|
|
} else {
|
|
|
|
result.marginLeft = tableMargin.left;
|
|
|
|
result.marginRight = captionMargin.right;
|
|
|
|
}
|
2008-01-29 07:40:05 +00:00
|
|
|
}
|
2008-04-15 01:05:17 +00:00
|
|
|
|
2009-04-08 20:52:37 +00:00
|
|
|
aState.ComputeReplacedBlockOffsetsForFloats(aFrame, aFloatAvailableSpace,
|
|
|
|
leftOffset, rightOffset,
|
2008-04-15 01:05:17 +00:00
|
|
|
&result);
|
|
|
|
|
2008-05-01 15:14:36 +00:00
|
|
|
// result.marginLeft has already been subtracted from leftOffset (etc.)
|
|
|
|
nscoord availWidth = aState.mContentArea.width - leftOffset - rightOffset;
|
2008-04-15 01:05:17 +00:00
|
|
|
// Force the outer frame to shrink-wrap (otherwise it just sizes to
|
|
|
|
// the available width unconditionally).
|
|
|
|
result.borderBoxWidth =
|
|
|
|
aFrame->ComputeSize(aState.mReflowState.rendContext,
|
|
|
|
nsSize(aState.mContentArea.width,
|
|
|
|
NS_UNCONSTRAINEDSIZE),
|
|
|
|
availWidth,
|
|
|
|
nsSize(offsetState.mComputedMargin.LeftRight(),
|
|
|
|
offsetState.mComputedMargin.TopBottom()),
|
|
|
|
nsSize(offsetState.mComputedBorderPadding.LeftRight() -
|
|
|
|
offsetState.mComputedPadding.LeftRight(),
|
|
|
|
offsetState.mComputedBorderPadding.TopBottom() -
|
|
|
|
offsetState.mComputedPadding.TopBottom()),
|
|
|
|
nsSize(offsetState.mComputedPadding.LeftRight(),
|
|
|
|
offsetState.mComputedPadding.TopBottom()),
|
|
|
|
PR_TRUE).width +
|
|
|
|
offsetState.mComputedBorderPadding.LeftRight() -
|
|
|
|
(result.marginLeft + result.marginRight);
|
2008-01-29 07:40:05 +00:00
|
|
|
} else {
|
2009-04-08 20:52:37 +00:00
|
|
|
aState.ComputeReplacedBlockOffsetsForFloats(aFrame, aFloatAvailableSpace,
|
|
|
|
leftOffset, rightOffset);
|
2008-04-15 01:05:17 +00:00
|
|
|
nscoord availWidth = aState.mContentArea.width - leftOffset - rightOffset;
|
|
|
|
|
|
|
|
// We actually don't want the min width here; see bug 427782; we only
|
|
|
|
// want to displace if the width won't compute to a value small enough
|
|
|
|
// to fit.
|
|
|
|
// All we really need here is the result of ComputeSize, and we
|
|
|
|
// could *almost* get that from an nsCSSOffsetState, except for the
|
|
|
|
// last argument.
|
|
|
|
nsSize availSpace(availWidth, NS_UNCONSTRAINEDSIZE);
|
|
|
|
nsHTMLReflowState reflowState(aState.mPresContext, aState.mReflowState,
|
|
|
|
aFrame, availSpace);
|
|
|
|
result.borderBoxWidth = reflowState.ComputedWidth() +
|
|
|
|
reflowState.mComputedBorderPadding.LeftRight();
|
|
|
|
// Use the margins from offsetState rather than reflowState so that
|
|
|
|
// they aren't reduced by ignoring margins in overconstrained cases.
|
|
|
|
result.marginLeft = offsetState.mComputedMargin.left;
|
|
|
|
result.marginRight = offsetState.mComputedMargin.right;
|
2008-01-29 07:40:05 +00:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
2007-09-03 07:00:10 +00:00
|
|
|
|
2007-10-19 17:41:29 +00:00
|
|
|
/* static */
|
|
|
|
nsBlockFrame*
|
|
|
|
nsBlockFrame::GetNearestAncestorBlock(nsIFrame* aCandidate)
|
|
|
|
{
|
|
|
|
nsBlockFrame* block = nsnull;
|
|
|
|
while(aCandidate) {
|
2008-07-13 22:10:23 +00:00
|
|
|
block = nsLayoutUtils::GetAsBlock(aCandidate);
|
2007-10-19 17:41:29 +00:00
|
|
|
if (block) {
|
|
|
|
// yay, candidate is a block!
|
|
|
|
return block;
|
|
|
|
}
|
|
|
|
// Not a block. Check its parent next.
|
|
|
|
aCandidate = aCandidate->GetParent();
|
|
|
|
}
|
|
|
|
NS_NOTREACHED("Fell off frame tree looking for ancestor block!");
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
2011-01-19 22:39:31 +00:00
|
|
|
nscoord
|
|
|
|
nsBlockFrame::GetEffectiveComputedHeight(const nsHTMLReflowState& aReflowState) const
|
|
|
|
{
|
|
|
|
nscoord height = aReflowState.ComputedHeight();
|
|
|
|
NS_ABORT_IF_FALSE(height != NS_UNCONSTRAINEDSIZE, "Don't call me!");
|
|
|
|
|
|
|
|
if (GetPrevInFlow()) {
|
|
|
|
// Reduce the height by the computed height of prev-in-flows.
|
|
|
|
for (nsIFrame* prev = GetPrevInFlow(); prev; prev = prev->GetPrevInFlow()) {
|
|
|
|
height -= prev->GetRect().height;
|
|
|
|
}
|
|
|
|
// We just subtracted our top-border padding, since it was included in the
|
|
|
|
// first frame's height. Add it back to get the content height.
|
|
|
|
height += aReflowState.mComputedBorderPadding.top;
|
|
|
|
// We may have stretched the frame beyond its computed height. Oh well.
|
|
|
|
height = NS_MAX(0, height);
|
|
|
|
}
|
|
|
|
return height;
|
|
|
|
}
|
|
|
|
|
2007-02-11 07:19:09 +00:00
|
|
|
#ifdef IBMBIDI
|
2007-05-28 14:40:56 +00:00
|
|
|
nsresult
|
|
|
|
nsBlockFrame::ResolveBidi()
|
|
|
|
{
|
2007-09-03 06:51:11 +00:00
|
|
|
NS_ASSERTION(!GetPrevInFlow(),
|
|
|
|
"ResolveBidi called on non-first continuation");
|
|
|
|
|
|
|
|
nsPresContext* presContext = PresContext();
|
|
|
|
if (!presContext->BidiEnabled()) {
|
2007-05-28 14:40:56 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-04-27 08:47:18 +00:00
|
|
|
nsBidiPresUtils* bidiUtils = presContext->GetBidiUtils();
|
|
|
|
if (!bidiUtils)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
return bidiUtils->Resolve(this);
|
2007-02-11 07:19:09 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1999-03-16 19:36:00 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
void
|
1999-04-20 00:27:43 +00:00
|
|
|
nsBlockFrame::VerifyLines(PRBool aFinalCheckOK)
|
1999-03-16 19:36:00 +00:00
|
|
|
{
|
1999-10-19 23:04:19 +00:00
|
|
|
if (!gVerifyLines) {
|
|
|
|
return;
|
|
|
|
}
|
2001-10-25 01:08:40 +00:00
|
|
|
if (mLines.empty()) {
|
1999-04-20 00:27:43 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add up the counts on each line. Also validate that IsFirstLine is
|
|
|
|
// set properly.
|
|
|
|
PRInt32 count = 0;
|
|
|
|
PRBool seenBlock = PR_FALSE;
|
2001-10-25 01:08:40 +00:00
|
|
|
line_iterator line, line_end;
|
|
|
|
for (line = begin_lines(), line_end = end_lines();
|
|
|
|
line != line_end;
|
|
|
|
++line) {
|
1999-04-20 00:27:43 +00:00
|
|
|
if (aFinalCheckOK) {
|
1999-10-14 23:10:03 +00:00
|
|
|
NS_ABORT_IF_FALSE(line->GetChildCount(), "empty line");
|
1999-04-20 00:27:43 +00:00
|
|
|
if (line->IsBlock()) {
|
|
|
|
seenBlock = PR_TRUE;
|
|
|
|
}
|
1999-08-31 03:09:40 +00:00
|
|
|
if (line->IsBlock()) {
|
1999-10-14 23:10:03 +00:00
|
|
|
NS_ASSERTION(1 == line->GetChildCount(), "bad first line");
|
1999-04-20 00:27:43 +00:00
|
|
|
}
|
1999-03-16 19:36:00 +00:00
|
|
|
}
|
1999-10-14 23:10:03 +00:00
|
|
|
count += line->GetChildCount();
|
1999-04-20 00:27:43 +00:00
|
|
|
}
|
1999-03-16 19:36:00 +00:00
|
|
|
|
1999-04-20 00:27:43 +00:00
|
|
|
// Then count the frames
|
|
|
|
PRInt32 frameCount = 0;
|
2001-10-25 01:08:40 +00:00
|
|
|
nsIFrame* frame = mLines.front()->mFirstChild;
|
2003-06-26 11:30:17 +00:00
|
|
|
while (frame) {
|
1999-04-20 00:27:43 +00:00
|
|
|
frameCount++;
|
2003-06-26 11:30:17 +00:00
|
|
|
frame = frame->GetNextSibling();
|
1999-04-20 00:27:43 +00:00
|
|
|
}
|
|
|
|
NS_ASSERTION(count == frameCount, "bad line list");
|
|
|
|
|
|
|
|
// Next: test that each line has right number of frames on it
|
2001-10-25 01:08:40 +00:00
|
|
|
for (line = begin_lines(), line_end = end_lines();
|
|
|
|
line != line_end;
|
|
|
|
) {
|
1999-10-14 23:10:03 +00:00
|
|
|
count = line->GetChildCount();
|
1999-04-20 00:27:43 +00:00
|
|
|
frame = line->mFirstChild;
|
|
|
|
while (--count >= 0) {
|
2003-06-26 11:30:17 +00:00
|
|
|
frame = frame->GetNextSibling();
|
1999-03-16 19:36:00 +00:00
|
|
|
}
|
2001-10-25 01:08:40 +00:00
|
|
|
++line;
|
|
|
|
if ((line != line_end) && (0 != line->GetChildCount())) {
|
1999-04-20 00:27:43 +00:00
|
|
|
NS_ASSERTION(frame == line->mFirstChild, "bad line list");
|
1999-03-16 19:36:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Its possible that a frame can have some frames on an overflow
|
|
|
|
// list. But its never possible for multiple frames to have overflow
|
|
|
|
// lists. Check that this fact is actually true.
|
|
|
|
void
|
2004-06-01 06:20:16 +00:00
|
|
|
nsBlockFrame::VerifyOverflowSituation()
|
1999-03-16 19:36:00 +00:00
|
|
|
{
|
|
|
|
nsBlockFrame* flow = (nsBlockFrame*) GetFirstInFlow();
|
|
|
|
while (nsnull != flow) {
|
2004-06-01 06:20:16 +00:00
|
|
|
nsLineList* overflowLines = GetOverflowLines();
|
1999-11-02 23:42:52 +00:00
|
|
|
if (nsnull != overflowLines) {
|
2001-10-25 01:08:40 +00:00
|
|
|
NS_ASSERTION(! overflowLines->empty(), "should not be empty if present");
|
|
|
|
NS_ASSERTION(overflowLines->front()->mFirstChild, "bad overflow list");
|
1999-03-16 19:36:00 +00:00
|
|
|
}
|
2006-02-21 21:33:47 +00:00
|
|
|
flow = (nsBlockFrame*) flow->GetNextInFlow();
|
1999-03-16 19:36:00 +00:00
|
|
|
}
|
|
|
|
}
|
1999-03-22 22:42:30 +00:00
|
|
|
|
|
|
|
PRInt32
|
|
|
|
nsBlockFrame::GetDepth() const
|
|
|
|
{
|
|
|
|
PRInt32 depth = 0;
|
|
|
|
nsIFrame* parent = mParent;
|
2003-06-26 11:30:17 +00:00
|
|
|
while (parent) {
|
|
|
|
parent = parent->GetParent();
|
1999-03-22 22:42:30 +00:00
|
|
|
depth++;
|
|
|
|
}
|
|
|
|
return depth;
|
|
|
|
}
|
1999-03-16 19:36:00 +00:00
|
|
|
#endif
|