2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
// vim:cindent:ts=2:et:sw=2:
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/*
|
2007-12-12 13:49:14 -08:00
|
|
|
* rendering object for CSS display:block, inline-block, and list-item
|
|
|
|
* boxes, also used for various anonymous boxes
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
|
|
|
|
2013-09-24 18:43:43 -07:00
|
|
|
#include "nsBlockFrame.h"
|
|
|
|
|
2012-12-14 15:58:45 -08:00
|
|
|
#include "mozilla/DebugOnly.h"
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsCOMPtr.h"
|
2012-08-08 06:05:17 -07:00
|
|
|
#include "nsAbsoluteContainingBlock.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsBlockReflowContext.h"
|
|
|
|
#include "nsBlockReflowState.h"
|
|
|
|
#include "nsBulletFrame.h"
|
|
|
|
#include "nsLineBox.h"
|
|
|
|
#include "nsLineLayout.h"
|
|
|
|
#include "nsPlaceholderFrame.h"
|
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsFrameManager.h"
|
|
|
|
#include "nsPresContext.h"
|
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsStyleContext.h"
|
|
|
|
#include "nsHTMLParts.h"
|
|
|
|
#include "nsGkAtoms.h"
|
|
|
|
#include "nsGenericHTMLElement.h"
|
2012-09-30 09:40:24 -07:00
|
|
|
#include "nsAttrValueInlines.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "prprf.h"
|
2009-01-04 16:39:54 -08:00
|
|
|
#include "nsFloatManager.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "prenv.h"
|
|
|
|
#include "plstr.h"
|
2012-07-27 07:03:27 -07:00
|
|
|
#include "nsError.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsIScrollableFrame.h"
|
2013-01-15 04:22:03 -08:00
|
|
|
#include <algorithm>
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef ACCESSIBILITY
|
|
|
|
#include "nsIDOMHTMLDocument.h"
|
|
|
|
#endif
|
|
|
|
#include "nsLayoutUtils.h"
|
|
|
|
#include "nsDisplayList.h"
|
2007-04-20 20:57:40 -07:00
|
|
|
#include "nsCSSAnonBoxes.h"
|
2009-09-18 04:09:35 -07:00
|
|
|
#include "nsCSSFrameConstructor.h"
|
2011-04-07 18:04:40 -07:00
|
|
|
#include "nsRenderingContext.h"
|
2011-06-22 11:11:48 -07:00
|
|
|
#include "TextOverflow.h"
|
2013-10-01 14:00:38 -07:00
|
|
|
#include "nsIFrameInlines.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifdef IBMBIDI
|
|
|
|
#include "nsBidiPresUtils.h"
|
|
|
|
#endif // IBMBIDI
|
|
|
|
|
|
|
|
static const int MIN_LINES_NEEDING_CURSOR = 20;
|
|
|
|
|
2014-01-04 07:02:17 -08:00
|
|
|
static const char16_t kDiscCharacter = 0x2022;
|
|
|
|
static const char16_t kCircleCharacter = 0x25e6;
|
|
|
|
static const char16_t kSquareCharacter = 0x25aa;
|
2010-10-15 08:34:24 -07:00
|
|
|
|
2008-08-12 02:32:10 -07:00
|
|
|
#define DISABLE_FLOAT_BREAKING_IN_COLUMNS
|
|
|
|
|
2010-03-28 18:46:55 -07:00
|
|
|
using namespace mozilla;
|
2011-06-22 11:11:48 -07:00
|
|
|
using namespace mozilla::css;
|
2013-04-01 08:26:02 -07:00
|
|
|
using namespace mozilla::layout;
|
2010-03-28 18:46:55 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
#include "nsBlockDebugFlags.h"
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool nsBlockFrame::gLamePaintMetrics;
|
|
|
|
bool nsBlockFrame::gLameReflowMetrics;
|
|
|
|
bool nsBlockFrame::gNoisy;
|
|
|
|
bool nsBlockFrame::gNoisyDamageRepair;
|
|
|
|
bool nsBlockFrame::gNoisyIntrinsic;
|
|
|
|
bool nsBlockFrame::gNoisyReflow;
|
|
|
|
bool nsBlockFrame::gReallyNoisyReflow;
|
|
|
|
bool nsBlockFrame::gNoisyFloatManager;
|
|
|
|
bool nsBlockFrame::gVerifyLines;
|
|
|
|
bool nsBlockFrame::gDisableResizeOpt;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t nsBlockFrame::gNoiseIndent;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
struct BlockDebugFlags {
|
|
|
|
const char* name;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool* on;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
static const BlockDebugFlags gFlags[] = {
|
|
|
|
{ "reflow", &nsBlockFrame::gNoisyReflow },
|
|
|
|
{ "really-noisy-reflow", &nsBlockFrame::gReallyNoisyReflow },
|
|
|
|
{ "intrinsic", &nsBlockFrame::gNoisyIntrinsic },
|
2009-01-04 16:39:54 -08:00
|
|
|
{ "float-manager", &nsBlockFrame::gNoisyFloatManager },
|
2007-03-22 10:30:00 -07:00
|
|
|
{ "verify-lines", &nsBlockFrame::gVerifyLines },
|
|
|
|
{ "damage-repair", &nsBlockFrame::gNoisyDamageRepair },
|
|
|
|
{ "lame-paint-metrics", &nsBlockFrame::gLamePaintMetrics },
|
|
|
|
{ "lame-reflow-metrics", &nsBlockFrame::gLameReflowMetrics },
|
|
|
|
{ "disable-resize-opt", &nsBlockFrame::gDisableResizeOpt },
|
|
|
|
};
|
|
|
|
#define NUM_DEBUG_FLAGS (sizeof(gFlags) / sizeof(gFlags[0]))
|
|
|
|
|
|
|
|
static void
|
|
|
|
ShowDebugFlags()
|
|
|
|
{
|
|
|
|
printf("Here are the available GECKO_BLOCK_DEBUG_FLAGS:\n");
|
|
|
|
const BlockDebugFlags* bdf = gFlags;
|
|
|
|
const BlockDebugFlags* end = gFlags + NUM_DEBUG_FLAGS;
|
|
|
|
for (; bdf < end; bdf++) {
|
|
|
|
printf(" %s\n", bdf->name);
|
|
|
|
}
|
|
|
|
printf("Note: GECKO_BLOCK_DEBUG_FLAGS is a comma separated list of flag\n");
|
|
|
|
printf("names (no whitespace)\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBlockFrame::InitDebugFlags()
|
|
|
|
{
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool firstTime = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (firstTime) {
|
2011-10-17 07:59:28 -07:00
|
|
|
firstTime = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
char* flags = PR_GetEnv("GECKO_BLOCK_DEBUG_FLAGS");
|
|
|
|
if (flags) {
|
2011-09-28 23:19:26 -07:00
|
|
|
bool error = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
for (;;) {
|
|
|
|
char* cm = PL_strchr(flags, ',');
|
|
|
|
if (cm) *cm = '\0';
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool found = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
const BlockDebugFlags* bdf = gFlags;
|
|
|
|
const BlockDebugFlags* end = gFlags + NUM_DEBUG_FLAGS;
|
|
|
|
for (; bdf < end; bdf++) {
|
|
|
|
if (PL_strcasecmp(bdf->name, flags) == 0) {
|
2011-10-17 07:59:28 -07:00
|
|
|
*(bdf->on) = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
printf("nsBlockFrame: setting %s debug flag on\n", bdf->name);
|
2011-10-17 07:59:28 -07:00
|
|
|
gNoisy = true;
|
|
|
|
found = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found) {
|
2011-10-17 07:59:28 -07:00
|
|
|
error = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!cm) break;
|
|
|
|
*cm = ',';
|
|
|
|
flags = cm + 1;
|
|
|
|
}
|
|
|
|
if (error) {
|
|
|
|
ShowDebugFlags();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Debugging support code
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
const char* nsBlockFrame::kReflowCommandType[] = {
|
|
|
|
"ContentChanged",
|
|
|
|
"StyleChanged",
|
|
|
|
"ReflowDirty",
|
|
|
|
"Timeout",
|
|
|
|
"UserDefined",
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef REALLY_NOISY_FIRST_LINE
|
|
|
|
static void
|
|
|
|
DumpStyleGeneaology(nsIFrame* aFrame, const char* gap)
|
|
|
|
{
|
|
|
|
fputs(gap, stdout);
|
|
|
|
nsFrame::ListTag(stdout, aFrame);
|
|
|
|
printf(": ");
|
2013-02-15 21:38:33 -08:00
|
|
|
nsStyleContext* sc = aFrame->StyleContext();
|
2012-07-30 07:20:58 -07:00
|
|
|
while (nullptr != sc) {
|
2007-03-22 10:30:00 -07:00
|
|
|
nsStyleContext* psc;
|
|
|
|
printf("%p ", sc);
|
|
|
|
psc = sc->GetParent();
|
|
|
|
sc = psc;
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef REFLOW_STATUS_COVERAGE
|
|
|
|
static void
|
2011-09-28 23:19:26 -07:00
|
|
|
RecordReflowStatus(bool aChildIsBlock, nsReflowStatus aFrameReflowStatus)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
static uint32_t record[2];
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// 0: child-is-block
|
|
|
|
// 1: child-is-inline
|
2012-08-09 00:09:40 -07:00
|
|
|
int index = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!aChildIsBlock) index |= 1;
|
|
|
|
|
|
|
|
// Compute new status
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t newS = record[index];
|
2007-03-22 10:30:00 -07:00
|
|
|
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;
|
|
|
|
printf("record(%d): %02x %02x\n", index, record[0], record[1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-03-28 18:46:55 -07: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(OverflowLinesProperty, DestroyOverflowLines)
|
2013-04-01 08:26:02 -07:00
|
|
|
NS_DECLARE_FRAME_PROPERTY_FRAMELIST(OverflowOutOfFlowsProperty)
|
|
|
|
NS_DECLARE_FRAME_PROPERTY_FRAMELIST(PushedFloatProperty)
|
|
|
|
NS_DECLARE_FRAME_PROPERTY_FRAMELIST(OutsideBulletProperty)
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_DECLARE_FRAME_PROPERTY(InsideBulletProperty, nullptr)
|
2010-03-28 18:46:55 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
nsIFrame*
|
2014-02-04 17:59:39 -08:00
|
|
|
NS_NewBlockFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, nsFrameState aFlags)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsBlockFrame* it = new (aPresShell) nsBlockFrame(aContext);
|
2012-11-07 11:55:53 -08:00
|
|
|
it->SetFlags(aFlags);
|
2007-03-22 10:30:00 -07:00
|
|
|
return it;
|
|
|
|
}
|
|
|
|
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsBlockFrame)
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsBlockFrame::~nsBlockFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-12-23 21:21:15 -08:00
|
|
|
nsBlockFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-05-03 17:14:01 -07:00
|
|
|
ClearLineCursor();
|
2011-04-29 16:02:33 -07:00
|
|
|
DestroyAbsoluteFrames(aDestructRoot);
|
2009-12-23 21:21:15 -08:00
|
|
|
mFloats.DestroyFramesFrom(aDestructRoot);
|
2007-03-30 14:11:41 -07:00
|
|
|
nsPresContext* presContext = PresContext();
|
2013-04-01 08:26:02 -07:00
|
|
|
nsIPresShell* shell = presContext->PresShell();
|
2012-10-14 18:34:23 -07:00
|
|
|
nsLineBox::DeleteLineList(presContext, mLines, aDestructRoot,
|
|
|
|
&mFrames);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-04-01 08:26:02 -07:00
|
|
|
FramePropertyTable* props = presContext->PropertyTable();
|
|
|
|
|
|
|
|
if (HasPushedFloats()) {
|
2013-04-01 08:26:02 -07:00
|
|
|
SafelyDestroyFrameListProp(aDestructRoot, shell, props,
|
2013-04-01 08:26:02 -07:00
|
|
|
PushedFloatProperty());
|
|
|
|
RemoveStateBits(NS_BLOCK_HAS_PUSHED_FLOATS);
|
2010-08-19 06:38:00 -07:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// destroy overflow lines now
|
2012-03-07 17:57:37 -08:00
|
|
|
FrameLines* overflowLines = RemoveOverflowLines();
|
2007-03-22 10:30:00 -07:00
|
|
|
if (overflowLines) {
|
2012-03-07 17:57:37 -08:00
|
|
|
nsLineBox::DeleteLineList(presContext, overflowLines->mLines,
|
2012-10-14 18:34:23 -07:00
|
|
|
aDestructRoot, &overflowLines->mFrames);
|
2009-09-28 18:23:33 -07:00
|
|
|
delete overflowLines;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-04-01 08:26:02 -07:00
|
|
|
if (GetStateBits() & NS_BLOCK_HAS_OVERFLOW_OUT_OF_FLOWS) {
|
2013-04-01 08:26:02 -07:00
|
|
|
SafelyDestroyFrameListProp(aDestructRoot, shell, props,
|
2013-04-01 08:26:02 -07:00
|
|
|
OverflowOutOfFlowsProperty());
|
|
|
|
RemoveStateBits(NS_BLOCK_HAS_OVERFLOW_OUT_OF_FLOWS);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (HasOutsideBullet()) {
|
2013-04-01 08:26:02 -07:00
|
|
|
SafelyDestroyFrameListProp(aDestructRoot, shell, props,
|
2013-04-01 08:26:02 -07:00
|
|
|
OutsideBulletProperty());
|
|
|
|
RemoveStateBits(NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2009-12-23 21:21:15 -08:00
|
|
|
nsBlockFrameSuper::DestroyFrom(aDestructRoot);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2008-10-30 12:17:59 -07:00
|
|
|
/* virtual */ nsILineIterator*
|
|
|
|
nsBlockFrame::GetLineIterator()
|
|
|
|
{
|
|
|
|
nsLineIterator* it = new nsLineIterator;
|
|
|
|
if (!it)
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2008-10-30 12:17:59 -07:00
|
|
|
|
2013-02-16 13:51:02 -08:00
|
|
|
const nsStyleVisibility* visibility = StyleVisibility();
|
2008-10-30 12:17:59 -07:00
|
|
|
nsresult rv = it->Init(mLines, visibility->mDirection == NS_STYLE_DIRECTION_RTL);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
delete it;
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2008-10-30 12:17:59 -07:00
|
|
|
}
|
|
|
|
return it;
|
|
|
|
}
|
|
|
|
|
2009-01-12 11:20:59 -08:00
|
|
|
NS_QUERYFRAME_HEAD(nsBlockFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsBlockFrame)
|
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsBlockFrameSuper)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsSplittableType
|
|
|
|
nsBlockFrame::GetSplittableType() const
|
|
|
|
{
|
|
|
|
return NS_FRAME_SPLITTABLE_NON_RECTANGULAR;
|
|
|
|
}
|
|
|
|
|
2014-01-05 15:31:14 -08:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2013-04-30 11:38:52 -07:00
|
|
|
void
|
2014-01-26 14:07:02 -08:00
|
|
|
nsBlockFrame::List(FILE* out, const char* aPrefix, uint32_t aFlags) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2014-01-26 14:07:02 -08:00
|
|
|
nsCString str;
|
|
|
|
ListGeneric(str, aPrefix, aFlags);
|
2009-10-15 19:47:03 -07:00
|
|
|
|
2014-01-26 14:07:02 -08:00
|
|
|
fprintf_stderr(out, "%s<\n", str.get());
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-01-26 14:07:02 -08:00
|
|
|
nsCString pfx(aPrefix);
|
|
|
|
pfx += " ";
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Output the lines
|
2008-10-12 15:33:20 -07:00
|
|
|
if (!mLines.empty()) {
|
|
|
|
const_line_iterator line = begin_lines(), line_end = end_lines();
|
|
|
|
for ( ; line != line_end; ++line) {
|
2014-01-26 14:07:02 -08:00
|
|
|
line->List(out, pfx.get(), aFlags);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-12 15:33:20 -07:00
|
|
|
// Output the overflow lines.
|
2012-03-07 17:57:37 -08:00
|
|
|
const FrameLines* overflowLines = GetOverflowLines();
|
|
|
|
if (overflowLines && !overflowLines->mLines.empty()) {
|
2014-01-26 14:07:02 -08:00
|
|
|
fprintf_stderr(out, "%sOverflow-lines %p/%p <\n", pfx.get(), overflowLines, &overflowLines->mFrames);
|
|
|
|
nsCString nestedPfx(pfx);
|
|
|
|
nestedPfx += " ";
|
2012-03-07 17:57:37 -08:00
|
|
|
const_line_iterator line = overflowLines->mLines.begin(),
|
|
|
|
line_end = overflowLines->mLines.end();
|
2008-10-12 15:33:20 -07:00
|
|
|
for ( ; line != line_end; ++line) {
|
2014-01-26 14:07:02 -08:00
|
|
|
line->List(out, nestedPfx.get(), aFlags);
|
2008-10-12 15:33:20 -07:00
|
|
|
}
|
2014-01-26 14:07:02 -08:00
|
|
|
fprintf_stderr(out, "%s>\n", pfx.get());
|
2008-10-12 15:33:20 -07:00
|
|
|
}
|
|
|
|
|
2011-08-24 13:54:29 -07:00
|
|
|
// skip the principal list - we printed the lines above
|
|
|
|
// skip the overflow list - we printed the overflow lines above
|
|
|
|
ChildListIterator lists(this);
|
|
|
|
ChildListIDs skip(kPrincipalList | kOverflowList);
|
|
|
|
for (; !lists.IsDone(); lists.Next()) {
|
|
|
|
if (skip.Contains(lists.CurrentID())) {
|
|
|
|
continue;
|
2008-10-12 15:33:20 -07:00
|
|
|
}
|
2014-01-26 14:07:02 -08:00
|
|
|
fprintf_stderr(out, "%s%s %p <\n", pfx.get(),
|
|
|
|
mozilla::layout::ChildListName(lists.CurrentID()),
|
|
|
|
&GetChildList(lists.CurrentID()));
|
|
|
|
nsCString nestedPfx(pfx);
|
|
|
|
nestedPfx += " ";
|
2011-08-24 13:54:29 -07:00
|
|
|
nsFrameList::Enumerator childFrames(lists.CurrentList());
|
|
|
|
for (; !childFrames.AtEnd(); childFrames.Next()) {
|
|
|
|
nsIFrame* kid = childFrames.get();
|
2014-01-26 14:07:02 -08:00
|
|
|
kid->List(out, nestedPfx.get(), aFlags);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2014-01-26 14:07:02 -08:00
|
|
|
fprintf_stderr(out, "%s>\n", pfx.get());
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2014-01-26 14:07:02 -08:00
|
|
|
fprintf_stderr(out, "%s>\n", aPrefix);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2014-02-17 23:47:48 -08:00
|
|
|
nsresult
|
2014-01-05 15:31:14 -08:00
|
|
|
nsBlockFrame::GetFrameName(nsAString& aResult) const
|
|
|
|
{
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("Block"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2014-02-17 23:47:48 -08:00
|
|
|
nsFrameState
|
2007-03-22 10:30:00 -07:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nsIAtom*
|
|
|
|
nsBlockFrame::GetType() const
|
|
|
|
{
|
|
|
|
return nsGkAtoms::blockFrame;
|
|
|
|
}
|
|
|
|
|
2013-02-10 22:22:20 -08:00
|
|
|
void
|
|
|
|
nsBlockFrame::InvalidateFrame(uint32_t aDisplayItemKey)
|
|
|
|
{
|
|
|
|
if (IsSVGText()) {
|
2013-12-20 08:38:51 -08:00
|
|
|
NS_ASSERTION(GetParent()->GetType() == nsGkAtoms::svgTextFrame,
|
2013-02-10 22:22:20 -08:00
|
|
|
"unexpected block frame in SVG text");
|
|
|
|
GetParent()->InvalidateFrame();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
nsBlockFrameSuper::InvalidateFrame(aDisplayItemKey);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBlockFrame::InvalidateFrameWithRect(const nsRect& aRect, uint32_t aDisplayItemKey)
|
|
|
|
{
|
|
|
|
if (IsSVGText()) {
|
2013-12-20 08:38:51 -08:00
|
|
|
NS_ASSERTION(GetParent()->GetType() == nsGkAtoms::svgTextFrame,
|
2013-02-10 22:22:20 -08:00
|
|
|
"unexpected block frame in SVG text");
|
|
|
|
GetParent()->InvalidateFrame();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
nsBlockFrameSuper::InvalidateFrameWithRect(aRect, aDisplayItemKey);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nscoord
|
|
|
|
nsBlockFrame::GetBaseline() const
|
|
|
|
{
|
|
|
|
nscoord result;
|
|
|
|
if (nsLayoutUtils::GetLastLineBaseline(this, &result))
|
|
|
|
return result;
|
|
|
|
return nsFrame::GetBaseline();
|
|
|
|
}
|
|
|
|
|
2010-08-31 11:54:44 -07: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-07 18:05:49 -07:00
|
|
|
nsRefPtr<nsFontMetrics> fm;
|
2012-05-20 22:18:28 -07:00
|
|
|
float inflation = nsLayoutUtils::FontSizeInflationFor(this);
|
2012-01-24 17:21:29 -08:00
|
|
|
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm), inflation);
|
2014-03-12 20:33:21 -07:00
|
|
|
nscoord lineHeight =
|
|
|
|
nsHTMLReflowState::CalcLineHeight(GetContent(), StyleContext(),
|
|
|
|
contentRect.height, inflation);
|
|
|
|
return nsLayoutUtils::GetCenteredFontBaseline(fm, lineHeight) + bp.top;
|
2010-08-31 11:54:44 -07:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Child frame enumeration
|
|
|
|
|
2012-03-07 17:57:37 -08:00
|
|
|
const nsFrameList&
|
2011-08-24 13:54:29 -07:00
|
|
|
nsBlockFrame::GetChildList(ChildListID aListID) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-08-24 13:54:29 -07:00
|
|
|
switch (aListID) {
|
|
|
|
case kPrincipalList:
|
|
|
|
return mFrames;
|
|
|
|
case kOverflowList: {
|
2012-03-07 17:57:37 -08:00
|
|
|
FrameLines* overflowLines = GetOverflowLines();
|
|
|
|
return overflowLines ? overflowLines->mFrames : nsFrameList::EmptyList();
|
2011-08-24 13:54:29 -07:00
|
|
|
}
|
|
|
|
case kFloatList:
|
|
|
|
return mFloats;
|
|
|
|
case kOverflowOutOfFlowList: {
|
|
|
|
const nsFrameList* list = GetOverflowOutOfFlows();
|
|
|
|
return list ? *list : nsFrameList::EmptyList();
|
|
|
|
}
|
|
|
|
case kPushedFloatsList: {
|
|
|
|
const nsFrameList* list = GetPushedFloats();
|
|
|
|
return list ? *list : nsFrameList::EmptyList();
|
|
|
|
}
|
2012-03-07 17:57:37 -08:00
|
|
|
case kBulletList: {
|
|
|
|
const nsFrameList* list = GetOutsideBulletList();
|
|
|
|
return list ? *list : nsFrameList::EmptyList();
|
|
|
|
}
|
2011-08-24 13:54:29 -07:00
|
|
|
default:
|
|
|
|
return nsContainerFrame::GetChildList(aListID);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-24 13:54:29 -07:00
|
|
|
void
|
|
|
|
nsBlockFrame::GetChildLists(nsTArray<ChildList>* aLists) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-08-24 13:54:29 -07:00
|
|
|
nsContainerFrame::GetChildLists(aLists);
|
2012-03-07 17:57:37 -08:00
|
|
|
FrameLines* overflowLines = GetOverflowLines();
|
|
|
|
if (overflowLines) {
|
|
|
|
overflowLines->mFrames.AppendIfNonempty(aLists, kOverflowList);
|
2011-08-24 13:54:29 -07:00
|
|
|
}
|
|
|
|
const nsFrameList* list = GetOverflowOutOfFlows();
|
|
|
|
if (list) {
|
|
|
|
list->AppendIfNonempty(aLists, kOverflowOutOfFlowList);
|
|
|
|
}
|
|
|
|
mFloats.AppendIfNonempty(aLists, kFloatList);
|
2012-03-07 17:57:37 -08:00
|
|
|
list = GetOutsideBulletList();
|
|
|
|
if (list) {
|
|
|
|
list->AppendIfNonempty(aLists, kBulletList);
|
2011-08-24 13:54:29 -07:00
|
|
|
}
|
|
|
|
list = GetPushedFloats();
|
|
|
|
if (list) {
|
|
|
|
list->AppendIfNonempty(aLists, kPushedFloatsList);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
/* virtual */ bool
|
2007-03-22 10:30:00 -07:00
|
|
|
nsBlockFrame::IsFloatContainingBlock() const
|
|
|
|
{
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-03-07 17:57:37 -08:00
|
|
|
static void
|
|
|
|
ReparentFrame(nsIFrame* aFrame, nsIFrame* aOldParent, nsIFrame* aNewParent)
|
|
|
|
{
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ASSERTION(aOldParent == aFrame->GetParent(),
|
2009-08-25 21:50:41 -07:00
|
|
|
"Parent not consistent with expectations");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
aFrame->SetParent(aNewParent);
|
|
|
|
|
|
|
|
// When pushing and pulling frames we need to check for whether any
|
|
|
|
// views need to be reparented
|
2014-02-06 14:07:47 -08:00
|
|
|
nsContainerFrame::ReparentFrameView(aFrame, aOldParent, aNewParent);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-03-07 17:57:37 -08:00
|
|
|
static void
|
|
|
|
ReparentFrames(nsFrameList& aFrameList, nsIFrame* aOldParent,
|
|
|
|
nsIFrame* aNewParent)
|
|
|
|
{
|
|
|
|
for (nsFrameList::Enumerator e(aFrameList); !e.AtEnd(); e.Next()) {
|
|
|
|
ReparentFrame(e.get(), aOldParent, aNewParent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove the first line from aFromLines and adjust the associated frame list
|
|
|
|
* aFromFrames accordingly. The removed line is assigned to *aOutLine and
|
|
|
|
* a frame list with its frames is assigned to *aOutFrames, i.e. the frames
|
|
|
|
* that were extracted from the head of aFromFrames.
|
|
|
|
* aFromLines must contain at least one line, the line may be empty.
|
|
|
|
* @return true if aFromLines becomes empty
|
|
|
|
*/
|
|
|
|
static bool
|
|
|
|
RemoveFirstLine(nsLineList& aFromLines, nsFrameList& aFromFrames,
|
|
|
|
nsLineBox** aOutLine, nsFrameList* aOutFrames)
|
|
|
|
{
|
|
|
|
nsLineList_iterator removedLine = aFromLines.begin();
|
|
|
|
*aOutLine = removedLine;
|
|
|
|
nsLineList_iterator next = aFromLines.erase(removedLine);
|
|
|
|
bool isLastLine = next == aFromLines.end();
|
|
|
|
nsIFrame* lastFrame = isLastLine ? aFromFrames.LastChild()
|
|
|
|
: next->mFirstChild->GetPrevSibling();
|
|
|
|
nsFrameList::FrameLinkEnumerator linkToBreak(aFromFrames, lastFrame);
|
|
|
|
*aOutFrames = aFromFrames.ExtractHead(linkToBreak);
|
|
|
|
return isLastLine;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// Reflow methods
|
|
|
|
|
|
|
|
/* virtual */ void
|
|
|
|
nsBlockFrame::MarkIntrinsicWidthsDirty()
|
|
|
|
{
|
2013-09-25 04:42:34 -07:00
|
|
|
nsBlockFrame* dirtyBlock = static_cast<nsBlockFrame*>(FirstContinuation());
|
2007-07-23 14:40:10 -07:00
|
|
|
dirtyBlock->mMinWidth = NS_INTRINSIC_WIDTH_UNKNOWN;
|
|
|
|
dirtyBlock->mPrefWidth = NS_INTRINSIC_WIDTH_UNKNOWN;
|
2007-10-11 04:41:04 -07:00
|
|
|
if (!(GetStateBits() & NS_BLOCK_NEEDS_BIDI_RESOLUTION)) {
|
|
|
|
for (nsIFrame* frame = dirtyBlock; frame;
|
|
|
|
frame = frame->GetNextContinuation()) {
|
|
|
|
frame->AddStateBits(NS_BLOCK_NEEDS_BIDI_RESOLUTION);
|
|
|
|
}
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsBlockFrameSuper::MarkIntrinsicWidthsDirty();
|
|
|
|
}
|
|
|
|
|
2012-06-05 19:13:41 -07:00
|
|
|
void
|
|
|
|
nsBlockFrame::CheckIntrinsicCacheAgainstShrinkWrapState()
|
|
|
|
{
|
|
|
|
nsPresContext *presContext = PresContext();
|
|
|
|
if (!nsLayoutUtils::FontSizeInflationEnabled(presContext)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
bool inflationEnabled =
|
|
|
|
!presContext->mInflationDisabledForShrinkWrap;
|
|
|
|
if (inflationEnabled !=
|
|
|
|
!!(GetStateBits() & NS_BLOCK_FRAME_INTRINSICS_INFLATED)) {
|
|
|
|
mMinWidth = NS_INTRINSIC_WIDTH_UNKNOWN;
|
|
|
|
mPrefWidth = NS_INTRINSIC_WIDTH_UNKNOWN;
|
|
|
|
if (inflationEnabled) {
|
|
|
|
AddStateBits(NS_BLOCK_FRAME_INTRINSICS_INFLATED);
|
|
|
|
} else {
|
|
|
|
RemoveStateBits(NS_BLOCK_FRAME_INTRINSICS_INFLATED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/* virtual */ nscoord
|
2011-04-07 18:04:40 -07:00
|
|
|
nsBlockFrame::GetMinWidth(nsRenderingContext *aRenderingContext)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-09-25 04:42:34 -07:00
|
|
|
nsIFrame* firstInFlow = FirstContinuation();
|
2007-07-23 14:40:10 -07:00
|
|
|
if (firstInFlow != this)
|
|
|
|
return firstInFlow->GetMinWidth(aRenderingContext);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
DISPLAY_MIN_WIDTH(this, mMinWidth);
|
2012-06-05 19:13:41 -07:00
|
|
|
|
|
|
|
CheckIntrinsicCacheAgainstShrinkWrapState();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (mMinWidth != NS_INTRINSIC_WIDTH_UNKNOWN)
|
|
|
|
return mMinWidth;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (gNoisyIntrinsic) {
|
|
|
|
IndentBy(stdout, gNoiseIndent);
|
|
|
|
ListTag(stdout);
|
|
|
|
printf(": GetMinWidth\n");
|
|
|
|
}
|
2008-01-28 23:40:05 -08:00
|
|
|
AutoNoisyIndenter indenter(gNoisyIntrinsic);
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
2013-05-13 15:37:00 -07:00
|
|
|
for (nsBlockFrame* curFrame = this; curFrame;
|
|
|
|
curFrame = static_cast<nsBlockFrame*>(curFrame->GetNextContinuation())) {
|
|
|
|
curFrame->LazyMarkLinesDirty();
|
|
|
|
}
|
|
|
|
|
2007-10-11 04:41:04 -07:00
|
|
|
if (GetStateBits() & NS_BLOCK_NEEDS_BIDI_RESOLUTION)
|
|
|
|
ResolveBidi();
|
2007-03-22 10:30:00 -07:00
|
|
|
InlineMinWidthData data;
|
2007-07-23 14:40:10 -07:00
|
|
|
for (nsBlockFrame* curFrame = this; curFrame;
|
2007-09-04 23:41:35 -07:00
|
|
|
curFrame = static_cast<nsBlockFrame*>(curFrame->GetNextContinuation())) {
|
2007-07-23 14:40:10 -07:00
|
|
|
for (line_iterator line = curFrame->begin_lines(), line_end = curFrame->end_lines();
|
|
|
|
line != line_end; ++line)
|
|
|
|
{
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef DEBUG
|
2007-07-23 14:40:10 -07:00
|
|
|
if (gNoisyIntrinsic) {
|
|
|
|
IndentBy(stdout, gNoiseIndent);
|
|
|
|
printf("line (%s%s)\n",
|
|
|
|
line->IsBlock() ? "block" : "inline",
|
|
|
|
line->IsEmpty() ? ", empty" : "");
|
2007-06-21 15:32:47 -07:00
|
|
|
}
|
2007-07-23 14:40:10 -07: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-14 22:12:17 -08:00
|
|
|
if (!curFrame->GetPrevContinuation() &&
|
|
|
|
line == curFrame->begin_lines()) {
|
2010-08-31 09:05:12 -07: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).
|
2013-02-16 13:51:02 -08:00
|
|
|
const nsStyleCoord &indent = StyleText()->mTextIndent;
|
2010-08-31 09:05:12 -07:00
|
|
|
if (indent.ConvertsToLength())
|
|
|
|
data.currentLine += nsRuleNode::ComputeCoordPercentCalc(indent, 0);
|
2007-07-23 14:40:10 -07:00
|
|
|
}
|
|
|
|
// XXX Bug NNNNNN Should probably handle percentage text-indent.
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-12-12 16:24:32 -08:00
|
|
|
data.line = &line;
|
2009-02-10 01:23:05 -08:00
|
|
|
data.lineContainer = curFrame;
|
2007-07-23 14:40:10 -07:00
|
|
|
nsIFrame *kid = line->mFirstChild;
|
2012-08-22 08:56:38 -07:00
|
|
|
for (int32_t i = 0, i_end = line->GetChildCount(); i != i_end;
|
2007-07-23 14:40:10 -07:00
|
|
|
++i, kid = kid->GetNextSibling()) {
|
|
|
|
kid->AddInlineMinWidth(aRenderingContext, &data);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
#ifdef DEBUG
|
2007-07-23 14:40:10 -07:00
|
|
|
if (gNoisyIntrinsic) {
|
|
|
|
IndentBy(stdout, gNoiseIndent);
|
|
|
|
printf("min: [prevLines=%d currentLine=%d]\n",
|
|
|
|
data.prevLines, data.currentLine);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
2007-07-23 14:40:10 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2007-06-21 15:32:47 -07:00
|
|
|
data.ForceBreak(aRenderingContext);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
mMinWidth = data.prevLines;
|
|
|
|
return mMinWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nscoord
|
2011-04-07 18:04:40 -07:00
|
|
|
nsBlockFrame::GetPrefWidth(nsRenderingContext *aRenderingContext)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-09-25 04:42:34 -07:00
|
|
|
nsIFrame* firstInFlow = FirstContinuation();
|
2007-07-23 14:40:10 -07:00
|
|
|
if (firstInFlow != this)
|
|
|
|
return firstInFlow->GetPrefWidth(aRenderingContext);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
DISPLAY_PREF_WIDTH(this, mPrefWidth);
|
2007-07-23 14:40:10 -07:00
|
|
|
|
2012-06-05 19:13:41 -07:00
|
|
|
CheckIntrinsicCacheAgainstShrinkWrapState();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (mPrefWidth != NS_INTRINSIC_WIDTH_UNKNOWN)
|
|
|
|
return mPrefWidth;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (gNoisyIntrinsic) {
|
|
|
|
IndentBy(stdout, gNoiseIndent);
|
|
|
|
ListTag(stdout);
|
|
|
|
printf(": GetPrefWidth\n");
|
|
|
|
}
|
2008-01-28 23:40:05 -08:00
|
|
|
AutoNoisyIndenter indenter(gNoisyIntrinsic);
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
2013-05-13 15:37:00 -07:00
|
|
|
for (nsBlockFrame* curFrame = this; curFrame;
|
|
|
|
curFrame = static_cast<nsBlockFrame*>(curFrame->GetNextContinuation())) {
|
|
|
|
curFrame->LazyMarkLinesDirty();
|
|
|
|
}
|
|
|
|
|
2007-10-11 04:41:04 -07:00
|
|
|
if (GetStateBits() & NS_BLOCK_NEEDS_BIDI_RESOLUTION)
|
|
|
|
ResolveBidi();
|
2007-03-22 10:30:00 -07:00
|
|
|
InlinePrefWidthData data;
|
2007-07-23 14:40:10 -07:00
|
|
|
for (nsBlockFrame* curFrame = this; curFrame;
|
2007-09-04 23:41:35 -07:00
|
|
|
curFrame = static_cast<nsBlockFrame*>(curFrame->GetNextContinuation())) {
|
2007-07-23 14:40:10 -07:00
|
|
|
for (line_iterator line = curFrame->begin_lines(), line_end = curFrame->end_lines();
|
|
|
|
line != line_end; ++line)
|
|
|
|
{
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef DEBUG
|
2007-07-23 14:40:10 -07:00
|
|
|
if (gNoisyIntrinsic) {
|
|
|
|
IndentBy(stdout, gNoiseIndent);
|
|
|
|
printf("line (%s%s)\n",
|
|
|
|
line->IsBlock() ? "block" : "inline",
|
|
|
|
line->IsEmpty() ? ", empty" : "");
|
2007-06-21 15:32:47 -07:00
|
|
|
}
|
2007-07-23 14:40:10 -07: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-14 22:12:17 -08:00
|
|
|
if (!curFrame->GetPrevContinuation() &&
|
|
|
|
line == curFrame->begin_lines()) {
|
2010-08-31 09:05:12 -07: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).
|
2013-02-16 13:51:02 -08:00
|
|
|
const nsStyleCoord &indent = StyleText()->mTextIndent;
|
2010-08-31 09:05:12 -07:00
|
|
|
if (indent.ConvertsToLength())
|
|
|
|
data.currentLine += nsRuleNode::ComputeCoordPercentCalc(indent, 0);
|
2007-07-23 14:40:10 -07:00
|
|
|
}
|
|
|
|
// XXX Bug NNNNNN Should probably handle percentage text-indent.
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-12-12 16:24:32 -08:00
|
|
|
data.line = &line;
|
2009-02-10 01:23:05 -08:00
|
|
|
data.lineContainer = curFrame;
|
2007-07-23 14:40:10 -07:00
|
|
|
nsIFrame *kid = line->mFirstChild;
|
2012-08-22 08:56:38 -07:00
|
|
|
for (int32_t i = 0, i_end = line->GetChildCount(); i != i_end;
|
2007-07-23 14:40:10 -07:00
|
|
|
++i, kid = kid->GetNextSibling()) {
|
|
|
|
kid->AddInlinePrefWidth(aRenderingContext, &data);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
#ifdef DEBUG
|
2007-07-23 14:40:10 -07:00
|
|
|
if (gNoisyIntrinsic) {
|
|
|
|
IndentBy(stdout, gNoiseIndent);
|
|
|
|
printf("pref: [prevLines=%d currentLine=%d]\n",
|
|
|
|
data.prevLines, data.currentLine);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
2007-07-23 14:40:10 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2007-06-21 15:32:47 -07:00
|
|
|
data.ForceBreak(aRenderingContext);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
mPrefWidth = data.prevLines;
|
|
|
|
return mPrefWidth;
|
|
|
|
}
|
|
|
|
|
2007-10-12 01:30:54 -07:00
|
|
|
nsRect
|
|
|
|
nsBlockFrame::ComputeTightBounds(gfxContext* aContext) const
|
|
|
|
{
|
|
|
|
// be conservative
|
2013-02-15 21:38:33 -08:00
|
|
|
if (StyleContext()->HasTextDecorationLines()) {
|
2010-10-06 21:25:46 -07:00
|
|
|
return GetVisualOverflowRect();
|
2011-04-22 22:16:41 -07:00
|
|
|
}
|
2007-10-12 01:30:54 -07:00
|
|
|
return ComputeSimpleTightBounds(aContext);
|
|
|
|
}
|
|
|
|
|
2013-11-25 06:20:20 -08:00
|
|
|
/* virtual */ nsresult
|
|
|
|
nsBlockFrame::GetPrefWidthTightBounds(nsRenderingContext* aRenderingContext,
|
|
|
|
nscoord* aX,
|
|
|
|
nscoord* aXMost)
|
|
|
|
{
|
|
|
|
nsIFrame* firstInFlow = FirstContinuation();
|
|
|
|
if (firstInFlow != this) {
|
|
|
|
return firstInFlow->GetPrefWidthTightBounds(aRenderingContext, aX, aXMost);
|
|
|
|
}
|
|
|
|
|
|
|
|
*aX = 0;
|
|
|
|
*aXMost = 0;
|
|
|
|
|
|
|
|
nsresult rv;
|
|
|
|
InlinePrefWidthData data;
|
|
|
|
for (nsBlockFrame* curFrame = this; curFrame;
|
|
|
|
curFrame = static_cast<nsBlockFrame*>(curFrame->GetNextContinuation())) {
|
|
|
|
for (line_iterator line = curFrame->begin_lines(), line_end = curFrame->end_lines();
|
|
|
|
line != line_end; ++line)
|
|
|
|
{
|
|
|
|
nscoord childX, childXMost;
|
|
|
|
if (line->IsBlock()) {
|
|
|
|
data.ForceBreak(aRenderingContext);
|
|
|
|
rv = line->mFirstChild->GetPrefWidthTightBounds(aRenderingContext,
|
|
|
|
&childX, &childXMost);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
*aX = std::min(*aX, childX);
|
|
|
|
*aXMost = std::max(*aXMost, childXMost);
|
|
|
|
} else {
|
|
|
|
if (!curFrame->GetPrevContinuation() &&
|
|
|
|
line == curFrame->begin_lines()) {
|
|
|
|
// Only add text-indent if it has no percentages; using a
|
|
|
|
// percentage basis of 0 unconditionally would give strange
|
|
|
|
// behavior for calc(10%-3px).
|
|
|
|
const nsStyleCoord &indent = StyleText()->mTextIndent;
|
|
|
|
if (indent.ConvertsToLength()) {
|
|
|
|
data.currentLine += nsRuleNode::ComputeCoordPercentCalc(indent, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// XXX Bug NNNNNN Should probably handle percentage text-indent.
|
|
|
|
|
|
|
|
data.line = &line;
|
|
|
|
data.lineContainer = curFrame;
|
|
|
|
nsIFrame *kid = line->mFirstChild;
|
|
|
|
for (int32_t i = 0, i_end = line->GetChildCount(); i != i_end;
|
|
|
|
++i, kid = kid->GetNextSibling()) {
|
|
|
|
rv = kid->GetPrefWidthTightBounds(aRenderingContext, &childX,
|
|
|
|
&childXMost);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
*aX = std::min(*aX, data.currentLine + childX);
|
|
|
|
*aXMost = std::max(*aXMost, data.currentLine + childXMost);
|
|
|
|
kid->AddInlinePrefWidth(aRenderingContext, &data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
data.ForceBreak(aRenderingContext);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool
|
2009-05-20 04:21:34 -07:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
static nsSize
|
|
|
|
CalculateContainingBlockSizeForAbsolutes(const nsHTMLReflowState& aReflowState,
|
|
|
|
nsSize aFrameSize)
|
|
|
|
{
|
|
|
|
// The issue here is that for a 'height' of 'auto' the reflow state
|
|
|
|
// code won't know how to calculate the containing block height
|
|
|
|
// because it's calculated bottom up. So we use our own computed
|
2007-12-04 19:05:57 -08:00
|
|
|
// size as the dimensions.
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIFrame* frame = aReflowState.frame;
|
|
|
|
|
|
|
|
nsSize cbSize(aFrameSize);
|
|
|
|
// Containing block is relative to the padding edge
|
2008-07-17 06:32:49 -07:00
|
|
|
const nsMargin& border =
|
2013-12-27 09:59:21 -08:00
|
|
|
aReflowState.ComputedPhysicalBorderPadding() - aReflowState.ComputedPhysicalPadding();
|
2008-07-17 06:32:49 -07:00
|
|
|
cbSize.width -= border.LeftRight();
|
|
|
|
cbSize.height -= border.TopBottom();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-09-08 01:13:17 -07: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.
|
2007-03-22 10:30:00 -07: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
|
2014-02-14 18:00:08 -08:00
|
|
|
// content, except for fieldsets where the inner anonymous frame has
|
|
|
|
// the correct padding area with the legend taken into account.
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsHTMLReflowState* aLastRS = &aReflowState;
|
|
|
|
const nsHTMLReflowState* lastButOneRS = &aReflowState;
|
|
|
|
while (aLastRS->parentReflowState &&
|
2014-02-14 18:00:08 -08:00
|
|
|
aLastRS->parentReflowState->frame->GetContent() == frame->GetContent() &&
|
|
|
|
aLastRS->parentReflowState->frame->GetType() != nsGkAtoms::fieldSetFrame) {
|
2007-03-22 10:30:00 -07:00
|
|
|
lastButOneRS = aLastRS;
|
|
|
|
aLastRS = aLastRS->parentReflowState;
|
|
|
|
}
|
|
|
|
if (aLastRS != &aReflowState) {
|
|
|
|
// 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 11:20:59 -08:00
|
|
|
nsIScrollableFrame* scrollFrame = do_QueryFrame(aLastRS->frame);
|
2007-03-22 10:30:00 -07:00
|
|
|
nsMargin scrollbars(0,0,0,0);
|
|
|
|
if (scrollFrame) {
|
2008-04-09 21:39:41 -07:00
|
|
|
scrollbars =
|
|
|
|
scrollFrame->GetDesiredScrollbarSizes(aLastRS->frame->PresContext(),
|
|
|
|
aLastRS->rendContext);
|
2007-12-04 19:05:57 -08:00
|
|
|
if (!lastButOneRS->mFlags.mAssumingHScrollbar) {
|
2007-03-22 10:30:00 -07:00
|
|
|
scrollbars.top = scrollbars.bottom = 0;
|
2007-12-04 19:05:57 -08:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!lastButOneRS->mFlags.mAssumingVScrollbar) {
|
|
|
|
scrollbars.left = scrollbars.right = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// We found a reflow state for the outermost wrapping frame, so use
|
|
|
|
// its computed metrics if available
|
2008-09-08 01:13:17 -07:00
|
|
|
if (aLastRS->ComputedWidth() != NS_UNCONSTRAINEDSIZE) {
|
2013-01-15 04:22:03 -08:00
|
|
|
cbSize.width = std::max(0,
|
2013-12-27 09:59:21 -08:00
|
|
|
aLastRS->ComputedWidth() + aLastRS->ComputedPhysicalPadding().LeftRight() - scrollbars.LeftRight());
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2007-08-02 11:08:05 -07:00
|
|
|
if (aLastRS->ComputedHeight() != NS_UNCONSTRAINEDSIZE) {
|
2013-01-15 04:22:03 -08:00
|
|
|
cbSize.height = std::max(0,
|
2013-12-27 09:59:21 -08:00
|
|
|
aLastRS->ComputedHeight() + aLastRS->ComputedPhysicalPadding().TopBottom() - scrollbars.TopBottom());
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return cbSize;
|
|
|
|
}
|
|
|
|
|
2014-02-17 23:47:48 -08:00
|
|
|
nsresult
|
2007-07-25 21:03:29 -07:00
|
|
|
nsBlockFrame::Reflow(nsPresContext* aPresContext,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsBlockFrame");
|
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aMetrics, aStatus);
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (gNoisyReflow) {
|
|
|
|
IndentBy(stdout, gNoiseIndent);
|
|
|
|
ListTag(stdout);
|
|
|
|
printf(": begin reflow availSize=%d,%d computedSize=%d,%d\n",
|
2013-12-27 09:59:21 -08:00
|
|
|
aReflowState.AvailableWidth(), aReflowState.AvailableHeight(),
|
2007-08-02 11:08:05 -07:00
|
|
|
aReflowState.ComputedWidth(), aReflowState.ComputedHeight());
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
AutoNoisyIndenter indent(gNoisy);
|
2012-10-25 16:25:59 -07:00
|
|
|
PRTime start = 0; // Initialize these variablies to silence the compiler.
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t ctc = 0; // We only use these if they are set (gLameReflowMetrics).
|
2007-03-22 10:30:00 -07:00
|
|
|
if (gLameReflowMetrics) {
|
|
|
|
start = PR_Now();
|
|
|
|
ctc = nsLineBox::GetCtorCount();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-01-19 14:39:31 -08:00
|
|
|
const nsHTMLReflowState *reflowState = &aReflowState;
|
2013-07-25 08:34:16 -07:00
|
|
|
nscoord consumedHeight = GetConsumedHeight();
|
|
|
|
nscoord effectiveComputedHeight = GetEffectiveComputedHeight(aReflowState,
|
|
|
|
consumedHeight);
|
2013-04-25 09:03:28 -07:00
|
|
|
Maybe<nsHTMLReflowState> mutableReflowState;
|
2011-01-19 14:39:31 -08:00
|
|
|
// If we have non-auto height, we're clipping our kids and we fit,
|
|
|
|
// make sure our kids fit too.
|
2013-12-27 09:59:21 -08:00
|
|
|
if (aReflowState.AvailableHeight() != NS_UNCONSTRAINEDSIZE &&
|
2011-01-19 14:39:31 -08:00
|
|
|
aReflowState.ComputedHeight() != NS_AUTOHEIGHT &&
|
2013-03-06 03:08:16 -08:00
|
|
|
ShouldApplyOverflowClipping(this, aReflowState.mStyleDisplay)) {
|
2014-03-13 00:39:33 -07:00
|
|
|
LogicalMargin blockDirExtras = aReflowState.ComputedLogicalBorderPadding();
|
|
|
|
WritingMode wm = aReflowState.GetWritingMode();
|
|
|
|
if (GetLogicalSkipSides() & (LOGICAL_SIDE_B_START)) {
|
|
|
|
blockDirExtras.BStart(wm) = 0;
|
2011-01-19 14:39:31 -08:00
|
|
|
} else {
|
|
|
|
// Bottom margin never causes us to create continuations, so we
|
|
|
|
// don't need to worry about whether it fits in its entirety.
|
2014-03-13 00:39:33 -07:00
|
|
|
blockDirExtras.BStart(wm) +=
|
|
|
|
aReflowState.ComputedLogicalMargin().BStart(wm);
|
2011-01-19 14:39:31 -08:00
|
|
|
}
|
|
|
|
|
2014-03-13 00:39:33 -07:00
|
|
|
if (effectiveComputedHeight + blockDirExtras.BStartEnd(wm) <=
|
|
|
|
aReflowState.AvailableBSize()) {
|
2013-04-25 09:03:28 -07:00
|
|
|
mutableReflowState.construct(aReflowState);
|
2014-03-13 00:39:33 -07:00
|
|
|
mutableReflowState.ref().AvailableBSize() = NS_UNCONSTRAINEDSIZE;
|
2013-04-25 09:03:28 -07:00
|
|
|
reflowState = mutableReflowState.addr();
|
2011-01-19 14:39:31 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-04 18:57:53 -08:00
|
|
|
// See comment below about oldSize. Use *only* for the
|
|
|
|
// abs-pos-containing-block-size-change optimization!
|
2007-03-22 10:30:00 -07:00
|
|
|
nsSize oldSize = GetSize();
|
|
|
|
|
2009-01-04 16:39:54 -08:00
|
|
|
// Should we create a float manager?
|
2011-01-19 14:39:31 -08:00
|
|
|
nsAutoFloatManager autoFloatManager(const_cast<nsHTMLReflowState&>(*reflowState));
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-01-04 16:39:54 -08:00
|
|
|
// XXXldb If we start storing the float manager in the frame rather
|
2007-03-22 10:30:00 -07: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.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool needFloatManager = nsBlockFrame::BlockNeedsFloatManager(this);
|
2009-01-04 16:39:54 -08:00
|
|
|
if (needFloatManager)
|
|
|
|
autoFloatManager.CreateFloatManager(aPresContext);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-10-06 21:25:45 -07: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.
|
2007-03-22 10:30:00 -07:00
|
|
|
ClearLineCursor();
|
|
|
|
|
2011-01-19 14:39:31 -08:00
|
|
|
if (IsFrameTreeTooDeep(*reflowState, aMetrics, aStatus)) {
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-07-20 11:27:04 -07:00
|
|
|
bool topMarginRoot, bottomMarginRoot;
|
|
|
|
IsMarginRoot(&topMarginRoot, &bottomMarginRoot);
|
2013-07-25 08:34:16 -07:00
|
|
|
|
|
|
|
// Cache the consumed height in the block reflow state so that we don't have
|
|
|
|
// to continually recompute it.
|
2013-01-31 14:40:05 -08:00
|
|
|
nsBlockReflowState state(*reflowState, aPresContext, this,
|
2013-07-25 08:34:16 -07:00
|
|
|
topMarginRoot, bottomMarginRoot, needFloatManager,
|
|
|
|
consumedHeight);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifdef IBMBIDI
|
2007-10-11 04:41:04 -07:00
|
|
|
if (GetStateBits() & NS_BLOCK_NEEDS_BIDI_RESOLUTION)
|
2013-09-25 04:42:34 -07:00
|
|
|
static_cast<nsBlockFrame*>(FirstContinuation())->ResolveBidi();
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif // IBMBIDI
|
|
|
|
|
2007-05-06 12:16:51 -07:00
|
|
|
if (RenumberLists(aPresContext)) {
|
|
|
|
AddStateBits(NS_FRAME_HAS_DIRTY_CHILDREN);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
// 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.
|
2012-01-30 15:35:03 -08:00
|
|
|
DrainOverflowLines();
|
2009-08-31 11:25:36 -07:00
|
|
|
|
2009-09-13 17:26:01 -07:00
|
|
|
// Handle paginated overflow (see nsContainerFrame.h)
|
2010-10-06 21:25:45 -07:00
|
|
|
nsOverflowAreas ocBounds;
|
2009-09-13 17:26:01 -07:00
|
|
|
nsReflowStatus ocStatus = NS_FRAME_COMPLETE;
|
|
|
|
if (GetPrevInFlow()) {
|
2011-01-19 14:39:31 -08:00
|
|
|
ReflowOverflowContainerChildren(aPresContext, *reflowState, ocBounds, 0,
|
2009-09-13 17:26:01 -07:00
|
|
|
ocStatus);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now that we're done cleaning up our overflow container lists, we can
|
|
|
|
// give |state| its nsOverflowContinuationTracker.
|
2014-02-06 14:07:47 -08:00
|
|
|
nsOverflowContinuationTracker tracker(this, false);
|
2009-09-13 17:26:01 -07:00
|
|
|
state.mOverflowTracker = &tracker;
|
|
|
|
|
2010-08-05 21:59:20 -07:00
|
|
|
// Drain & handle pushed floats
|
|
|
|
DrainPushedFloats(state);
|
2010-10-06 21:25:45 -07:00
|
|
|
nsOverflowAreas fcBounds;
|
2009-08-31 11:25:36 -07:00
|
|
|
nsReflowStatus fcStatus = NS_FRAME_COMPLETE;
|
2013-06-18 23:09:22 -07:00
|
|
|
ReflowPushedFloats(state, fcBounds, fcStatus);
|
2009-08-31 11:25:36 -07:00
|
|
|
|
2007-03-22 10:30:00 -07: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.
|
2013-05-10 17:35:08 -07:00
|
|
|
if (!(GetStateBits() & NS_FRAME_IS_DIRTY) && reflowState->mFlags.mHResize) {
|
2007-03-22 10:30:00 -07:00
|
|
|
PrepareResizeReflow(state);
|
2013-05-10 17:35:08 -07:00
|
|
|
}
|
|
|
|
|
2013-05-13 15:37:00 -07:00
|
|
|
LazyMarkLinesDirty();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
mState &= ~NS_FRAME_FIRST_REFLOW;
|
|
|
|
|
|
|
|
// Now reflow...
|
|
|
|
rv = ReflowDirtyLines(state);
|
2013-03-19 07:05:05 -07:00
|
|
|
|
|
|
|
// If we have a next-in-flow, and that next-in-flow has pushed floats from
|
|
|
|
// this frame from a previous iteration of reflow, then we should not return
|
|
|
|
// a status of NS_FRAME_COMPLETE, since we actually have overflow, it's just
|
|
|
|
// already been handled.
|
|
|
|
|
|
|
|
// NOTE: This really shouldn't happen, since we _should_ pull back our floats
|
|
|
|
// and reflow them, but just in case it does, this is a safety precaution so
|
|
|
|
// we don't end up with a placeholder pointing to frames that have already
|
|
|
|
// been deleted as part of removing our next-in-flow.
|
|
|
|
if (NS_FRAME_IS_COMPLETE(state.mReflowStatus)) {
|
|
|
|
nsBlockFrame* nif = static_cast<nsBlockFrame*>(GetNextInFlow());
|
|
|
|
while (nif) {
|
|
|
|
if (nif->HasPushedFloatsFromPrevContinuation()) {
|
|
|
|
NS_MergeReflowStatusInto(&state.mReflowStatus, NS_FRAME_NOT_COMPLETE);
|
|
|
|
}
|
|
|
|
|
|
|
|
nif = static_cast<nsBlockFrame*>(nif->GetNextInFlow());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "reflow dirty lines failed");
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2009-06-28 20:56:13 -07:00
|
|
|
NS_MergeReflowStatusInto(&state.mReflowStatus, ocStatus);
|
2009-08-31 11:25:36 -07:00
|
|
|
NS_MergeReflowStatusInto(&state.mReflowStatus, fcStatus);
|
2007-07-25 21:03:29 -07:00
|
|
|
|
2009-08-31 11:25:36 -07:00
|
|
|
// If we end in a BR with clear and affected floats continue,
|
|
|
|
// we need to continue, too.
|
2013-12-27 09:59:21 -08:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != reflowState->AvailableHeight() &&
|
2009-08-31 11:25:36 -07:00
|
|
|
NS_FRAME_IS_COMPLETE(state.mReflowStatus) &&
|
|
|
|
state.mFloatManager->ClearContinues(FindTrailingClear())) {
|
|
|
|
NS_FRAME_SET_INCOMPLETE(state.mReflowStatus);
|
|
|
|
}
|
|
|
|
|
2009-07-13 09:50:54 -07:00
|
|
|
if (!NS_FRAME_IS_FULLY_COMPLETE(state.mReflowStatus)) {
|
2012-03-07 17:57:37 -08:00
|
|
|
if (HasOverflowLines() || HasPushedFloats()) {
|
2007-03-22 10:30:00 -07:00
|
|
|
state.mReflowStatus |= NS_FRAME_REFLOW_NEXTINFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG_kipp
|
2009-07-13 09:50:54 -07:00
|
|
|
ListTag(stdout); printf(": block is not fully complete\n");
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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.
|
2012-03-07 17:57:37 -08:00
|
|
|
if (HasOutsideBullet() && !mLines.empty() &&
|
2008-02-10 13:49:24 -08:00
|
|
|
(mLines.front()->IsBlock() ||
|
|
|
|
(0 == mLines.front()->mBounds.height &&
|
|
|
|
mLines.front() != mLines.back() &&
|
|
|
|
mLines.begin().next()->IsBlock()))) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// Reflow the bullet
|
2013-12-31 05:50:31 -08:00
|
|
|
nsHTMLReflowMetrics metrics(aReflowState);
|
2009-04-08 13:52:36 -07:00
|
|
|
// XXX Use the entire line when we fix bug 25888.
|
|
|
|
nsLayoutUtils::LinePosition position;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool havePosition = nsLayoutUtils::GetFirstLinePosition(this, &position);
|
2009-04-08 13:52:36 -07:00
|
|
|
nscoord lineTop = havePosition ? position.mTop
|
2013-12-27 09:59:21 -08:00
|
|
|
: reflowState->ComputedPhysicalBorderPadding().top;
|
2012-03-07 17:57:37 -08:00
|
|
|
nsIFrame* bullet = GetOutsideBullet();
|
|
|
|
ReflowBullet(bullet, state, metrics, lineTop);
|
2013-12-27 09:59:52 -08:00
|
|
|
NS_ASSERTION(!BulletIsEmpty() || metrics.Height() == 0,
|
2009-09-11 03:46:36 -07:00
|
|
|
"empty bullet took up space");
|
2009-04-08 13:52:36 -07:00
|
|
|
|
2009-09-11 03:46:36 -07:00
|
|
|
if (havePosition && !BulletIsEmpty()) {
|
2007-12-03 13:31:26 -08: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 10:32:51 -08:00
|
|
|
|
2007-12-03 13:31:26 -08:00
|
|
|
// Tall bullets won't look particularly nice here...
|
2012-03-07 17:57:37 -08:00
|
|
|
nsRect bbox = bullet->GetRect();
|
2013-12-27 09:59:52 -08:00
|
|
|
bbox.y = position.mBaseline - metrics.TopAscent();
|
2012-03-07 17:57:37 -08:00
|
|
|
bullet->SetRect(bbox);
|
2007-12-03 13:31:26 -08:00
|
|
|
}
|
|
|
|
// Otherwise just leave the bullet where it is, up against our top padding.
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-09-05 11:59:09 -07:00
|
|
|
CheckFloats(state);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Compute our final size
|
2008-12-29 00:18:40 -08:00
|
|
|
nscoord bottomEdgeOfChildren;
|
2011-01-19 14:39:31 -08:00
|
|
|
ComputeFinalSize(*reflowState, state, aMetrics, &bottomEdgeOfChildren);
|
2013-12-27 09:59:52 -08:00
|
|
|
nsRect areaBounds = nsRect(0, 0, aMetrics.Width(), aMetrics.Height());
|
2011-06-15 14:03:49 -07:00
|
|
|
ComputeOverflowAreas(areaBounds, reflowState->mStyleDisplay,
|
|
|
|
bottomEdgeOfChildren, aMetrics.mOverflowAreas);
|
2007-07-25 21:03:29 -07:00
|
|
|
// Factor overflow container child bounds into the overflow area
|
2010-10-06 21:25:45 -07:00
|
|
|
aMetrics.mOverflowAreas.UnionWith(ocBounds);
|
2010-08-05 21:59:20 -07:00
|
|
|
// Factor pushed float child bounds into the overflow area
|
2010-10-06 21:25:45 -07:00
|
|
|
aMetrics.mOverflowAreas.UnionWith(fcBounds);
|
2007-03-22 10:30:00 -07: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
|
|
|
|
// 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-04 18:57:53 -08: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 16:02:33 -07:00
|
|
|
if (HasAbsolutelyPositionedChildren()) {
|
|
|
|
nsAbsoluteContainingBlock* absoluteContainer = GetAbsoluteContainingBlock();
|
2011-09-28 23:19:26 -07:00
|
|
|
bool haveInterrupt = aPresContext->HasPendingInterrupt();
|
2011-01-19 14:39:31 -08:00
|
|
|
if (reflowState->WillReflowAgainForClearance() ||
|
2009-04-21 16:53:52 -07:00
|
|
|
haveInterrupt) {
|
2008-10-15 13:30:42 -07:00
|
|
|
// Make sure that when we reflow again we'll actually reflow all the abs
|
2009-04-21 16:53:52 -07: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 16:02:33 -07:00
|
|
|
absoluteContainer->MarkAllFramesDirty();
|
2009-04-21 16:53:52 -07:00
|
|
|
} else {
|
2011-04-29 16:02:33 -07:00
|
|
|
absoluteContainer->MarkSizeDependentFramesDirty();
|
2009-04-21 16:53:52 -07:00
|
|
|
}
|
2008-10-15 13:30:42 -07:00
|
|
|
} else {
|
|
|
|
nsSize containingBlockSize =
|
2011-01-19 14:39:31 -08:00
|
|
|
CalculateContainingBlockSizeForAbsolutes(*reflowState,
|
2013-12-27 09:59:52 -08:00
|
|
|
nsSize(aMetrics.Width(),
|
|
|
|
aMetrics.Height()));
|
2008-10-15 13:30:42 -07:00
|
|
|
|
|
|
|
// 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.
|
2013-12-27 09:59:52 -08:00
|
|
|
bool cbWidthChanged = aMetrics.Width() != oldSize.width;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool isRoot = !GetContent()->GetParent();
|
2008-10-15 13:30:42 -07:00
|
|
|
// 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.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool cbHeightChanged =
|
2011-01-19 14:39:31 -08:00
|
|
|
!(isRoot && NS_UNCONSTRAINEDSIZE == reflowState->ComputedHeight()) &&
|
2013-12-27 09:59:52 -08:00
|
|
|
aMetrics.Height() != oldSize.height;
|
2008-10-15 13:30:42 -07:00
|
|
|
|
2013-04-15 01:31:45 -07:00
|
|
|
nsRect containingBlock(nsPoint(0, 0), containingBlockSize);
|
2011-04-29 16:02:33 -07:00
|
|
|
absoluteContainer->Reflow(this, aPresContext, *reflowState,
|
|
|
|
state.mReflowStatus,
|
2013-04-15 01:31:45 -07:00
|
|
|
containingBlock, true,
|
2011-04-29 16:02:33 -07:00
|
|
|
cbWidthChanged, cbHeightChanged,
|
|
|
|
&aMetrics.mOverflowAreas);
|
2008-10-15 13:30:42 -07:00
|
|
|
|
|
|
|
//XXXfr Why isn't this rv (and others in this file) checked/returned?
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2007-05-21 03:06:08 -07:00
|
|
|
FinishAndStoreOverflow(&aMetrics);
|
|
|
|
|
2009-01-04 16:39:54 -08:00
|
|
|
// Clear the float manager pointer in the block reflow state so we
|
2007-03-22 10:30:00 -07:00
|
|
|
// don't waste time translating the coordinate system back on a dead
|
2009-01-04 16:39:54 -08:00
|
|
|
// float manager.
|
|
|
|
if (needFloatManager)
|
2012-07-30 07:20:58 -07:00
|
|
|
state.mFloatManager = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
aStatus = state.mReflowStatus;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2011-01-11 17:09:21 -08: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);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (gNoisyReflow) {
|
|
|
|
IndentBy(stdout, gNoiseIndent);
|
|
|
|
ListTag(stdout);
|
|
|
|
printf(": status=%x (%scomplete) metrics=%d,%d carriedMargin=%d",
|
|
|
|
aStatus, NS_FRAME_IS_COMPLETE(aStatus) ? "" : "not ",
|
2013-12-27 09:59:52 -08:00
|
|
|
aMetrics.Width(), aMetrics.Height(),
|
2007-03-22 10:30:00 -07:00
|
|
|
aMetrics.mCarriedOutBottomMargin.get());
|
2010-10-06 21:25:45 -07: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);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gLameReflowMetrics) {
|
|
|
|
PRTime end = PR_Now();
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t ectc = nsLineBox::GetCtorCount();
|
|
|
|
int32_t numLines = mLines.size();
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!numLines) numLines = 1;
|
|
|
|
PRTime delta, perLineDelta, lines;
|
2012-10-12 10:29:11 -07:00
|
|
|
lines = int64_t(numLines);
|
2012-10-04 22:05:27 -07:00
|
|
|
delta = end - start;
|
2012-10-04 22:05:28 -07:00
|
|
|
perLineDelta = delta / lines;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
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);
|
|
|
|
printf("%s\n", buf);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-01-19 14:39:31 -08:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, (*reflowState), aMetrics);
|
2007-03-22 10:30:00 -07:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2007-03-22 10:30:00 -07:00
|
|
|
nsBlockFrame::CheckForCollapsedBottomMarginFromClearanceLine()
|
|
|
|
{
|
|
|
|
line_iterator begin = begin_lines();
|
|
|
|
line_iterator line = end_lines();
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
while (true) {
|
2007-03-22 10:30:00 -07:00
|
|
|
if (begin == line) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
--line;
|
|
|
|
if (line->mBounds.height != 0 || !line->CachedIsEmpty()) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
if (line->HasClearance()) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// not reached
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBlockFrame::ComputeFinalSize(const nsHTMLReflowState& aReflowState,
|
|
|
|
nsBlockReflowState& aState,
|
2008-12-29 00:18:40 -08:00
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
nscoord* aBottomEdgeOfChildren)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
const nsMargin& borderPadding = aState.BorderPadding();
|
|
|
|
#ifdef NOISY_FINAL_SIZE
|
|
|
|
ListTag(stdout);
|
|
|
|
printf(": mY=%d mIsBottomMarginRoot=%s mPrevBottomMargin=%d bp=%d,%d\n",
|
|
|
|
aState.mY, aState.GetFlag(BRS_ISBOTTOMMARGINROOT) ? "yes" : "no",
|
|
|
|
aState.mPrevBottomMargin,
|
|
|
|
borderPadding.top, borderPadding.bottom);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Compute final width
|
2013-12-27 09:59:52 -08:00
|
|
|
aMetrics.Width() =
|
2010-04-14 12:35:36 -07:00
|
|
|
NSCoordSaturatingAdd(NSCoordSaturatingAdd(borderPadding.left,
|
|
|
|
aReflowState.ComputedWidth()),
|
|
|
|
borderPadding.right);
|
2007-03-22 10:30:00 -07: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
|
|
|
|
// subsequent lines are empty, then we do not allow our children's
|
|
|
|
// 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 00:18:40 -08: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.
|
2013-12-27 09:59:21 -08:00
|
|
|
if (bottomEdgeOfChildren < aState.mReflowState.AvailableHeight())
|
2008-12-29 00:18:40 -08:00
|
|
|
{
|
|
|
|
// Truncate bottom margin if it doesn't fit to our available height.
|
|
|
|
bottomEdgeOfChildren =
|
2013-01-15 04:22:03 -08:00
|
|
|
std::min(bottomEdgeOfChildren + aState.mPrevBottomMargin.get(),
|
2013-12-27 09:59:21 -08:00
|
|
|
aState.mReflowState.AvailableHeight());
|
2008-12-29 00:18:40 -08:00
|
|
|
}
|
|
|
|
}
|
2009-01-04 16:39:54 -08:00
|
|
|
if (aState.GetFlag(BRS_FLOAT_MGR)) {
|
|
|
|
// Include the float manager's state to properly account for the
|
2008-12-29 00:18:40 -08:00
|
|
|
// bottom margin of any floated elements; e.g., inside a table cell.
|
|
|
|
nscoord floatHeight =
|
2014-03-02 09:42:16 -08:00
|
|
|
aState.ClearFloats(bottomEdgeOfChildren, NS_STYLE_CLEAR_BOTH,
|
2012-07-30 07:20:58 -07:00
|
|
|
nullptr, nsFloatManager::DONT_CLEAR_PUSHED_FLOATS);
|
2013-01-15 04:22:03 -08:00
|
|
|
bottomEdgeOfChildren = std::max(bottomEdgeOfChildren, floatHeight);
|
2008-12-29 00:18:40 -08:00
|
|
|
}
|
|
|
|
|
2013-07-25 08:34:22 -07:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != aReflowState.ComputedHeight()
|
|
|
|
&& (mParent->GetType() != nsGkAtoms::columnSetFrame ||
|
2013-12-27 09:59:21 -08:00
|
|
|
aReflowState.parentReflowState->AvailableHeight() == NS_UNCONSTRAINEDSIZE)) {
|
2013-07-25 08:34:22 -07:00
|
|
|
ComputeFinalHeight(aReflowState, &aState.mReflowStatus,
|
|
|
|
aState.mY + nonCarriedOutVerticalMargin,
|
|
|
|
borderPadding, aMetrics, aState.mConsumedHeight);
|
|
|
|
if (!NS_FRAME_IS_COMPLETE(aState.mReflowStatus)) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// Use the current height; continuations will take up the rest.
|
|
|
|
// 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.
|
2013-12-27 09:59:52 -08:00
|
|
|
aMetrics.Height() = std::max(aReflowState.AvailableHeight(),
|
2007-03-22 10:30:00 -07:00
|
|
|
aState.mY + nonCarriedOutVerticalMargin);
|
|
|
|
// ... but don't take up more height than is available
|
2013-07-25 08:34:22 -07:00
|
|
|
nscoord effectiveComputedHeight =
|
|
|
|
GetEffectiveComputedHeight(aReflowState, aState.GetConsumedHeight());
|
2013-12-27 09:59:52 -08:00
|
|
|
aMetrics.Height() = std::min(aMetrics.Height(),
|
2013-07-25 08:34:22 -07:00
|
|
|
borderPadding.top + effectiveComputedHeight);
|
2007-03-22 10:30:00 -07:00
|
|
|
// 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.
|
|
|
|
}
|
|
|
|
|
|
|
|
// Don't carry out a bottom margin when our height is fixed.
|
|
|
|
aMetrics.mCarriedOutBottomMargin.Zero();
|
|
|
|
}
|
2008-01-23 16:28:42 -08:00
|
|
|
else if (NS_FRAME_IS_COMPLETE(aState.mReflowStatus)) {
|
2012-07-18 07:26:05 -07:00
|
|
|
nscoord contentHeight = bottomEdgeOfChildren - borderPadding.top;
|
|
|
|
nscoord autoHeight = aReflowState.ApplyMinMaxHeight(contentHeight);
|
|
|
|
if (autoHeight != contentHeight) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// Our min-height or max-height made our height change. Don't carry out
|
|
|
|
// our kids' bottom margins.
|
|
|
|
aMetrics.mCarriedOutBottomMargin.Zero();
|
|
|
|
}
|
|
|
|
autoHeight += borderPadding.top + borderPadding.bottom;
|
2013-12-27 09:59:52 -08:00
|
|
|
aMetrics.Height() = autoHeight;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2008-01-23 16:28:42 -08:00
|
|
|
else {
|
2013-12-27 09:59:21 -08:00
|
|
|
NS_ASSERTION(aReflowState.AvailableHeight() != NS_UNCONSTRAINEDSIZE,
|
2008-01-23 16:28:42 -08:00
|
|
|
"Shouldn't be incomplete if availableHeight is UNCONSTRAINED.");
|
2013-12-27 09:59:52 -08:00
|
|
|
aMetrics.Height() = std::max(aState.mY, aReflowState.AvailableHeight());
|
2013-12-27 09:59:21 -08:00
|
|
|
if (aReflowState.AvailableHeight() == NS_UNCONSTRAINEDSIZE)
|
2008-01-29 21:48:42 -08:00
|
|
|
// This should never happen, but it does. See bug 414255
|
2013-12-27 09:59:52 -08:00
|
|
|
aMetrics.Height() = aState.mY;
|
2008-01-23 16:28:42 -08:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-10-01 22:57:45 -07: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
|
2013-12-27 09:59:52 -08:00
|
|
|
NS_ASSERTION(aMetrics.Height() == 0, "overflow containers must be zero-height");
|
2007-10-01 22:57:45 -07:00
|
|
|
NS_FRAME_SET_OVERFLOW_INCOMPLETE(aState.mReflowStatus);
|
|
|
|
}
|
|
|
|
|
2008-11-25 14:57:28 -08:00
|
|
|
// Screen out negative heights --- can happen due to integer overflows :-(
|
2013-12-27 09:59:52 -08:00
|
|
|
aMetrics.Height() = std::max(0, aMetrics.Height());
|
2008-12-29 00:18:40 -08:00
|
|
|
*aBottomEdgeOfChildren = bottomEdgeOfChildren;
|
2008-11-25 14:57:28 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef DEBUG_blocks
|
2014-03-11 13:23:50 -07:00
|
|
|
if (CRAZY_SIZE(aMetrics.Width()) || CRAZY_SIZE(aMetrics.Height())) {
|
2007-03-22 10:30:00 -07:00
|
|
|
ListTag(stdout);
|
2013-12-27 09:59:52 -08:00
|
|
|
printf(": WARNING: desired:%d,%d\n", aMetrics.Width(), aMetrics.Height());
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-06-15 14:03:49 -07:00
|
|
|
nsBlockFrame::ComputeOverflowAreas(const nsRect& aBounds,
|
|
|
|
const nsStyleDisplay* aDisplay,
|
|
|
|
nscoord aBottomEdgeOfChildren,
|
|
|
|
nsOverflowAreas& aOverflowAreas)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-10-06 21:25:45 -07:00
|
|
|
// Compute the overflow areas of our children
|
2007-03-22 10:30:00 -07:00
|
|
|
// XXX_perf: This can be done incrementally. It is currently one of
|
|
|
|
// the things that makes incremental reflow O(N^2).
|
2011-06-15 14:03:49 -07:00
|
|
|
nsOverflowAreas areas(aBounds, aBounds);
|
2013-03-06 03:08:16 -08:00
|
|
|
if (!ShouldApplyOverflowClipping(this, aDisplay)) {
|
2007-03-22 10:30:00 -07:00
|
|
|
for (line_iterator line = begin_lines(), line_end = end_lines();
|
|
|
|
line != line_end;
|
|
|
|
++line) {
|
2010-10-06 21:25:45 -07:00
|
|
|
areas.UnionWith(line->GetOverflowAreas());
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-03-07 17:57:37 -08:00
|
|
|
// Factor an outside bullet in; normally the bullet will be factored into
|
2010-10-06 21:25:45 -07:00
|
|
|
// the line-box's overflow areas. However, if the line is a block
|
2007-03-22 10:30:00 -07: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-06 21:25:45 -07:00
|
|
|
// XXXldb Can we just fix GetOverflowArea instead?
|
2012-03-07 17:57:37 -08:00
|
|
|
nsIFrame* outsideBullet = GetOutsideBullet();
|
|
|
|
if (outsideBullet) {
|
|
|
|
areas.UnionAllWith(outsideBullet->GetRect());
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2008-12-29 00:18:40 -08:00
|
|
|
|
2011-06-20 10:03:09 -07: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.
|
2010-10-06 21:25:45 -07: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);
|
2013-01-15 04:22:03 -08:00
|
|
|
o.height = std::max(o.YMost(), aBottomEdgeOfChildren) - o.y;
|
2010-10-06 21:25:45 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
#ifdef NOISY_COMBINED_AREA
|
|
|
|
ListTag(stdout);
|
|
|
|
printf(": ca=%d,%d,%d,%d\n", area.x, area.y, area.width, area.height);
|
|
|
|
#endif
|
|
|
|
|
2011-06-15 14:03:49 -07:00
|
|
|
aOverflowAreas = areas;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
nsBlockFrame::UpdateOverflow()
|
|
|
|
{
|
|
|
|
// We need to update the overflow areas of lines manually, as they
|
|
|
|
// get cached and re-used otherwise. Lines aren't exposed as normal
|
|
|
|
// frame children, so calling UnionChildOverflow alone will end up
|
|
|
|
// using the old cached values.
|
|
|
|
for (line_iterator line = begin_lines(), line_end = end_lines();
|
|
|
|
line != line_end;
|
|
|
|
++line) {
|
|
|
|
nsOverflowAreas lineAreas;
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t n = line->GetChildCount();
|
2011-06-15 14:03:49 -07:00
|
|
|
for (nsIFrame* lineFrame = line->mFirstChild;
|
|
|
|
n > 0; lineFrame = lineFrame->GetNextSibling(), --n) {
|
|
|
|
ConsiderChildOverflow(lineAreas, lineFrame);
|
|
|
|
}
|
|
|
|
|
2012-11-06 09:11:50 -08:00
|
|
|
// Consider the overflow areas of the floats attached to the line as well
|
|
|
|
if (line->HasFloats()) {
|
|
|
|
for (nsFloatCache* fc = line->GetFirstFloat(); fc; fc = fc->Next()) {
|
|
|
|
ConsiderChildOverflow(lineAreas, fc->mFloat);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-15 14:03:49 -07:00
|
|
|
line->SetOverflowAreas(lineAreas);
|
|
|
|
}
|
|
|
|
|
2013-05-29 21:44:37 -07:00
|
|
|
// Line cursor invariants depend on the overflow areas of the lines, so
|
|
|
|
// we must clear the line cursor since those areas may have changed.
|
|
|
|
ClearLineCursor();
|
|
|
|
|
2011-06-15 14:03:49 -07:00
|
|
|
return nsBlockFrameSuper::UpdateOverflow();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-05-13 15:37:00 -07:00
|
|
|
void
|
|
|
|
nsBlockFrame::LazyMarkLinesDirty()
|
|
|
|
{
|
|
|
|
if (GetStateBits() & NS_BLOCK_LOOK_FOR_DIRTY_FRAMES) {
|
|
|
|
for (line_iterator line = begin_lines(), line_end = end_lines();
|
|
|
|
line != line_end; ++line) {
|
|
|
|
int32_t n = line->GetChildCount();
|
|
|
|
for (nsIFrame* lineFrame = line->mFirstChild;
|
|
|
|
n > 0; lineFrame = lineFrame->GetNextSibling(), --n) {
|
|
|
|
if (NS_SUBTREE_DIRTY(lineFrame)) {
|
|
|
|
// NOTE: MarkLineDirty does more than just marking the line dirty.
|
|
|
|
MarkLineDirty(line, &mLines);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RemoveStateBits(NS_BLOCK_LOOK_FOR_DIRTY_FRAMES);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-20 11:27:03 -07:00
|
|
|
void
|
2008-10-12 12:26:06 -07:00
|
|
|
nsBlockFrame::MarkLineDirty(line_iterator aLine, const nsLineList* aLineList)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
// Mark aLine dirty
|
|
|
|
aLine->MarkDirty();
|
2011-10-17 07:59:28 -07:00
|
|
|
aLine->SetInvalidateTextRuns(true);
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (gNoisyReflow) {
|
|
|
|
IndentBy(stdout, gNoiseIndent);
|
|
|
|
ListTag(stdout);
|
2007-07-08 00:08:04 -07:00
|
|
|
printf(": mark line %p dirty\n", static_cast<void*>(aLine.get()));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Mark previous line dirty if it's an inline line so that it can
|
|
|
|
// maybe pullup something from the line just affected.
|
|
|
|
// XXX We don't need to do this if aPrevLine ends in a break-after...
|
2012-07-20 11:27:03 -07:00
|
|
|
if (aLine != aLineList->front() && aLine->IsInline() &&
|
2007-03-22 10:30:00 -07:00
|
|
|
aLine.prev()->IsInline()) {
|
|
|
|
aLine.prev()->MarkDirty();
|
2011-10-17 07:59:28 -07:00
|
|
|
aLine.prev()->SetInvalidateTextRuns(true);
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (gNoisyReflow) {
|
|
|
|
IndentBy(stdout, gNoiseIndent);
|
|
|
|
ListTag(stdout);
|
|
|
|
printf(": mark prev-line %p dirty\n",
|
2007-07-08 00:08:04 -07:00
|
|
|
static_cast<void*>(aLine.prev().get()));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-20 08:49:44 -08:00
|
|
|
/**
|
|
|
|
* Test whether lines are certain to be aligned left so that we can make
|
|
|
|
* resizing optimizations
|
|
|
|
*/
|
2012-08-02 04:38:47 -07:00
|
|
|
static inline bool
|
2012-08-22 08:56:38 -07:00
|
|
|
IsAlignedLeft(uint8_t aAlignment,
|
|
|
|
uint8_t aDirection,
|
|
|
|
uint8_t aUnicodeBidi,
|
2012-08-02 04:38:47 -07:00
|
|
|
nsIFrame* aFrame)
|
2012-02-20 08:49:44 -08:00
|
|
|
{
|
2012-10-09 22:00:05 -07:00
|
|
|
return aFrame->IsSVGText() ||
|
|
|
|
NS_STYLE_TEXT_ALIGN_LEFT == aAlignment ||
|
|
|
|
(((NS_STYLE_TEXT_ALIGN_DEFAULT == aAlignment &&
|
|
|
|
NS_STYLE_DIRECTION_LTR == aDirection) ||
|
|
|
|
(NS_STYLE_TEXT_ALIGN_END == aAlignment &&
|
|
|
|
NS_STYLE_DIRECTION_RTL == aDirection)) &&
|
|
|
|
!(NS_STYLE_UNICODE_BIDI_PLAINTEXT & aUnicodeBidi));
|
2012-02-20 08:49:44 -08:00
|
|
|
}
|
|
|
|
|
2013-06-18 23:09:22 -07:00
|
|
|
void
|
2007-03-22 10:30:00 -07:00
|
|
|
nsBlockFrame::PrepareResizeReflow(nsBlockReflowState& aState)
|
|
|
|
{
|
2013-02-16 13:51:02 -08:00
|
|
|
const nsStyleText* styleText = StyleText();
|
|
|
|
const nsStyleTextReset* styleTextReset = StyleTextReset();
|
2007-03-22 10:30:00 -07:00
|
|
|
// See if we can try and avoid marking all the lines as dirty
|
2011-09-28 23:19:26 -07:00
|
|
|
bool tryAndSkipLines =
|
2012-12-05 14:26:28 -08:00
|
|
|
// The block must be LTR (bug 806284)
|
2013-02-16 13:51:02 -08:00
|
|
|
StyleVisibility()->mDirection == NS_STYLE_DIRECTION_LTR &&
|
2012-12-05 14:26:28 -08:00
|
|
|
// The text must be left-aligned.
|
2012-02-20 08:49:44 -08:00
|
|
|
IsAlignedLeft(styleText->mTextAlign,
|
|
|
|
aState.mReflowState.mStyleVisibility->mDirection,
|
2012-08-02 04:38:47 -07:00
|
|
|
styleTextReset->mUnicodeBidi,
|
|
|
|
this) &&
|
2012-12-05 14:26:28 -08:00
|
|
|
// The left content-edge must be a constant distance from the left
|
|
|
|
// border-edge.
|
2013-02-16 13:51:02 -08:00
|
|
|
!StylePadding()->mPadding.GetLeft().HasPercent();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (gDisableResizeOpt) {
|
2011-10-17 07:59:28 -07:00
|
|
|
tryAndSkipLines = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
if (gNoisyReflow) {
|
|
|
|
if (!tryAndSkipLines) {
|
|
|
|
IndentBy(stdout, gNoiseIndent);
|
|
|
|
ListTag(stdout);
|
|
|
|
printf(": marking all lines dirty: availWidth=%d textAlign=%d\n",
|
2013-12-27 09:59:21 -08:00
|
|
|
aState.mReflowState.AvailableWidth(),
|
2007-03-22 10:30:00 -07:00
|
|
|
styleText->mTextAlign);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (tryAndSkipLines) {
|
2013-12-27 09:59:21 -08:00
|
|
|
nscoord newAvailWidth = aState.mReflowState.ComputedPhysicalBorderPadding().left +
|
2007-03-22 10:30:00 -07:00
|
|
|
aState.mReflowState.ComputedWidth();
|
2013-12-27 09:59:21 -08:00
|
|
|
NS_ASSERTION(NS_UNCONSTRAINEDSIZE != aState.mReflowState.ComputedPhysicalBorderPadding().left &&
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_UNCONSTRAINEDSIZE != aState.mReflowState.ComputedWidth(),
|
|
|
|
"math on NS_UNCONSTRAINEDSIZE");
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (gNoisyReflow) {
|
|
|
|
IndentBy(stdout, gNoiseIndent);
|
|
|
|
ListTag(stdout);
|
|
|
|
printf(": trying to avoid marking all lines dirty\n");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-02-20 08:49:44 -08:00
|
|
|
// The last line might not be aligned left even if the rest of the block is
|
|
|
|
bool skipLastLine = NS_STYLE_TEXT_ALIGN_AUTO == styleText->mTextAlignLast ||
|
|
|
|
IsAlignedLeft(styleText->mTextAlignLast,
|
|
|
|
aState.mReflowState.mStyleVisibility->mDirection,
|
2012-08-02 04:38:47 -07:00
|
|
|
styleTextReset->mUnicodeBidi,
|
|
|
|
this);
|
2012-02-20 08:49:44 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
for (line_iterator line = begin_lines(), line_end = end_lines();
|
|
|
|
line != line_end;
|
|
|
|
++line)
|
|
|
|
{
|
|
|
|
// We let child blocks make their own decisions the same
|
|
|
|
// way we are here.
|
2012-02-20 08:49:44 -08:00
|
|
|
bool isLastLine = line == mLines.back() && !GetNextInFlow();
|
2007-03-22 10:30:00 -07:00
|
|
|
if (line->IsBlock() ||
|
|
|
|
line->HasFloats() ||
|
2012-02-20 08:49:44 -08:00
|
|
|
(!isLastLine && !line->HasBreakAfter()) ||
|
|
|
|
((isLastLine || !line->IsLineWrapped()) && !skipLastLine) ||
|
2007-03-22 10:30:00 -07:00
|
|
|
line->ResizeReflowOptimizationDisabled() ||
|
|
|
|
line->IsImpactedByFloat() ||
|
|
|
|
(line->mBounds.XMost() > newAvailWidth)) {
|
|
|
|
line->MarkDirty();
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef REALLY_NOISY_REFLOW
|
|
|
|
if (!line->IsBlock()) {
|
|
|
|
printf("PrepareResizeReflow thinks line %p is %simpacted by floats\n",
|
|
|
|
line.get(), line->IsImpactedByFloat() ? "" : "not ");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (gNoisyReflow && !line->IsDirty()) {
|
|
|
|
IndentBy(stdout, gNoiseIndent + 1);
|
2012-02-20 08:49:44 -08:00
|
|
|
printf("skipped: line=%p next=%p %s %s%s%s%s breakTypeBefore/After=%d/%d xmost=%d\n",
|
2007-07-08 00:08:04 -07:00
|
|
|
static_cast<void*>(line.get()),
|
2012-07-30 07:20:58 -07:00
|
|
|
static_cast<void*>((line.next() != end_lines() ? line.next().get() : nullptr)),
|
2007-03-22 10:30:00 -07:00
|
|
|
line->IsBlock() ? "block" : "inline",
|
|
|
|
line->HasBreakAfter() ? "has-break-after " : "",
|
|
|
|
line->HasFloats() ? "has-floats " : "",
|
|
|
|
line->IsImpactedByFloat() ? "impacted " : "",
|
2012-02-20 08:49:44 -08:00
|
|
|
skipLastLine ? "last-line-left-aligned " : "",
|
2007-03-22 10:30:00 -07:00
|
|
|
line->GetBreakTypeBefore(), line->GetBreakTypeAfter(),
|
|
|
|
line->mBounds.XMost());
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Mark everything dirty
|
|
|
|
for (line_iterator line = begin_lines(), line_end = end_lines();
|
|
|
|
line != line_end;
|
|
|
|
++line)
|
|
|
|
{
|
|
|
|
line->MarkDirty();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Propagate reflow "damage" from from earlier lines to the current
|
|
|
|
* line. The reflow damage comes from the following sources:
|
|
|
|
* 1. The regions of float damage remembered during reflow.
|
|
|
|
* 2. The combination of nonzero |aDeltaY| and any impact by a float,
|
|
|
|
* either the previous reflow or now.
|
|
|
|
*
|
|
|
|
* 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).
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
nsBlockFrame::PropagateFloatDamage(nsBlockReflowState& aState,
|
|
|
|
nsLineBox* aLine,
|
|
|
|
nscoord aDeltaY)
|
|
|
|
{
|
2009-01-04 16:39:54 -08:00
|
|
|
nsFloatManager *floatManager = aState.mReflowState.mFloatManager;
|
2007-08-20 13:07:50 -07:00
|
|
|
NS_ASSERTION((aState.mReflowState.parentReflowState &&
|
2009-01-04 16:39:54 -08:00
|
|
|
aState.mReflowState.parentReflowState->mFloatManager == floatManager) ||
|
2007-08-20 13:07:50 -07: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-04 16:39:54 -08:00
|
|
|
if (!floatManager->HasAnyFloats())
|
2007-08-20 13:07:50 -07:00
|
|
|
return;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Check the damage region recorded in the float damage.
|
2009-01-04 16:39:54 -08:00
|
|
|
if (floatManager->HasFloatDamage()) {
|
2007-11-07 12:07:54 -08:00
|
|
|
// Need to check mBounds *and* mCombinedArea to find intersections
|
|
|
|
// with aLine's floats
|
2007-03-22 10:30:00 -07:00
|
|
|
nscoord lineYA = aLine->mBounds.y + aDeltaY;
|
|
|
|
nscoord lineYB = lineYA + aLine->mBounds.height;
|
2010-10-06 21:25:45 -07: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-04 16:39:54 -08:00
|
|
|
if (floatManager->IntersectsDamage(lineYA, lineYB) ||
|
|
|
|
floatManager->IntersectsDamage(lineYCombinedA, lineYCombinedB)) {
|
2007-03-22 10:30:00 -07:00
|
|
|
aLine->MarkDirty();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-04 16:39:54 -08:00
|
|
|
// Check if the line is moving relative to the float manager
|
2007-08-20 13:07:50 -07:00
|
|
|
if (aDeltaY + aState.mReflowState.mBlockDelta != 0) {
|
|
|
|
if (aLine->IsBlock()) {
|
|
|
|
// Unconditionally reflow sliding blocks; we only really need to reflow
|
2009-01-04 16:39:54 -08:00
|
|
|
// if there's a float impacting this block, but the current float manager
|
2007-08-20 13:07:50 -07:00
|
|
|
// makes it difficult to check that. Therefore, we let the child block
|
|
|
|
// decide what it needs to reflow.
|
|
|
|
aLine->MarkDirty();
|
|
|
|
} else {
|
2011-09-28 23:19:26 -07:00
|
|
|
bool wasImpactedByFloat = aLine->IsImpactedByFloat();
|
2009-04-08 13:52:37 -07:00
|
|
|
nsFlowAreaRect floatAvailableSpace =
|
2009-05-20 04:21:34 -07:00
|
|
|
aState.GetFloatAvailableSpaceForHeight(aLine->mBounds.y + aDeltaY,
|
|
|
|
aLine->mBounds.height,
|
2012-07-30 07:20:58 -07:00
|
|
|
nullptr);
|
2007-08-20 13:07:50 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef REALLY_NOISY_REFLOW
|
|
|
|
printf("nsBlockFrame::PropagateFloatDamage %p was = %d, is=%d\n",
|
2009-04-08 13:52:37 -07:00
|
|
|
this, wasImpactedByFloat, floatAvailableSpace.mHasFloats);
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
2007-08-20 13:07:50 -07: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 13:52:37 -07:00
|
|
|
if (wasImpactedByFloat || floatAvailableSpace.mHasFloats) {
|
2007-08-20 13:07:50 -07:00
|
|
|
aLine->MarkDirty();
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool LineHasClear(nsLineBox* aLine) {
|
2008-01-28 23:40:05 -08:00
|
|
|
return aLine->IsBlock()
|
|
|
|
? (aLine->GetBreakTypeBefore() ||
|
|
|
|
(aLine->mFirstChild->GetStateBits() & NS_BLOCK_HAS_CLEAR_CHILDREN) ||
|
|
|
|
!nsBlockFrame::BlockCanIntersectFloats(aLine->mFirstChild))
|
|
|
|
: aLine->HasFloatBreakAfter();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reparent a whole list of floats from aOldParent to this block. The
|
|
|
|
* floats might be taken from aOldParent's overflow list. They will be
|
|
|
|
* removed from the list. They end up appended to our mFloats list.
|
|
|
|
*/
|
|
|
|
void
|
2013-02-27 15:05:45 -08:00
|
|
|
nsBlockFrame::ReparentFloats(nsIFrame* aFirstFrame, nsBlockFrame* aOldParent,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aReparentSiblings) {
|
2007-03-22 10:30:00 -07:00
|
|
|
nsFrameList list;
|
2013-02-27 15:05:45 -08:00
|
|
|
aOldParent->CollectFloats(aFirstFrame, list, aReparentSiblings);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (list.NotEmpty()) {
|
|
|
|
for (nsIFrame* f = list.FirstChild(); f; f = f->GetNextSibling()) {
|
|
|
|
ReparentFrame(f, aOldParent, this);
|
|
|
|
}
|
2012-07-30 07:20:58 -07:00
|
|
|
mFloats.AppendFrames(nullptr, list);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void DumpLine(const nsBlockReflowState& aState, nsLineBox* aLine,
|
2012-08-22 08:56:38 -07:00
|
|
|
nscoord aDeltaY, int32_t aDeltaIndent) {
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (nsBlockFrame::gNoisyReflow) {
|
2010-10-06 21:25:45 -07:00
|
|
|
nsRect ovis(aLine->GetVisualOverflowArea());
|
|
|
|
nsRect oscr(aLine->GetScrollableOverflowArea());
|
2007-03-22 10:30:00 -07:00
|
|
|
nsBlockFrame::IndentBy(stdout, nsBlockFrame::gNoiseIndent + aDeltaIndent);
|
2010-10-06 21:25:45 -07: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 00:08:04 -07:00
|
|
|
static_cast<void*>(aLine), aState.mY,
|
2007-03-22 10:30:00 -07:00
|
|
|
aLine->IsDirty() ? "yes" : "no",
|
|
|
|
aLine->mBounds.x, aLine->mBounds.y,
|
|
|
|
aLine->mBounds.width, aLine->mBounds.height,
|
2010-10-06 21:25:45 -07:00
|
|
|
ovis.x, ovis.y, ovis.width, ovis.height,
|
|
|
|
oscr.x, oscr.y, oscr.width, oscr.height,
|
2007-03-22 10:30:00 -07:00
|
|
|
aDeltaY, aState.mPrevBottomMargin.get(), aLine->GetChildCount());
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reflow the dirty lines
|
|
|
|
*/
|
|
|
|
nsresult
|
|
|
|
nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool keepGoing = true;
|
|
|
|
bool repositionViews = false; // should we really need this?
|
|
|
|
bool foundAnyClears = aState.mFloatBreakType != NS_STYLE_CLEAR_NONE;
|
|
|
|
bool willReflowAgain = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (gNoisyReflow) {
|
|
|
|
IndentBy(stdout, gNoiseIndent);
|
|
|
|
ListTag(stdout);
|
|
|
|
printf(": reflowing dirty lines");
|
|
|
|
printf(" computedWidth=%d\n", aState.mReflowState.ComputedWidth());
|
|
|
|
}
|
|
|
|
AutoNoisyIndenter indent(gNoisyReflow);
|
|
|
|
#endif
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool selfDirty = (GetStateBits() & NS_FRAME_IS_DIRTY) ||
|
2007-03-22 10:30:00 -07:00
|
|
|
(aState.mReflowState.mFlags.mVResize &&
|
|
|
|
(GetStateBits() & NS_FRAME_CONTAINS_RELATIVE_HEIGHT));
|
2009-07-06 18:23:24 -07:00
|
|
|
|
|
|
|
// Reflow our last line if our availableHeight has increased
|
|
|
|
// so that we (and our last child) pull up content as necessary
|
2013-12-27 09:59:21 -08:00
|
|
|
if (aState.mReflowState.AvailableHeight() != NS_UNCONSTRAINEDSIZE
|
|
|
|
&& GetNextInFlow() && aState.mReflowState.AvailableHeight() > mRect.height) {
|
2009-07-06 18:23:24 -07:00
|
|
|
line_iterator lastLine = end_lines();
|
|
|
|
if (lastLine != begin_lines()) {
|
|
|
|
--lastLine;
|
|
|
|
lastLine->MarkDirty();
|
|
|
|
}
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
// the amount by which we will slide the current line if it is not
|
|
|
|
// dirty
|
|
|
|
nscoord deltaY = 0;
|
|
|
|
|
|
|
|
// 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
|
2011-09-28 23:19:26 -07:00
|
|
|
bool needToRecoverState = false;
|
2010-08-05 21:59:20 -07:00
|
|
|
// Float continuations were reflowed in ReflowPushedFloats
|
2011-09-28 23:19:26 -07:00
|
|
|
bool reflowedFloat = mFloats.NotEmpty() &&
|
2010-08-05 21:59:20 -07:00
|
|
|
(mFloats.FirstChild()->GetStateBits() & NS_FRAME_IS_PUSHED_FLOAT);
|
2011-09-28 23:19:26 -07:00
|
|
|
bool lastLineMovedUp = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
// We save up information about BR-clearance here
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t inlineFloatBreakType = aState.mFloatBreakType;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
line_iterator line = begin_lines(), line_end = end_lines();
|
|
|
|
|
|
|
|
// Reflow the lines that are already ours
|
|
|
|
for ( ; line != line_end; ++line, aState.AdvanceToNextLine()) {
|
|
|
|
DumpLine(aState, line, deltaY, 0);
|
|
|
|
#ifdef DEBUG
|
|
|
|
AutoNoisyIndenter indent2(gNoisyReflow);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (selfDirty)
|
|
|
|
line->MarkDirty();
|
|
|
|
|
|
|
|
// This really sucks, but we have to look inside any blocks that have clear
|
|
|
|
// elements inside them.
|
|
|
|
// XXX what can we do smarter here?
|
|
|
|
if (!line->IsDirty() && line->IsBlock() &&
|
|
|
|
(line->mFirstChild->GetStateBits() & NS_BLOCK_HAS_CLEAR_CHILDREN)) {
|
|
|
|
line->MarkDirty();
|
|
|
|
}
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
nsIFrame *replacedBlock = nullptr;
|
2008-01-28 23:40:05 -08:00
|
|
|
if (line->IsBlock() &&
|
|
|
|
!nsBlockFrame::BlockCanIntersectFloats(line->mFirstChild)) {
|
2008-05-03 16:33:36 -07:00
|
|
|
replacedBlock = line->mFirstChild;
|
2008-01-28 23:40:05 -08:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// We have to reflow the line if it's a block whose clearance
|
|
|
|
// might have changed, so detect that.
|
2008-01-28 23:40:05 -08:00
|
|
|
if (!line->IsDirty() &&
|
|
|
|
(line->GetBreakTypeBefore() != NS_STYLE_CLEAR_NONE ||
|
2008-05-03 16:33:36 -07:00
|
|
|
replacedBlock)) {
|
2007-03-22 10:30:00 -07: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-28 23:40:05 -08:00
|
|
|
nscoord newY =
|
2008-05-03 16:33:36 -07:00
|
|
|
aState.ClearFloats(curY, line->GetBreakTypeBefore(), replacedBlock);
|
2007-03-22 10:30:00 -07: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;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool previousMarginWasDirty = line->IsPreviousMarginDirty();
|
2007-03-22 10:30:00 -07:00
|
|
|
if (previousMarginWasDirty) {
|
|
|
|
// If the previous margin is dirty, reflow the current line
|
|
|
|
line->MarkDirty();
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2010-08-05 21:59:20 -07: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() &&
|
2013-12-27 09:59:21 -08:00
|
|
|
aState.mReflowState.AvailableHeight() != NS_UNCONSTRAINEDSIZE &&
|
2013-04-08 11:38:33 -07:00
|
|
|
(deltaY != 0 || aState.mReflowState.mFlags.mVResize ||
|
|
|
|
aState.mReflowState.mFlags.mMustReflowPlaceholders) &&
|
2010-08-05 21:59:20 -07:00
|
|
|
(line->IsBlock() || line->HasFloats() || line->HadFloatPushed())) {
|
|
|
|
line->MarkDirty();
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!line->IsDirty()) {
|
|
|
|
// See if there's any reflow damage that requires that we mark the
|
|
|
|
// line dirty.
|
|
|
|
PropagateFloatDamage(aState, line, deltaY);
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool reflowedPrevLine = !needToRecoverState;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (needToRecoverState) {
|
2011-10-17 07:59:28 -07:00
|
|
|
needToRecoverState = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Update aState.mPrevChild as if we had reflowed all of the frames in
|
2012-02-17 17:34:20 -08:00
|
|
|
// this line.
|
2014-03-15 14:29:24 -07:00
|
|
|
if (line->IsDirty()) {
|
2012-02-17 17:34:20 -08:00
|
|
|
NS_ASSERTION(line->mFirstChild->GetPrevSibling() ==
|
|
|
|
line.prev()->LastChild(), "unexpected line frames");
|
|
|
|
aState.mPrevChild = line->mFirstChild->GetPrevSibling();
|
2014-03-15 14:29:24 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Now repair the line and update |aState.mY| by calling
|
|
|
|
// |ReflowLine| or |SlideLine|.
|
2007-12-01 00:29:02 -08: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)) {
|
2011-10-17 07:59:28 -07:00
|
|
|
lastLineMovedUp = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool maybeReflowingForFirstTime =
|
2007-03-22 10:30:00 -07:00
|
|
|
line->mBounds.x == 0 && line->mBounds.y == 0 &&
|
|
|
|
line->mBounds.width == 0 && line->mBounds.height == 0;
|
|
|
|
|
|
|
|
// Compute the dirty lines "before" YMost, after factoring in
|
|
|
|
// the running deltaY value - the running value is implicit in
|
|
|
|
// aState.mY.
|
|
|
|
nscoord oldY = line->mBounds.y;
|
|
|
|
nscoord oldYMost = line->mBounds.YMost();
|
|
|
|
|
2007-12-04 18:57:53 -08:00
|
|
|
NS_ASSERTION(!willReflowAgain || !line->IsBlock(),
|
|
|
|
"Don't reflow blocks while willReflowAgain is true, reflow of block abs-pos children depends on this");
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Reflow the dirty line. If it's an incremental reflow, then force
|
|
|
|
// it to invalidate the dirty area if necessary
|
|
|
|
rv = ReflowLine(aState, line, &keepGoing);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2007-11-29 17:49:01 -08:00
|
|
|
|
2007-12-04 18:57:53 -08:00
|
|
|
if (aState.mReflowState.WillReflowAgainForClearance()) {
|
2007-11-29 17:49:01 -08:00
|
|
|
line->MarkDirty();
|
2011-10-17 07:59:28 -07:00
|
|
|
willReflowAgain = true;
|
2007-12-01 00:29:02 -08: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-29 17:49:01 -08:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (line->HasFloats()) {
|
2011-10-17 07:59:28 -07:00
|
|
|
reflowedFloat = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!keepGoing) {
|
|
|
|
DumpLine(aState, line, deltaY, -1);
|
|
|
|
if (0 == line->GetChildCount()) {
|
|
|
|
DeleteLine(aState, line, line_end);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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()) {
|
2011-09-28 23:19:26 -07:00
|
|
|
bool maybeWasEmpty = oldY == line.next()->mBounds.y;
|
|
|
|
bool isEmpty = line->CachedIsEmpty();
|
2007-03-22 10:30:00 -07:00
|
|
|
if (maybeReflowingForFirstTime /*1*/ ||
|
|
|
|
(isEmpty || maybeWasEmpty) /*2/3/4*/) {
|
|
|
|
line.next()->MarkPreviousMarginDirty();
|
|
|
|
// since it's marked dirty, nobody will care about |deltaY|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
deltaY = line->mBounds.YMost() - oldYMost;
|
2009-07-30 08:53:36 -07: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);
|
2007-03-22 10:30:00 -07:00
|
|
|
} else {
|
2009-09-13 17:26:01 -07:00
|
|
|
aState.mOverflowTracker->Skip(line->mFirstChild, aState.mReflowStatus);
|
2007-07-25 21:03:29 -07:00
|
|
|
// Nop except for blocks (we don't create overflow container
|
|
|
|
// continuations for any inlines atm), so only checking mFirstChild
|
|
|
|
// is enough
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
lastLineMovedUp = deltaY < 0;
|
|
|
|
|
|
|
|
if (deltaY != 0)
|
|
|
|
SlideLine(aState, line, deltaY);
|
|
|
|
else
|
2011-10-17 07:59:28 -07:00
|
|
|
repositionViews = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-12-03 17:30:49 -08: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-04 16:39:54 -08:00
|
|
|
// add floats to the float manager. We don't need to do that because
|
2007-12-03 17:30:49 -08: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 00:29:02 -08:00
|
|
|
} else {
|
|
|
|
// XXX EVIL O(N^2) EVIL
|
|
|
|
aState.RecoverStateFrom(line, deltaY);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Keep mY up to date in case we're propagating reflow damage
|
|
|
|
// 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()) {
|
|
|
|
aState.mY = line->mBounds.YMost();
|
|
|
|
}
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
needToRecoverState = true;
|
2009-07-24 06:32:32 -07: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;
|
2011-08-24 13:54:30 -07:00
|
|
|
inlineKid = inlineKid->GetFirstPrincipalChild()) {
|
2009-07-24 06:32:32 -07:00
|
|
|
inlineKid->PullOverflowsFromPrevInFlow();
|
|
|
|
}
|
|
|
|
}
|
2007-03-22 10:30:00 -07: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();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (LineHasClear(line.get())) {
|
2011-10-17 07:59:28 -07:00
|
|
|
foundAnyClears = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
DumpLine(aState, line, deltaY, -1);
|
2009-04-21 16:53:52 -07:00
|
|
|
|
2009-07-30 08:53:36 -07:00
|
|
|
if (aState.mPresContext->HasPendingInterrupt()) {
|
2011-10-17 07:59:28 -07:00
|
|
|
willReflowAgain = true;
|
2009-04-21 16:53:52 -07:00
|
|
|
// 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);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Handle BR-clearance from the last line of the block
|
|
|
|
if (inlineFloatBreakType != NS_STYLE_CLEAR_NONE) {
|
|
|
|
aState.mY = aState.ClearFloats(aState.mY, inlineFloatBreakType);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (needToRecoverState) {
|
|
|
|
// Is this expensive?
|
|
|
|
aState.ReconstructMarginAbove(line);
|
|
|
|
|
|
|
|
// Update aState.mPrevChild as if we had reflowed all of the frames in
|
2012-02-17 17:34:20 -08:00
|
|
|
// the last line.
|
|
|
|
NS_ASSERTION(line == line_end || line->mFirstChild->GetPrevSibling() ==
|
|
|
|
line.prev()->LastChild(), "unexpected line frames");
|
|
|
|
aState.mPrevChild =
|
|
|
|
line == line_end ? mFrames.LastChild() : line->mFirstChild->GetPrevSibling();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Should we really have to do this?
|
|
|
|
if (repositionViews)
|
2013-11-15 05:19:02 -08:00
|
|
|
nsContainerFrame::PlaceFrameView(this);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-04-21 16:53:52 -07: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.,
|
2007-03-22 10:30:00 -07:00
|
|
|
// -- the next in flow is not changing
|
|
|
|
// -- and we cannot have added more space for its first line to be
|
|
|
|
// pulled up into,
|
|
|
|
// -- it's an incremental reflow of a descendant
|
|
|
|
// -- and we didn't reflow any floats (so the available space
|
|
|
|
// didn't change)
|
2007-09-24 12:52:09 -07:00
|
|
|
// -- my chain of next-in-flows either has no first line, or its first
|
|
|
|
// line isn't dirty.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool heightConstrained =
|
2013-12-27 09:59:21 -08:00
|
|
|
aState.mReflowState.AvailableHeight() != NS_UNCONSTRAINEDSIZE;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool skipPull = willReflowAgain && heightConstrained;
|
2009-04-21 16:53:52 -07:00
|
|
|
if (!skipPull && heightConstrained && aState.mNextInFlow &&
|
2007-03-22 10:30:00 -07:00
|
|
|
(aState.mReflowState.mFlags.mNextInFlowUntouched &&
|
|
|
|
!lastLineMovedUp &&
|
|
|
|
!(GetStateBits() & NS_FRAME_IS_DIRTY) &&
|
|
|
|
!reflowedFloat)) {
|
2007-09-24 12:52:09 -07: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.
|
2012-03-07 17:57:37 -08:00
|
|
|
nsBlockInFlowLineIterator bifLineIter(this, lineIter);
|
2007-09-24 12:52:09 -07:00
|
|
|
|
|
|
|
// 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()) {
|
2011-10-17 07:59:28 -07:00
|
|
|
skipPull=true;
|
2007-09-24 12:52:09 -07:00
|
|
|
}
|
|
|
|
}
|
2007-07-25 21:03:29 -07:00
|
|
|
}
|
2009-04-21 16:53:52 -07: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 12:52:09 -07:00
|
|
|
|
|
|
|
if (!skipPull && aState.mNextInFlow) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// Pull data from a next-in-flow if there's still room for more
|
|
|
|
// content here.
|
2012-03-07 17:57:37 -08:00
|
|
|
while (keepGoing && aState.mNextInFlow) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// Grab first line from our next-in-flow
|
|
|
|
nsBlockFrame* nextInFlow = aState.mNextInFlow;
|
2012-03-07 17:57:37 -08:00
|
|
|
nsLineBox* pulledLine;
|
|
|
|
nsFrameList pulledFrames;
|
|
|
|
if (!nextInFlow->mLines.empty()) {
|
|
|
|
RemoveFirstLine(nextInFlow->mLines, nextInFlow->mFrames,
|
|
|
|
&pulledLine, &pulledFrames);
|
2007-03-22 10:30:00 -07:00
|
|
|
} else {
|
|
|
|
// Grab an overflow line if there are any
|
2012-03-07 17:57:37 -08:00
|
|
|
FrameLines* overflowLines = nextInFlow->GetOverflowLines();
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!overflowLines) {
|
|
|
|
aState.mNextInFlow =
|
2007-07-08 00:08:04 -07:00
|
|
|
static_cast<nsBlockFrame*>(nextInFlow->GetNextInFlow());
|
2007-03-22 10:30:00 -07:00
|
|
|
continue;
|
|
|
|
}
|
2012-03-07 17:57:37 -08:00
|
|
|
bool last =
|
|
|
|
RemoveFirstLine(overflowLines->mLines, overflowLines->mFrames,
|
|
|
|
&pulledLine, &pulledFrames);
|
|
|
|
if (last) {
|
|
|
|
nextInFlow->DestroyOverflowLines();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-07 17:57:37 -08:00
|
|
|
if (pulledFrames.IsEmpty()) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// The line is empty. Try the next one.
|
2012-03-07 17:57:37 -08:00
|
|
|
NS_ASSERTION(pulledLine->GetChildCount() == 0 &&
|
|
|
|
!pulledLine->mFirstChild, "bad empty line");
|
2012-05-03 17:14:01 -07:00
|
|
|
nextInFlow->FreeLineBox(pulledLine);
|
2007-03-22 10:30:00 -07:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2012-05-03 17:14:01 -07:00
|
|
|
if (pulledLine == nextInFlow->GetLineCursor()) {
|
|
|
|
nextInFlow->ClearLineCursor();
|
|
|
|
}
|
2012-03-07 17:57:37 -08:00
|
|
|
ReparentFrames(pulledFrames, nextInFlow, this);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-03-07 17:57:37 -08:00
|
|
|
NS_ASSERTION(pulledFrames.LastChild() == pulledLine->LastChild(),
|
|
|
|
"Unexpected last frame");
|
2009-09-10 15:26:30 -07:00
|
|
|
NS_ASSERTION(aState.mPrevChild || mLines.empty(), "should have a prevchild here");
|
2009-09-29 12:47:05 -07:00
|
|
|
NS_ASSERTION(aState.mPrevChild == mFrames.LastChild(),
|
|
|
|
"Incorrect aState.mPrevChild before inserting line at end");
|
|
|
|
|
2012-03-07 17:57:37 -08:00
|
|
|
// Shift pulledLine's frames into our mFrames list.
|
2012-07-30 07:20:58 -07:00
|
|
|
mFrames.AppendFrames(nullptr, pulledFrames);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-09-29 12:47:05 -07:00
|
|
|
// Add line to our line list, and set its last child as our new prev-child
|
2012-03-07 17:57:37 -08:00
|
|
|
line = mLines.before_insert(end_lines(), pulledLine);
|
|
|
|
aState.mPrevChild = mFrames.LastChild();
|
2009-09-29 12:47:05 -07:00
|
|
|
|
|
|
|
// Reparent floats whose placeholders are in the line.
|
2013-02-27 15:05:45 -08:00
|
|
|
ReparentFloats(pulledLine->mFirstChild, nextInFlow, true);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-03-07 17:57:37 -08:00
|
|
|
DumpLine(aState, pulledLine, deltaY, 0);
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
AutoNoisyIndenter indent2(gNoisyReflow);
|
|
|
|
#endif
|
|
|
|
|
2009-04-21 16:53:52 -07:00
|
|
|
if (aState.mPresContext->HasPendingInterrupt()) {
|
|
|
|
MarkLineDirtyForInterrupt(line);
|
|
|
|
} else {
|
|
|
|
// Now reflow it and any lines that it makes during it's reflow
|
2009-06-12 18:28:41 -07:00
|
|
|
// (we have to loop here because reflowing the line may cause a new
|
2009-04-21 16:53:52 -07: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-12 17:56:08 -07:00
|
|
|
|
|
|
|
if (aState.mReflowState.WillReflowAgainForClearance()) {
|
|
|
|
line->MarkDirty();
|
2011-10-17 07:59:28 -07:00
|
|
|
keepGoing = false;
|
2010-08-05 21:59:20 -07:00
|
|
|
NS_FRAME_SET_INCOMPLETE(aState.mReflowStatus);
|
2010-05-12 17:56:08 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-04-21 16:53:52 -07:00
|
|
|
DumpLine(aState, line, deltaY, -1);
|
|
|
|
if (!keepGoing) {
|
|
|
|
if (0 == line->GetChildCount()) {
|
|
|
|
DeleteLine(aState, line, line_end);
|
|
|
|
}
|
|
|
|
break;
|
2009-04-21 16:53:52 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-04-21 16:53:52 -07:00
|
|
|
if (LineHasClear(line.get())) {
|
2011-10-17 07:59:28 -07:00
|
|
|
foundAnyClears = true;
|
2009-04-21 16:53:52 -07:00
|
|
|
}
|
2009-04-21 20:02:17 -07:00
|
|
|
|
2009-04-21 16:53:52 -07:00
|
|
|
if (aState.mPresContext->CheckForInterrupt(this)) {
|
|
|
|
MarkLineDirtyForInterrupt(line);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If this is an inline frame then its time to stop
|
|
|
|
++line;
|
|
|
|
aState.AdvanceToNextLine();
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_FRAME_IS_NOT_COMPLETE(aState.mReflowStatus)) {
|
|
|
|
aState.mReflowStatus |= NS_FRAME_REFLOW_NEXTINFLOW;
|
2007-07-25 21:03:29 -07:00
|
|
|
} //XXXfr shouldn't set this flag when nextinflow has no lines
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Handle an odd-ball case: a list-item with no lines
|
2012-03-07 17:57:37 -08:00
|
|
|
if (HasOutsideBullet() && mLines.empty()) {
|
2013-12-31 05:50:31 -08:00
|
|
|
nsHTMLReflowMetrics metrics(aState.mReflowState);
|
2012-03-07 17:57:37 -08:00
|
|
|
nsIFrame* bullet = GetOutsideBullet();
|
|
|
|
ReflowBullet(bullet, aState, metrics,
|
2013-12-27 09:59:21 -08:00
|
|
|
aState.mReflowState.ComputedPhysicalBorderPadding().top);
|
2013-12-27 09:59:52 -08:00
|
|
|
NS_ASSERTION(!BulletIsEmpty() || metrics.Height() == 0,
|
2009-09-11 03:46:36 -07:00
|
|
|
"empty bullet took up space");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-09-11 03:46:36 -07: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-10 19:48:42 -07:00
|
|
|
|
2013-12-27 09:59:52 -08:00
|
|
|
if (metrics.TopAscent() == nsHTMLReflowMetrics::ASK_FOR_BASELINE) {
|
|
|
|
nscoord ascent;
|
|
|
|
if (nsLayoutUtils::GetFirstLineBaseline(bullet, &ascent)) {
|
|
|
|
metrics.SetTopAscent(ascent);
|
|
|
|
} else {
|
|
|
|
metrics.SetTopAscent(metrics.Height());
|
|
|
|
}
|
2009-09-11 03:46:36 -07:00
|
|
|
}
|
2009-08-10 19:48:42 -07:00
|
|
|
|
2011-08-14 10:08:04 -07:00
|
|
|
nsRefPtr<nsFontMetrics> fm;
|
2011-11-23 18:48:23 -08:00
|
|
|
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm),
|
2012-05-20 22:18:28 -07:00
|
|
|
nsLayoutUtils::FontSizeInflationFor(this));
|
2011-08-14 10:08:04 -07:00
|
|
|
aState.mReflowState.rendContext->SetFont(fm); // FIXME: needed?
|
2009-08-10 19:48:42 -07:00
|
|
|
|
2009-09-11 03:46:36 -07:00
|
|
|
nscoord minAscent =
|
2011-08-14 10:08:04 -07:00
|
|
|
nsLayoutUtils::GetCenteredFontBaseline(fm, aState.mMinLineHeight);
|
2009-09-11 03:46:36 -07:00
|
|
|
nscoord minDescent = aState.mMinLineHeight - minAscent;
|
2009-08-10 19:48:42 -07:00
|
|
|
|
2013-12-27 09:59:52 -08:00
|
|
|
aState.mY += std::max(minAscent, metrics.TopAscent()) +
|
|
|
|
std::max(minDescent, metrics.Height() - metrics.TopAscent());
|
2009-08-10 19:48:42 -07:00
|
|
|
|
2013-12-27 09:59:52 -08:00
|
|
|
nscoord offset = minAscent - metrics.TopAscent();
|
2009-09-11 03:46:36 -07:00
|
|
|
if (offset > 0) {
|
2012-03-07 17:57:37 -08:00
|
|
|
bullet->SetRect(bullet->GetRect() + nsPoint(0, offset));
|
2009-09-11 03:46:36 -07:00
|
|
|
}
|
2009-08-10 19:48:42 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (foundAnyClears) {
|
|
|
|
AddStateBits(NS_BLOCK_HAS_CLEAR_CHILDREN);
|
|
|
|
} else {
|
|
|
|
RemoveStateBits(NS_BLOCK_HAS_CLEAR_CHILDREN);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2012-05-03 17:14:01 -07:00
|
|
|
VerifyLines(true);
|
|
|
|
VerifyOverflowSituation();
|
2007-03-22 10:30:00 -07:00
|
|
|
if (gNoisyReflow) {
|
|
|
|
IndentBy(stdout, gNoiseIndent - 1);
|
|
|
|
ListTag(stdout);
|
|
|
|
printf(": done reflowing dirty lines (status=%x)\n",
|
|
|
|
aState.mReflowStatus);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2009-04-21 16:53:52 -07: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.
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t n = aLine->GetChildCount();
|
2009-04-21 16:53:52 -07:00
|
|
|
for (nsIFrame* f = aLine->mFirstChild; n > 0;
|
|
|
|
f = f->GetNextSibling(), --n) {
|
|
|
|
f->AddStateBits(NS_FRAME_IS_DIRTY);
|
2009-05-09 20:51:34 -07: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 11:25:35 -07:00
|
|
|
fc->mFloat->AddStateBits(NS_FRAME_IS_DIRTY);
|
2009-04-21 16:53:52 -07: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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
void
|
|
|
|
nsBlockFrame::DeleteLine(nsBlockReflowState& aState,
|
|
|
|
nsLineList::iterator aLine,
|
|
|
|
nsLineList::iterator aLineEnd)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(0 == aLine->GetChildCount(), "can't delete !empty line");
|
|
|
|
if (0 == aLine->GetChildCount()) {
|
|
|
|
NS_ASSERTION(aState.mCurrentLine == aLine,
|
|
|
|
"using function more generally than designed, "
|
|
|
|
"but perhaps OK now");
|
2012-05-03 17:14:01 -07:00
|
|
|
nsLineBox* line = aLine;
|
2007-03-22 10:30:00 -07:00
|
|
|
aLine = mLines.erase(aLine);
|
2012-03-10 18:32:27 -08:00
|
|
|
FreeLineBox(line);
|
2007-03-22 10:30:00 -07:00
|
|
|
// Mark the previous margin of the next line dirty since we need to
|
|
|
|
// recompute its top position.
|
|
|
|
if (aLine != aLineEnd)
|
|
|
|
aLine->MarkPreviousMarginDirty();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reflow a line. The line will either contain a single block frame
|
|
|
|
* or contain 1 or more inline frames. aKeepReflowGoing indicates
|
|
|
|
* whether or not the caller should continue to reflow more lines.
|
|
|
|
*/
|
|
|
|
nsresult
|
|
|
|
nsBlockFrame::ReflowLine(nsBlockReflowState& aState,
|
|
|
|
line_iterator aLine,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool* aKeepReflowGoing)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
NS_ABORT_IF_FALSE(aLine->GetChildCount(), "reflowing empty line");
|
|
|
|
|
|
|
|
// Setup the line-layout for the new line
|
|
|
|
aState.mCurrentLine = aLine;
|
|
|
|
aLine->ClearDirty();
|
|
|
|
aLine->InvalidateCachedIsEmpty();
|
2010-08-05 21:59:20 -07:00
|
|
|
aLine->ClearHadFloatPushed();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Now that we know what kind of line we have, reflow it
|
|
|
|
if (aLine->IsBlock()) {
|
|
|
|
rv = ReflowBlockFrame(aState, aLine, aKeepReflowGoing);
|
2012-08-28 22:39:31 -07:00
|
|
|
} else {
|
2011-10-17 07:59:28 -07:00
|
|
|
aLine->SetLineWrapped(false);
|
2007-03-22 10:30:00 -07:00
|
|
|
rv = ReflowInlineFrames(aState, aLine, aKeepReflowGoing);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2010-01-11 06:08:23 -08:00
|
|
|
nsIFrame*
|
2007-03-22 10:30:00 -07:00
|
|
|
nsBlockFrame::PullFrame(nsBlockReflowState& aState,
|
2010-01-11 06:08:23 -08:00
|
|
|
line_iterator aLine)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-01-11 06:08:23 -08:00
|
|
|
// First check our remaining lines.
|
2007-03-22 10:30:00 -07:00
|
|
|
if (end_lines() != aLine.next()) {
|
2013-02-27 15:05:46 -08:00
|
|
|
return PullFrameFrom(aLine, this, aLine.next());
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_ASSERTION(!GetOverflowLines(),
|
|
|
|
"Our overflow lines should have been removed at the start of reflow");
|
|
|
|
|
2010-01-11 06:08:23 -08:00
|
|
|
// Try each next-in-flow.
|
2007-03-22 10:30:00 -07:00
|
|
|
nsBlockFrame* nextInFlow = aState.mNextInFlow;
|
|
|
|
while (nextInFlow) {
|
2013-02-27 15:05:45 -08:00
|
|
|
if (nextInFlow->mLines.empty()) {
|
|
|
|
nextInFlow->DrainSelfOverflowList();
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!nextInFlow->mLines.empty()) {
|
2013-02-27 15:05:46 -08:00
|
|
|
return PullFrameFrom(aLine, nextInFlow, nextInFlow->mLines.begin());
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2010-01-11 06:08:23 -08:00
|
|
|
nextInFlow = static_cast<nsBlockFrame*>(nextInFlow->GetNextInFlow());
|
2007-03-22 10:30:00 -07:00
|
|
|
aState.mNextInFlow = nextInFlow;
|
|
|
|
}
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-01-11 06:08:23 -08:00
|
|
|
nsIFrame*
|
2013-02-27 15:05:46 -08:00
|
|
|
nsBlockFrame::PullFrameFrom(nsLineBox* aLine,
|
2010-01-11 06:08:23 -08:00
|
|
|
nsBlockFrame* aFromContainer,
|
|
|
|
nsLineList::iterator aFromLine)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsLineBox* fromLine = aFromLine;
|
|
|
|
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");
|
|
|
|
|
2012-08-02 04:38:51 -07:00
|
|
|
NS_ASSERTION(fromLine->IsBlock() == fromLine->mFirstChild->IsBlockOutside(),
|
2007-03-22 10:30:00 -07:00
|
|
|
"Disagreement about whether it's a block or not");
|
|
|
|
|
|
|
|
if (fromLine->IsBlock()) {
|
|
|
|
// 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.
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2010-01-11 06:08:23 -08:00
|
|
|
// Take frame from fromLine
|
|
|
|
nsIFrame* frame = fromLine->mFirstChild;
|
|
|
|
nsIFrame* newFirstChild = frame->GetNextSibling();
|
|
|
|
|
|
|
|
if (aFromContainer != this) {
|
|
|
|
// The frame is being pulled from a next-in-flow; therefore we
|
|
|
|
// need to add it to our sibling list.
|
2013-02-27 15:05:46 -08:00
|
|
|
MOZ_ASSERT(aLine == mLines.back());
|
2013-02-27 15:05:45 -08:00
|
|
|
MOZ_ASSERT(aFromLine == aFromContainer->mLines.begin(),
|
|
|
|
"should only pull from first line");
|
|
|
|
aFromContainer->mFrames.RemoveFrame(frame);
|
2009-09-29 12:47:05 -07:00
|
|
|
|
2010-01-11 06:08:23 -08:00
|
|
|
// When pushing and pulling frames we need to check for whether any
|
2013-02-27 15:05:45 -08:00
|
|
|
// views need to be reparented.
|
2010-01-11 06:08:23 -08:00
|
|
|
ReparentFrame(frame, aFromContainer, this);
|
2013-02-27 15:05:46 -08:00
|
|
|
mFrames.AppendFrame(nullptr, frame);
|
2009-09-29 12:47:05 -07:00
|
|
|
|
2013-02-27 15:05:46 -08:00
|
|
|
// The frame might have (or contain) floats that need to be brought
|
|
|
|
// over too. (pass 'false' since there are no siblings to check)
|
|
|
|
ReparentFloats(frame, aFromContainer, false);
|
2013-02-27 15:05:46 -08:00
|
|
|
} else {
|
|
|
|
MOZ_ASSERT(aLine == aFromLine.prev());
|
2010-01-11 06:08:23 -08:00
|
|
|
}
|
2013-02-27 15:05:46 -08:00
|
|
|
|
2012-03-10 18:32:27 -08:00
|
|
|
aLine->NoteFrameAdded(frame);
|
2013-01-05 18:04:59 -08:00
|
|
|
fromLine->NoteFrameRemoved(frame);
|
2012-03-10 18:32:27 -08:00
|
|
|
|
2013-01-05 18:04:59 -08:00
|
|
|
if (fromLine->GetChildCount() > 0) {
|
2010-01-11 06:08:23 -08:00
|
|
|
// Mark line dirty now that we pulled a child
|
|
|
|
fromLine->MarkDirty();
|
|
|
|
fromLine->mFirstChild = newFirstChild;
|
2012-03-10 18:32:27 -08:00
|
|
|
} else {
|
2013-02-27 15:05:45 -08:00
|
|
|
// Free up the fromLine now that it's empty.
|
2010-01-11 06:08:23 -08:00
|
|
|
// Its bounds might need to be redrawn, though.
|
2013-02-27 15:05:45 -08:00
|
|
|
if (aFromLine.next() != aFromContainer->mLines.end()) {
|
2010-01-11 06:08:23 -08:00
|
|
|
aFromLine.next()->MarkPreviousMarginDirty();
|
2013-02-27 15:05:45 -08:00
|
|
|
}
|
2013-02-27 15:05:45 -08:00
|
|
|
aFromContainer->mLines.erase(aFromLine);
|
2010-01-11 06:08:23 -08:00
|
|
|
// aFromLine is now invalid
|
2012-05-03 17:14:01 -07:00
|
|
|
aFromContainer->FreeLineBox(fromLine);
|
2010-01-11 06:08:23 -08:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2011-10-17 07:59:28 -07:00
|
|
|
VerifyLines(true);
|
2012-05-03 17:14:01 -07:00
|
|
|
VerifyOverflowSituation();
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
2010-01-11 06:08:23 -08:00
|
|
|
|
|
|
|
return frame;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBlockFrame::SlideLine(nsBlockReflowState& aState,
|
|
|
|
nsLineBox* aLine, nscoord aDY)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(aDY != 0, "why slide a line nowhere?");
|
|
|
|
|
|
|
|
// Adjust line state
|
|
|
|
aLine->SlideBy(aDY);
|
|
|
|
|
|
|
|
// Adjust the frames in the line
|
|
|
|
nsIFrame* kid = aLine->mFirstChild;
|
|
|
|
if (!kid) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aLine->IsBlock()) {
|
|
|
|
if (aDY) {
|
2013-09-11 11:51:42 -07:00
|
|
|
kid->MovePositionBy(nsPoint(0, aDY));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure the frame's view and any child views are updated
|
2013-11-15 05:19:02 -08:00
|
|
|
nsContainerFrame::PlaceFrameView(kid);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// 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
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t n = aLine->GetChildCount();
|
2007-03-22 10:30:00 -07:00
|
|
|
while (--n >= 0) {
|
|
|
|
if (aDY) {
|
2013-09-11 11:51:42 -07:00
|
|
|
kid->MovePositionBy(nsPoint(0, aDY));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
// Make sure the frame's view and any child views are updated
|
2013-11-15 05:19:02 -08:00
|
|
|
nsContainerFrame::PlaceFrameView(kid);
|
2007-03-22 10:30:00 -07:00
|
|
|
kid = kid->GetNextSibling();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-17 23:47:48 -08:00
|
|
|
nsresult
|
2012-08-22 08:56:38 -07:00
|
|
|
nsBlockFrame::AttributeChanged(int32_t aNameSpaceID,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIAtom* aAttribute,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aModType)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsresult rv = nsBlockFrameSuper::AttributeChanged(aNameSpaceID,
|
|
|
|
aAttribute, aModType);
|
|
|
|
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
2012-09-07 19:30:24 -07:00
|
|
|
if (nsGkAtoms::start == aAttribute ||
|
|
|
|
(nsGkAtoms::reversed == aAttribute && mContent->IsHTML(nsGkAtoms::ol))) {
|
2007-03-30 14:11:41 -07:00
|
|
|
nsPresContext* presContext = PresContext();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// XXX Not sure if this is necessary anymore
|
2007-05-06 12:16:51 -07:00
|
|
|
if (RenumberLists(presContext)) {
|
|
|
|
presContext->PresShell()->
|
|
|
|
FrameNeedsReflow(this, nsIPresShell::eStyleChange,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
else if (nsGkAtoms::value == aAttribute) {
|
2013-02-16 13:51:02 -08:00
|
|
|
const nsStyleDisplay* styleDisplay = StyleDisplay();
|
2007-03-22 10:30:00 -07: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.
|
|
|
|
// XXXldb I think that's a bad assumption.
|
|
|
|
nsBlockFrame* blockParent = nsLayoutUtils::FindNearestBlockAncestor(this);
|
|
|
|
|
|
|
|
// Tell the enclosing block frame to renumber list items within
|
|
|
|
// itself
|
2012-07-30 07:20:58 -07:00
|
|
|
if (nullptr != blockParent) {
|
2007-03-30 14:11:41 -07:00
|
|
|
nsPresContext* presContext = PresContext();
|
2007-03-22 10:30:00 -07:00
|
|
|
// XXX Not sure if this is necessary anymore
|
2007-05-06 12:16:51 -07:00
|
|
|
if (blockParent->RenumberLists(presContext)) {
|
|
|
|
presContext->PresShell()->
|
|
|
|
FrameNeedsReflow(blockParent, nsIPresShell::eStyleChange,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
static inline bool
|
2010-08-25 03:17:55 -07:00
|
|
|
IsNonAutoNonZeroHeight(const nsStyleCoord& aCoord)
|
|
|
|
{
|
|
|
|
if (aCoord.GetUnit() == eStyleUnit_Auto)
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2010-08-25 03:17:55 -07:00
|
|
|
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;
|
|
|
|
}
|
2011-10-17 07:59:28 -07:00
|
|
|
NS_ABORT_IF_FALSE(false, "unexpected unit for height or min-height");
|
|
|
|
return true;
|
2010-08-25 03:17:55 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
/* virtual */ bool
|
2007-03-22 10:30:00 -07:00
|
|
|
nsBlockFrame::IsSelfEmpty()
|
|
|
|
{
|
2007-11-07 19:55:12 -08: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)
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2007-11-07 19:55:12 -08:00
|
|
|
|
2013-02-16 13:51:02 -08:00
|
|
|
const nsStylePosition* position = StylePosition();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-08-25 03:17:55 -07:00
|
|
|
if (IsNonAutoNonZeroHeight(position->mMinHeight) ||
|
|
|
|
IsNonAutoNonZeroHeight(position->mHeight))
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-02-16 13:51:02 -08:00
|
|
|
const nsStyleBorder* border = StyleBorder();
|
|
|
|
const nsStylePadding* padding = StylePadding();
|
2012-05-30 22:19:49 -07:00
|
|
|
if (border->GetComputedBorderWidth(NS_SIDE_TOP) != 0 ||
|
|
|
|
border->GetComputedBorderWidth(NS_SIDE_BOTTOM) != 0 ||
|
2010-08-31 09:05:12 -07:00
|
|
|
!nsLayoutUtils::IsPaddingZero(padding->mPadding.GetTop()) ||
|
|
|
|
!nsLayoutUtils::IsPaddingZero(padding->mPadding.GetBottom())) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-03-07 17:57:37 -08:00
|
|
|
if (HasOutsideBullet() && !BulletIsEmpty()) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2009-08-10 19:48:42 -07:00
|
|
|
}
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2007-03-22 10:30:00 -07:00
|
|
|
nsBlockFrame::CachedIsEmpty()
|
|
|
|
{
|
|
|
|
if (!IsSelfEmpty()) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
for (line_iterator line = begin_lines(), line_end = end_lines();
|
|
|
|
line != line_end;
|
|
|
|
++line)
|
|
|
|
{
|
|
|
|
if (!line->CachedIsEmpty())
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2007-03-22 10:30:00 -07:00
|
|
|
nsBlockFrame::IsEmpty()
|
|
|
|
{
|
|
|
|
if (!IsSelfEmpty()) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
for (line_iterator line = begin_lines(), line_end = end_lines();
|
|
|
|
line != line_end;
|
|
|
|
++line)
|
|
|
|
{
|
|
|
|
if (!line->IsEmpty())
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2007-03-22 10:30:00 -07:00
|
|
|
nsBlockFrame::ShouldApplyTopMargin(nsBlockReflowState& aState,
|
|
|
|
nsLineBox* aLine)
|
|
|
|
{
|
|
|
|
if (aState.GetFlag(BRS_APPLYTOPMARGIN)) {
|
|
|
|
// Apply short-circuit check to avoid searching the line list
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
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.
|
2011-10-17 07:59:28 -07:00
|
|
|
aState.SetFlag(BRS_APPLYTOPMARGIN, true);
|
|
|
|
return true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Determine if this line is "essentially" the first line
|
|
|
|
line_iterator line = begin_lines();
|
|
|
|
if (aState.GetFlag(BRS_HAVELINEADJACENTTOTOP)) {
|
|
|
|
line = aState.mLineAdjacentToTop;
|
|
|
|
}
|
|
|
|
while (line != aLine) {
|
|
|
|
if (!line->CachedIsEmpty() || line->HasClearance()) {
|
|
|
|
// A line which precedes aLine is non-empty, or has clearance,
|
|
|
|
// so therefore the top margin applies.
|
2011-10-17 07:59:28 -07:00
|
|
|
aState.SetFlag(BRS_APPLYTOPMARGIN, true);
|
|
|
|
return true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
// No need to apply the top margin if the line has floats. We
|
|
|
|
// should collapse anyway (bug 44419)
|
|
|
|
++line;
|
2011-10-17 07:59:28 -07:00
|
|
|
aState.SetFlag(BRS_HAVELINEADJACENTTOTOP, true);
|
2007-03-22 10:30:00 -07:00
|
|
|
aState.mLineAdjacentToTop = line;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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).
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsBlockFrame::ReflowBlockFrame(nsBlockReflowState& aState,
|
|
|
|
line_iterator aLine,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool* aKeepReflowGoing)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(*aKeepReflowGoing, "bad caller");
|
|
|
|
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
nsIFrame* frame = aLine->mFirstChild;
|
|
|
|
if (!frame) {
|
2011-10-17 07:59:28 -07:00
|
|
|
NS_ASSERTION(false, "program error - unexpected empty line");
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Prepare the block reflow engine
|
2013-02-16 13:51:02 -08:00
|
|
|
const nsStyleDisplay* display = frame->StyleDisplay();
|
2007-03-22 10:30:00 -07:00
|
|
|
nsBlockReflowContext brc(aState.mPresContext, aState.mReflowState);
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t breakType = display->mBreakType;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (NS_STYLE_CLEAR_NONE != aState.mFloatBreakType) {
|
|
|
|
breakType = nsLayoutUtils::CombineBreakType(breakType,
|
|
|
|
aState.mFloatBreakType);
|
|
|
|
aState.mFloatBreakType = NS_STYLE_CLEAR_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Clear past floats before the block if the clear style is not none
|
|
|
|
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
|
|
|
|
// apply its top margin because it's not significant. Otherwise, dig
|
|
|
|
// deeper.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool applyTopMargin =
|
2007-03-22 10:30:00 -07:00
|
|
|
!frame->GetPrevInFlow() && ShouldApplyTopMargin(aState, aLine);
|
|
|
|
|
|
|
|
if (applyTopMargin) {
|
|
|
|
// The HasClearance setting is only valid if ShouldApplyTopMargin
|
2011-10-17 07:59:28 -07:00
|
|
|
// returned false (in which case the top-margin-root set our
|
2007-03-22 10:30:00 -07:00
|
|
|
// clearance flag). Otherwise clear it now. We'll set it later on
|
|
|
|
// ourselves if necessary.
|
|
|
|
aLine->ClearHasClearance();
|
|
|
|
}
|
2011-09-28 23:19:26 -07:00
|
|
|
bool treatWithClearance = aLine->HasClearance();
|
2008-01-28 23:40:05 -08:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mightClearFloats = breakType != NS_STYLE_CLEAR_NONE;
|
2012-07-30 07:20:58 -07:00
|
|
|
nsIFrame *replacedBlock = nullptr;
|
2008-01-28 23:40:05 -08:00
|
|
|
if (!nsBlockFrame::BlockCanIntersectFloats(frame)) {
|
2011-10-17 07:59:28 -07:00
|
|
|
mightClearFloats = true;
|
2008-05-03 16:33:36 -07:00
|
|
|
replacedBlock = frame;
|
2008-01-28 23:40:05 -08:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07: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-28 23:40:05 -08:00
|
|
|
if (!treatWithClearance && !applyTopMargin && mightClearFloats &&
|
2007-03-22 10:30:00 -07:00
|
|
|
aState.mReflowState.mDiscoveredClearance) {
|
|
|
|
nscoord curY = aState.mY + aState.mPrevBottomMargin.get();
|
2008-05-03 16:33:36 -07:00
|
|
|
nscoord clearY = aState.ClearFloats(curY, breakType, replacedBlock);
|
2007-03-22 10:30:00 -07: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.
|
2011-10-17 07:59:28 -07:00
|
|
|
treatWithClearance = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
// Only record the first frame that requires clearance
|
|
|
|
if (!*aState.mReflowState.mDiscoveredClearance) {
|
|
|
|
*aState.mReflowState.mDiscoveredClearance = frame;
|
|
|
|
}
|
2009-10-15 19:41:58 -07:00
|
|
|
aState.mPrevChild = frame;
|
2007-03-22 10:30:00 -07:00
|
|
|
// Exactly what we do now is flexible since we'll definitely be
|
|
|
|
// reflowed.
|
2007-11-29 17:49:01 -08:00
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (treatWithClearance) {
|
2011-10-17 07:59:28 -07:00
|
|
|
applyTopMargin = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
nsIFrame* clearanceFrame = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
nscoord startingY = aState.mY;
|
|
|
|
nsCollapsingMargin incomingMargin = aState.mPrevBottomMargin;
|
|
|
|
nscoord clearance;
|
2007-04-05 15:47:38 -07:00
|
|
|
// Save the original position of the frame so that we can reposition
|
|
|
|
// its view as needed.
|
|
|
|
nsPoint originalPosition = frame->GetPosition();
|
2011-10-17 07:59:28 -07:00
|
|
|
while (true) {
|
2007-03-22 10:30:00 -07:00
|
|
|
clearance = 0;
|
|
|
|
nscoord topMargin = 0;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mayNeedRetry = false;
|
|
|
|
bool clearedFloats = false;
|
2007-03-22 10:30:00 -07: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,
|
|
|
|
frame, availSpace);
|
|
|
|
|
|
|
|
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.
|
2011-10-17 07:59:28 -07:00
|
|
|
mayNeedRetry = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2008-01-28 23:40:05 -08:00
|
|
|
if (!treatWithClearance && !clearanceFrame && mightClearFloats) {
|
2007-03-22 10:30:00 -07: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 16:33:36 -07:00
|
|
|
nscoord clearY = aState.ClearFloats(curY, breakType, replacedBlock);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (clearY != curY) {
|
|
|
|
// Looks like we need clearance and we didn't know about it already. So
|
|
|
|
// recompute collapsed margin
|
2011-10-17 07:59:28 -07:00
|
|
|
treatWithClearance = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
// 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
|
2011-10-17 07:59:28 -07:00
|
|
|
mayNeedRetry = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
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 16:33:36 -07:00
|
|
|
aState.mY = aState.ClearFloats(aState.mY, breakType, replacedBlock);
|
2011-04-28 10:21:36 -07:00
|
|
|
|
|
|
|
clearedFloats = aState.mY != currentY;
|
|
|
|
|
2007-03-22 10:30:00 -07: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 13:52:37 -07:00
|
|
|
nsFlowAreaRect floatAvailableSpace = aState.GetFloatAvailableSpace();
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef REALLY_NOISY_REFLOW
|
2009-04-08 13:52:37 -07:00
|
|
|
printf("setting line %p isImpacted to %s\n",
|
2009-04-08 13:52:37 -07:00
|
|
|
aLine.get(), floatAvailableSpace.mHasFloats?"true":"false");
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
2009-04-08 13:52:37 -07:00
|
|
|
aLine->SetLineIsImpactedByFloat(floatAvailableSpace.mHasFloats);
|
2007-03-22 10:30:00 -07:00
|
|
|
nsRect availSpace;
|
2009-04-08 13:52:37 -07:00
|
|
|
aState.ComputeBlockAvailSpace(frame, display, floatAvailableSpace,
|
2012-07-30 07:20:58 -07:00
|
|
|
replacedBlock != nullptr, availSpace);
|
2011-04-28 10:21:36 -07: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;
|
2011-10-17 07:59:28 -07:00
|
|
|
*aKeepReflowGoing = false;
|
2012-11-08 08:09:38 -08:00
|
|
|
if (ShouldAvoidBreakInside(aState.mReflowState)) {
|
|
|
|
aState.mReflowStatus = NS_INLINE_LINE_BREAK_BEFORE();
|
|
|
|
} else {
|
|
|
|
PushLines(aState, aLine.prev());
|
|
|
|
NS_FRAME_SET_INCOMPLETE(aState.mReflowStatus);
|
|
|
|
}
|
2011-04-28 10:21:36 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Now put the Y coordinate back to the top of the top-margin +
|
|
|
|
// clearance, and flow the block.
|
|
|
|
aState.mY -= topMargin;
|
|
|
|
availSpace.y -= topMargin;
|
|
|
|
if (NS_UNCONSTRAINEDSIZE != availSpace.height) {
|
|
|
|
availSpace.height += topMargin;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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,
|
2013-08-14 05:27:20 -07:00
|
|
|
availSpace.Size());
|
2007-03-22 10:30:00 -07:00
|
|
|
blockHtmlRS.mFlags.mHasClearance = aLine->HasClearance();
|
|
|
|
|
2009-01-04 16:39:54 -08:00
|
|
|
nsFloatManager::SavedState floatManagerState;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (mayNeedRetry) {
|
|
|
|
blockHtmlRS.mDiscoveredClearance = &clearanceFrame;
|
2009-01-04 16:39:54 -08:00
|
|
|
aState.mFloatManager->PushState(&floatManagerState);
|
2007-03-22 10:30:00 -07:00
|
|
|
} else if (!applyTopMargin) {
|
|
|
|
blockHtmlRS.mDiscoveredClearance = aState.mReflowState.mDiscoveredClearance;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsReflowStatus frameReflowStatus = NS_FRAME_COMPLETE;
|
|
|
|
rv = brc.ReflowBlock(availSpace, applyTopMargin, aState.mPrevBottomMargin,
|
2008-04-18 00:40:35 -07:00
|
|
|
clearance, aState.IsAdjacentWithTop(),
|
2007-10-01 22:57:45 -07:00
|
|
|
aLine.get(), blockHtmlRS, frameReflowStatus, aState);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
if (mayNeedRetry && clearanceFrame) {
|
2009-01-04 16:39:54 -08:00
|
|
|
aState.mFloatManager->PopState(&floatManagerState);
|
2007-03-22 10:30:00 -07:00
|
|
|
aState.mY = startingY;
|
|
|
|
aState.mPrevBottomMargin = incomingMargin;
|
|
|
|
continue;
|
|
|
|
}
|
2009-02-09 20:36:54 -08:00
|
|
|
|
2009-09-02 08:33:15 -07:00
|
|
|
aState.mPrevChild = frame;
|
|
|
|
|
2009-02-09 20:36:54 -08: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 08:33:15 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#if defined(REFLOW_STATUS_COVERAGE)
|
2011-10-17 07:59:28 -07:00
|
|
|
RecordReflowStatus(true, frameReflowStatus);
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if (NS_INLINE_IS_BREAK_BEFORE(frameReflowStatus)) {
|
|
|
|
// None of the child block fits.
|
2011-10-17 07:59:28 -07:00
|
|
|
*aKeepReflowGoing = false;
|
2012-11-08 08:09:38 -08:00
|
|
|
if (ShouldAvoidBreakInside(aState.mReflowState)) {
|
|
|
|
aState.mReflowStatus = NS_INLINE_LINE_BREAK_BEFORE();
|
|
|
|
} else {
|
|
|
|
PushLines(aState, aLine.prev());
|
|
|
|
NS_FRAME_SET_INCOMPLETE(aState.mReflowStatus);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Note: line-break-after a block is a nop
|
|
|
|
|
|
|
|
// 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.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool forceFit = aState.IsAdjacentWithTop() && clearance <= 0 &&
|
2009-04-08 13:52:37 -07:00
|
|
|
!floatAvailableSpace.mHasFloats;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCollapsingMargin collapsedBottomMargin;
|
2010-10-06 21:25:45 -07:00
|
|
|
nsOverflowAreas overflowAreas;
|
2007-03-22 10:30:00 -07:00
|
|
|
*aKeepReflowGoing = brc.PlaceBlock(blockHtmlRS, forceFit, aLine.get(),
|
2008-04-18 00:40:35 -07:00
|
|
|
collapsedBottomMargin,
|
2010-10-06 21:25:45 -07:00
|
|
|
aLine->mBounds, overflowAreas,
|
|
|
|
frameReflowStatus);
|
2012-11-08 08:09:38 -08:00
|
|
|
if (!NS_FRAME_IS_FULLY_COMPLETE(frameReflowStatus) &&
|
|
|
|
ShouldAvoidBreakInside(aState.mReflowState)) {
|
|
|
|
*aKeepReflowGoing = false;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (aLine->SetCarriedOutBottomMargin(collapsedBottomMargin)) {
|
|
|
|
line_iterator nextLine = aLine;
|
|
|
|
++nextLine;
|
|
|
|
if (nextLine != end_lines()) {
|
|
|
|
nextLine->MarkPreviousMarginDirty();
|
|
|
|
}
|
|
|
|
}
|
2010-10-06 21:25:45 -07:00
|
|
|
|
|
|
|
aLine->SetOverflowAreas(overflowAreas);
|
2007-03-22 10:30:00 -07: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-25 21:03:29 -07:00
|
|
|
if (!NS_FRAME_IS_FULLY_COMPLETE(frameReflowStatus)) {
|
2013-06-18 23:09:20 -07:00
|
|
|
bool madeContinuation =
|
|
|
|
CreateContinuationFor(aState, nullptr, frame);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsIFrame* nextFrame = frame->GetNextInFlow();
|
2007-07-25 21:03:29 -07:00
|
|
|
NS_ASSERTION(nextFrame, "We're supposed to have a next-in-flow by now");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-07-25 21:03:29 -07: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())) {
|
2013-06-10 11:31:59 -07:00
|
|
|
nsOverflowContinuationTracker::AutoFinish fini(aState.mOverflowTracker, frame);
|
2007-07-25 21:03:29 -07:00
|
|
|
nsContainerFrame* parent =
|
|
|
|
static_cast<nsContainerFrame*>(nextFrame->GetParent());
|
2014-02-06 14:07:47 -08:00
|
|
|
rv = parent->StealFrame(nextFrame);
|
2007-07-25 21:03:29 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2007-10-10 15:09:53 -07:00
|
|
|
if (parent != this)
|
|
|
|
ReparentFrame(nextFrame, parent, this);
|
2012-07-30 07:20:58 -07:00
|
|
|
mFrames.InsertFrame(nullptr, frame, nextFrame);
|
2011-10-17 07:59:28 -07:00
|
|
|
madeContinuation = true; // needs to be added to mLines
|
2007-07-25 21:03:29 -07:00
|
|
|
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) {
|
2012-03-10 18:32:27 -08:00
|
|
|
nsLineBox* line = NewLineBox(nextFrame, true);
|
2007-07-25 21:03:29 -07:00
|
|
|
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-20 19:28:18 -08:00
|
|
|
nsBlockFrame* nifBlock =
|
|
|
|
nsLayoutUtils::GetAsBlock(nextFrame->GetParent());
|
|
|
|
NS_ASSERTION(nifBlock,
|
2007-07-25 21:03:29 -07:00
|
|
|
"A block's child's next in flow's parent must be a block!");
|
|
|
|
for (line_iterator line = nifBlock->begin_lines(),
|
2007-03-22 10:30:00 -07:00
|
|
|
line_end = nifBlock->end_lines(); line != line_end; ++line) {
|
2007-07-25 21:03:29 -07:00
|
|
|
if (line->Contains(nextFrame)) {
|
|
|
|
line->MarkDirty();
|
|
|
|
break;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-10-17 07:59:28 -07:00
|
|
|
*aKeepReflowGoing = false;
|
2007-07-25 21:03:29 -07:00
|
|
|
|
|
|
|
// 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();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2007-07-25 21:03:29 -07: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());
|
2014-02-06 14:07:47 -08:00
|
|
|
rv = parent->StealFrame(nextFrame);
|
2007-07-25 21:03:29 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
|
|
|
else if (madeContinuation) {
|
2009-10-02 09:27:37 -07:00
|
|
|
mFrames.RemoveFrame(nextFrame);
|
2007-07-25 21:03:29 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Put it in our overflow list
|
2009-09-13 17:26:01 -07:00
|
|
|
aState.mOverflowTracker->Insert(nextFrame, frameReflowStatus);
|
2008-05-28 06:39:41 -07:00
|
|
|
NS_MergeReflowStatusInto(&aState.mReflowStatus, frameReflowStatus);
|
2007-07-25 21:03:29 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef NOISY_VERTICAL_MARGINS
|
2007-07-25 21:03:29 -07:00
|
|
|
ListTag(stdout);
|
|
|
|
printf(": reflow complete but overflow incomplete for ");
|
|
|
|
nsFrame::ListTag(stdout, frame);
|
|
|
|
printf(" prevBottomMargin=%d collapsedBottomMargin=%d\n",
|
|
|
|
aState.mPrevBottomMargin, collapsedBottomMargin.get());
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
2007-07-25 21:03:29 -07:00
|
|
|
aState.mPrevBottomMargin = collapsedBottomMargin;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2007-07-25 21:03:29 -07:00
|
|
|
else { // frame is fully complete
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef NOISY_VERTICAL_MARGINS
|
|
|
|
ListTag(stdout);
|
|
|
|
printf(": reflow complete for ");
|
|
|
|
nsFrame::ListTag(stdout, frame);
|
|
|
|
printf(" prevBottomMargin=%d collapsedBottomMargin=%d\n",
|
|
|
|
aState.mPrevBottomMargin, collapsedBottomMargin.get());
|
|
|
|
#endif
|
|
|
|
aState.mPrevBottomMargin = collapsedBottomMargin;
|
|
|
|
}
|
|
|
|
#ifdef NOISY_VERTICAL_MARGINS
|
|
|
|
ListTag(stdout);
|
|
|
|
printf(": frame=");
|
|
|
|
nsFrame::ListTag(stdout, frame);
|
|
|
|
printf(" carriedOutBottomMargin=%d collapsedBottomMargin=%d => %d\n",
|
|
|
|
brc.GetCarriedOutBottomMargin(), collapsedBottomMargin.get(),
|
|
|
|
aState.mPrevBottomMargin);
|
|
|
|
#endif
|
2012-11-08 08:09:38 -08:00
|
|
|
} else {
|
|
|
|
if ((aLine == mLines.front() && !GetPrevInFlow()) ||
|
|
|
|
ShouldAvoidBreakInside(aState.mReflowState)) {
|
|
|
|
// If it's our very first line *or* we're not at the top of the page
|
|
|
|
// and we have page-break-inside:avoid, then we need to be pushed to
|
|
|
|
// our parent's next-in-flow.
|
2007-03-22 10:30:00 -07:00
|
|
|
aState.mReflowStatus = NS_INLINE_LINE_BREAK_BEFORE();
|
2012-11-08 08:09:38 -08:00
|
|
|
} else {
|
2007-03-22 10:30:00 -07:00
|
|
|
// Push the line that didn't fit and any lines that follow it
|
|
|
|
// to our next-in-flow.
|
|
|
|
PushLines(aState, aLine.prev());
|
2007-07-25 21:03:29 -07:00
|
|
|
NS_FRAME_SET_INCOMPLETE(aState.mReflowStatus);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break; // out of the reflow retry loop
|
|
|
|
}
|
2007-04-05 15:47:38 -07: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);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2011-10-17 07:59:28 -07:00
|
|
|
VerifyLines(true);
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsBlockFrame::ReflowInlineFrames(nsBlockReflowState& aState,
|
|
|
|
line_iterator aLine,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool* aKeepReflowGoing)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
2011-10-17 07:59:28 -07:00
|
|
|
*aKeepReflowGoing = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
aLine->SetLineIsImpactedByFloat(false);
|
2009-05-20 04:21:34 -07:00
|
|
|
|
|
|
|
// 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-05 21:59:19 -07:00
|
|
|
LineReflowStatus lineReflowStatus;
|
2007-03-22 10:30:00 -07:00
|
|
|
do {
|
2009-06-16 08:00:20 -07:00
|
|
|
nscoord availableSpaceHeight = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
do {
|
2011-09-28 23:19:26 -07:00
|
|
|
bool allowPullUp = true;
|
2012-07-30 07:20:58 -07:00
|
|
|
nsIContent* forceBreakInContent = nullptr;
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t forceBreakOffset = -1;
|
2014-01-23 10:26:39 -08:00
|
|
|
gfxBreakPriority forceBreakPriority = gfxBreakPriority::eNoBreak;
|
2009-06-16 08:00:20 -07:00
|
|
|
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);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2009-06-16 08:00:20 -07: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 {
|
2012-07-30 07:20:58 -07:00
|
|
|
forceBreakInContent = nullptr;
|
2009-06-16 08:00:20 -07:00
|
|
|
}
|
|
|
|
// restore the float manager state
|
|
|
|
aState.mReflowState.mFloatManager->PopState(&floatManagerState);
|
|
|
|
// Clear out float lists
|
|
|
|
aState.mCurrentLineFloats.DeleteAll();
|
|
|
|
aState.mBelowCurrentLineFloats.DeleteAll();
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-06-16 08:00:20 -07:00
|
|
|
// Don't allow pullup on a subsequent LINE_REFLOW_REDO_NO_PULL pass
|
2011-10-17 07:59:28 -07:00
|
|
|
allowPullUp = false;
|
2009-06-16 08:00:20 -07:00
|
|
|
} while (LINE_REFLOW_REDO_NO_PULL == lineReflowStatus);
|
|
|
|
} while (LINE_REFLOW_REDO_MORE_FLOATS == lineReflowStatus);
|
|
|
|
} while (LINE_REFLOW_REDO_NEXT_BAND == lineReflowStatus);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-08-05 21:59:20 -07:00
|
|
|
nsBlockFrame::PushTruncatedLine(nsBlockReflowState& aState,
|
|
|
|
line_iterator aLine,
|
2012-11-08 08:09:38 -08:00
|
|
|
bool* aKeepReflowGoing)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-11-08 08:09:38 -08:00
|
|
|
PushLines(aState, aLine.prev());
|
|
|
|
*aKeepReflowGoing = false;
|
2007-07-25 21:03:29 -07:00
|
|
|
NS_FRAME_SET_INCOMPLETE(aState.mReflowStatus);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
static const char* LineReflowStatusNames[] = {
|
|
|
|
"LINE_REFLOW_OK", "LINE_REFLOW_STOP", "LINE_REFLOW_REDO_NO_PULL",
|
2009-05-20 04:21:34 -07:00
|
|
|
"LINE_REFLOW_REDO_MORE_FLOATS",
|
2007-03-22 10:30:00 -07:00
|
|
|
"LINE_REFLOW_REDO_NEXT_BAND", "LINE_REFLOW_TRUNCATED"
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsBlockFrame::DoReflowInlineFrames(nsBlockReflowState& aState,
|
|
|
|
nsLineLayout& aLineLayout,
|
|
|
|
line_iterator aLine,
|
2009-05-20 04:21:34 -07:00
|
|
|
nsFlowAreaRect& aFloatAvailableSpace,
|
2009-06-16 08:00:20 -07:00
|
|
|
nscoord& aAvailableSpaceHeight,
|
2009-05-20 04:21:34 -07:00
|
|
|
nsFloatManager::SavedState*
|
|
|
|
aFloatStateBeforeLine,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool* aKeepReflowGoing,
|
2007-03-22 10:30:00 -07:00
|
|
|
LineReflowStatus* aLineReflowStatus,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aAllowPullUp)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
// Forget all of the floats on the line
|
|
|
|
aLine->FreeFloats(aState.mFloatCacheFreeList);
|
2010-10-06 21:25:45 -07:00
|
|
|
aState.mFloatOverflowAreas.Clear();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-05-20 04:21:34 -07:00
|
|
|
// We need to set this flag on the line if any of our reflow passes
|
|
|
|
// are impacted by floats.
|
|
|
|
if (aFloatAvailableSpace.mHasFloats)
|
2011-10-17 07:59:28 -07:00
|
|
|
aLine->SetLineIsImpactedByFloat(true);
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef REALLY_NOISY_REFLOW
|
|
|
|
printf("nsBlockFrame::DoReflowInlineFrames %p impacted = %d\n",
|
2009-05-20 04:21:34 -07:00
|
|
|
this, aFloatAvailableSpace.mHasFloats);
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
2014-03-11 13:23:50 -07:00
|
|
|
WritingMode wm = GetWritingMode(aLine->mFirstChild);
|
|
|
|
nscoord lineWidth = aFloatAvailableSpace.mRect.width +
|
|
|
|
aState.BorderPadding().LeftRight();
|
|
|
|
LogicalRect lineRect(wm, aFloatAvailableSpace.mRect, lineWidth);
|
|
|
|
|
|
|
|
nscoord iStart = lineRect.IStart(wm);
|
|
|
|
|
|
|
|
nscoord availISize = lineRect.ISize(wm);
|
|
|
|
nscoord availBSize;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (aState.GetFlag(BRS_UNCONSTRAINEDHEIGHT)) {
|
2014-03-11 13:23:50 -07:00
|
|
|
availBSize = NS_UNCONSTRAINEDSIZE;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* XXX get the height right! */
|
2014-03-11 13:23:50 -07:00
|
|
|
availBSize = lineRect.BSize(wm);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2007-05-21 02:55:27 -07:00
|
|
|
|
|
|
|
// Make sure to enable resize optimization before we call BeginLineReflow
|
|
|
|
// because it might get disabled there
|
|
|
|
aLine->EnableResizeReflowOptimization();
|
|
|
|
|
2014-03-11 13:23:50 -07:00
|
|
|
aLineLayout.BeginLineReflow(iStart, aState.mY,
|
|
|
|
availISize, availBSize,
|
2009-05-20 04:21:34 -07:00
|
|
|
aFloatAvailableSpace.mHasFloats,
|
2011-10-18 05:51:58 -07:00
|
|
|
false, /*XXX isTopOfPage*/
|
2014-03-11 13:23:50 -07:00
|
|
|
wm, lineWidth);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
aState.SetFlag(BRS_LINE_LAYOUT_EMPTY, false);
|
2008-11-27 10:44:47 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// XXX Unfortunately we need to know this before reflowing the first
|
|
|
|
// inline frame in the line. FIX ME.
|
|
|
|
if ((0 == aLineLayout.GetLineNumber()) &&
|
2007-12-05 00:15:15 -08:00
|
|
|
(NS_BLOCK_HAS_FIRST_LETTER_CHILD & mState) &&
|
2007-03-22 10:30:00 -07:00
|
|
|
(NS_BLOCK_HAS_FIRST_LETTER_STYLE & mState)) {
|
2011-10-17 07:59:28 -07:00
|
|
|
aLineLayout.SetFirstLetterStyleOK(true);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2009-12-22 15:44:35 -08:00
|
|
|
NS_ASSERTION(!((NS_BLOCK_HAS_FIRST_LETTER_CHILD & mState) &&
|
|
|
|
GetPrevContinuation()),
|
|
|
|
"first letter child bit should only be on first continuation");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Reflow the frames that are already on the line first
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
LineReflowStatus lineReflowStatus = LINE_REFLOW_OK;
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t i;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIFrame* frame = aLine->mFirstChild;
|
|
|
|
|
2009-05-20 04:21:34 -07:00
|
|
|
if (aFloatAvailableSpace.mHasFloats) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// There is a soft break opportunity at the start of the line, because
|
|
|
|
// we can always move this line down below float(s).
|
2014-01-23 10:26:39 -08:00
|
|
|
if (aLineLayout.NotifyOptionalBreakPosition(frame->GetContent(), 0, true, gfxBreakPriority::eNormalBreak)) {
|
2007-03-22 10:30:00 -07:00
|
|
|
lineReflowStatus = LINE_REFLOW_REDO_NEXT_BAND;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// need to repeatedly call GetChildCount here, because the child
|
|
|
|
// count can change during the loop!
|
|
|
|
for (i = 0; LINE_REFLOW_OK == lineReflowStatus && i < aLine->GetChildCount();
|
|
|
|
i++, frame = frame->GetNextSibling()) {
|
|
|
|
rv = ReflowInlineFrame(aState, aLineLayout, aLine, frame,
|
|
|
|
&lineReflowStatus);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
if (LINE_REFLOW_OK != lineReflowStatus) {
|
|
|
|
// It is possible that one or more of next lines are empty
|
|
|
|
// (because of DeleteNextInFlowChild). If so, delete them now
|
|
|
|
// in case we are finished.
|
|
|
|
++aLine;
|
|
|
|
while ((aLine != end_lines()) && (0 == aLine->GetChildCount())) {
|
|
|
|
// XXX Is this still necessary now that DeleteNextInFlowChild
|
|
|
|
// uses DoRemoveFrame?
|
|
|
|
nsLineBox *toremove = aLine;
|
|
|
|
aLine = mLines.erase(aLine);
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_ASSERTION(nullptr == toremove->mFirstChild, "bad empty line");
|
2012-03-10 18:32:27 -08:00
|
|
|
FreeLineBox(toremove);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
--aLine;
|
|
|
|
|
2010-08-05 21:59:19 -07:00
|
|
|
NS_ASSERTION(lineReflowStatus != LINE_REFLOW_TRUNCATED,
|
|
|
|
"ReflowInlineFrame should never determine that a line "
|
|
|
|
"needs to go to the next page/column");
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Don't pull up new frames into lines with continuation placeholders
|
2009-08-31 11:25:35 -07:00
|
|
|
if (aAllowPullUp) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// Pull frames and reflow them until we can't
|
|
|
|
while (LINE_REFLOW_OK == lineReflowStatus) {
|
2010-01-11 06:08:23 -08:00
|
|
|
frame = PullFrame(aState, aLine);
|
|
|
|
if (!frame) {
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (LINE_REFLOW_OK == lineReflowStatus) {
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t oldCount = aLine->GetChildCount();
|
2007-03-22 10:30:00 -07:00
|
|
|
rv = ReflowInlineFrame(aState, aLineLayout, aLine, frame,
|
|
|
|
&lineReflowStatus);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-27 10:44:47 -08:00
|
|
|
aState.SetFlag(BRS_LINE_LAYOUT_EMPTY, aLineLayout.LineIsEmpty());
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// We only need to backup if the line isn't going to be reflowed again anyway
|
2011-09-28 23:19:26 -07:00
|
|
|
bool needsBackup = aLineLayout.NeedsBackup() &&
|
2007-03-22 10:30:00 -07:00
|
|
|
(lineReflowStatus == LINE_REFLOW_STOP || lineReflowStatus == LINE_REFLOW_OK);
|
|
|
|
if (needsBackup && aLineLayout.HaveForcedBreakPosition()) {
|
|
|
|
NS_WARNING("We shouldn't be backing up more than once! "
|
|
|
|
"Someone must have set a break opportunity beyond the available width, "
|
|
|
|
"even though there were better break opportunities before it");
|
2011-10-17 07:59:28 -07:00
|
|
|
needsBackup = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
if (needsBackup) {
|
|
|
|
// We need to try backing up to before a text run
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t offset;
|
2008-07-24 00:16:18 -07:00
|
|
|
gfxBreakPriority breakPriority;
|
|
|
|
nsIContent* breakContent = aLineLayout.GetLastOptionalBreakPosition(&offset, &breakPriority);
|
2007-03-22 16:10:10 -07: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.
|
2007-03-22 10:30:00 -07:00
|
|
|
if (breakContent) {
|
|
|
|
// We can back up!
|
|
|
|
lineReflowStatus = LINE_REFLOW_REDO_NO_PULL;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// In case we reflow this line again, remember that we don't
|
|
|
|
// need to force any breaking
|
|
|
|
aLineLayout.ClearOptionalBreakPosition();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (LINE_REFLOW_REDO_NEXT_BAND == lineReflowStatus) {
|
|
|
|
// This happens only when we have a line that is impacted by
|
|
|
|
// floats and the first element in the line doesn't fit with
|
|
|
|
// the floats.
|
|
|
|
//
|
|
|
|
// What we do is to advance past the first float we find and
|
|
|
|
// then reflow the line all over again.
|
2009-05-20 04:21:34 -07:00
|
|
|
NS_ASSERTION(NS_UNCONSTRAINEDSIZE != aFloatAvailableSpace.mRect.height,
|
2007-03-22 10:30:00 -07:00
|
|
|
"unconstrained height on totally empty line");
|
|
|
|
|
2008-01-28 23:40:05 -08:00
|
|
|
// See the analogous code for blocks in nsBlockReflowState::ClearFloats.
|
2009-05-20 04:21:34 -07:00
|
|
|
if (aFloatAvailableSpace.mRect.height > 0) {
|
|
|
|
NS_ASSERTION(aFloatAvailableSpace.mHasFloats,
|
2007-10-09 19:18:40 -07:00
|
|
|
"redo line on totally empty line with non-empty band...");
|
2009-05-20 04:21:34 -07: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();
|
2007-03-22 10:30:00 -07:00
|
|
|
} else {
|
2013-12-27 09:59:21 -08:00
|
|
|
NS_ASSERTION(NS_UNCONSTRAINEDSIZE != aState.mReflowState.AvailableHeight(),
|
2007-03-22 10:30:00 -07:00
|
|
|
"We shouldn't be running out of height here");
|
2013-12-27 09:59:21 -08:00
|
|
|
if (NS_UNCONSTRAINEDSIZE == aState.mReflowState.AvailableHeight()) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// just move it down a bit to try to get out of this mess
|
|
|
|
aState.mY += 1;
|
2009-05-20 04:21:34 -07: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();
|
2007-03-22 10:30:00 -07:00
|
|
|
} else {
|
2010-08-05 21:59:19 -07: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.
|
2007-03-22 10:30:00 -07:00
|
|
|
lineReflowStatus = LINE_REFLOW_TRUNCATED;
|
2012-11-08 08:09:38 -08:00
|
|
|
PushTruncatedLine(aState, aLine, aKeepReflowGoing);
|
2007-03-22 10:30:00 -07: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
|
|
|
|
// past the float.
|
|
|
|
}
|
2009-05-20 04:21:34 -07:00
|
|
|
else if (LINE_REFLOW_TRUNCATED != lineReflowStatus &&
|
|
|
|
LINE_REFLOW_REDO_NO_PULL != lineReflowStatus) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// If we are propagating out a break-before status then there is
|
|
|
|
// no point in placing the line.
|
|
|
|
if (!NS_INLINE_IS_BREAK_BEFORE(aState.mReflowStatus)) {
|
2009-05-20 04:21:34 -07:00
|
|
|
if (!PlaceLine(aState, aLineLayout, aLine, aFloatStateBeforeLine,
|
2009-06-16 08:00:20 -07:00
|
|
|
aFloatAvailableSpace.mRect, aAvailableSpaceHeight,
|
|
|
|
aKeepReflowGoing)) {
|
2009-05-20 04:21:34 -07:00
|
|
|
lineReflowStatus = LINE_REFLOW_REDO_MORE_FLOATS;
|
|
|
|
// PlaceLine already called GetAvailableSpaceForHeight for us.
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (gNoisyReflow) {
|
|
|
|
printf("Line reflow status = %s\n", LineReflowStatusNames[lineReflowStatus]);
|
|
|
|
}
|
|
|
|
#endif
|
2009-10-26 18:43:56 -07:00
|
|
|
|
|
|
|
if (aLineLayout.GetDirtyNextLine()) {
|
|
|
|
// aLine may have been pushed to the overflow lines.
|
2012-03-07 17:57:37 -08:00
|
|
|
FrameLines* overflowLines = GetOverflowLines();
|
2009-10-26 18:43:56 -07:00
|
|
|
// We can't just compare iterators front() to aLine here, since they may be in
|
|
|
|
// different lists.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool pushedToOverflowLines = overflowLines &&
|
2012-03-07 17:57:37 -08:00
|
|
|
overflowLines->mLines.front() == aLine.get();
|
2009-10-26 18:43:56 -07:00
|
|
|
if (pushedToOverflowLines) {
|
|
|
|
// aLine is stale, it's associated with the main line list but it should
|
|
|
|
// be associated with the overflow line list now
|
2012-03-07 17:57:37 -08:00
|
|
|
aLine = overflowLines->mLines.begin();
|
2009-10-26 18:43:56 -07:00
|
|
|
}
|
|
|
|
nsBlockInFlowLineIterator iter(this, aLine, pushedToOverflowLines);
|
|
|
|
if (iter.Next() && iter.GetLine()->IsInline()) {
|
|
|
|
iter.GetLine()->MarkDirty();
|
|
|
|
if (iter.GetContainer() != this) {
|
|
|
|
aState.mReflowStatus |= NS_FRAME_REFLOW_NEXTINFLOW;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
*aLineReflowStatus = lineReflowStatus;
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reflow an inline frame. The reflow status is mapped from the frames
|
|
|
|
* reflow status to the lines reflow status (not to our reflow status).
|
2011-10-17 07:59:28 -07:00
|
|
|
* The line reflow status is simple: true means keep placing frames
|
|
|
|
* on the line; false means don't (the line is done). If the line
|
2007-03-22 10:30:00 -07:00
|
|
|
* has some sort of breaking affect then aLine's break-type will be set
|
|
|
|
* to something other than NS_STYLE_CLEAR_NONE.
|
|
|
|
*/
|
|
|
|
nsresult
|
|
|
|
nsBlockFrame::ReflowInlineFrame(nsBlockReflowState& aState,
|
|
|
|
nsLineLayout& aLineLayout,
|
|
|
|
line_iterator aLine,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
LineReflowStatus* aLineReflowStatus)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aFrame);
|
|
|
|
|
|
|
|
*aLineReflowStatus = LINE_REFLOW_OK;
|
|
|
|
|
|
|
|
#ifdef NOISY_FIRST_LETTER
|
|
|
|
ListTag(stdout);
|
|
|
|
printf(": reflowing ");
|
|
|
|
nsFrame::ListTag(stdout, aFrame);
|
2008-08-05 17:31:25 -07:00
|
|
|
printf(" reflowingFirstLetter=%s\n",
|
|
|
|
aLineLayout.GetFirstLetterStyleOK() ? "on" : "off");
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// Reflow the inline frame
|
|
|
|
nsReflowStatus frameReflowStatus;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool pushedFrame;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult rv = aLineLayout.ReflowFrame(aFrame, frameReflowStatus,
|
2012-07-30 07:20:58 -07:00
|
|
|
nullptr, pushedFrame);
|
2007-04-22 13:57:54 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
if (frameReflowStatus & NS_FRAME_REFLOW_NEXTINFLOW) {
|
2009-10-26 18:43:56 -07:00
|
|
|
aLineLayout.SetDirtyNextLine();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
#ifdef REALLY_NOISY_REFLOW_CHILD
|
|
|
|
nsFrame::ListTag(stdout, aFrame);
|
|
|
|
printf(": status=%x\n", frameReflowStatus);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(REFLOW_STATUS_COVERAGE)
|
2011-10-17 07:59:28 -07:00
|
|
|
RecordReflowStatus(false, frameReflowStatus);
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// Send post-reflow notification
|
|
|
|
aState.mPrevChild = aFrame;
|
|
|
|
|
|
|
|
/* 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
|
|
|
|
to a left float, even when that float takes up all the width on a line.
|
|
|
|
see bug 22496
|
|
|
|
*/
|
|
|
|
|
|
|
|
// 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).
|
|
|
|
aLine->SetBreakTypeAfter(NS_STYLE_CLEAR_NONE);
|
|
|
|
if (NS_INLINE_IS_BREAK(frameReflowStatus) ||
|
|
|
|
(NS_STYLE_CLEAR_NONE != aState.mFloatBreakType)) {
|
|
|
|
// Always abort the line reflow (because a line break is the
|
|
|
|
// minimal amount of break we do).
|
|
|
|
*aLineReflowStatus = LINE_REFLOW_STOP;
|
|
|
|
|
|
|
|
// XXX what should aLine's break-type be set to in all these cases?
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t breakType = NS_INLINE_GET_BREAK_TYPE(frameReflowStatus);
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ASSERTION((NS_STYLE_CLEAR_NONE != breakType) ||
|
|
|
|
(NS_STYLE_CLEAR_NONE != aState.mFloatBreakType), "bad break type");
|
2014-03-01 02:36:39 -08:00
|
|
|
NS_ASSERTION(NS_STYLE_CLEAR_MAX >= breakType, "invalid break type");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
if (NS_INLINE_IS_BREAK_BEFORE(frameReflowStatus)) {
|
|
|
|
// Break-before cases.
|
|
|
|
if (aFrame == aLine->mFirstChild) {
|
|
|
|
// If we break before the first frame on the line then we must
|
|
|
|
// be trying to place content where there's no room (e.g. on a
|
|
|
|
// line with wide floats). Inform the caller to reflow the
|
|
|
|
// line after skipping past a float.
|
|
|
|
*aLineReflowStatus = LINE_REFLOW_REDO_NEXT_BAND;
|
|
|
|
}
|
|
|
|
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.
|
2013-06-18 23:09:22 -07:00
|
|
|
SplitLine(aState, aLineLayout, aLine, aFrame, aLineReflowStatus);
|
2007-03-22 10:30:00 -07: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) {
|
2011-10-17 07:59:28 -07:00
|
|
|
aLine->SetLineWrapped(true);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// If a float split and its prev-in-flow was followed by a <BR>, then combine
|
|
|
|
// the <BR>'s break type with the inline's break type (the inline will be the very
|
|
|
|
// next frame after the split float).
|
|
|
|
if (NS_STYLE_CLEAR_NONE != aState.mFloatBreakType) {
|
|
|
|
breakType = nsLayoutUtils::CombineBreakType(breakType,
|
|
|
|
aState.mFloatBreakType);
|
|
|
|
aState.mFloatBreakType = NS_STYLE_CLEAR_NONE;
|
|
|
|
}
|
|
|
|
// Break-after cases
|
|
|
|
if (breakType == NS_STYLE_CLEAR_LINE) {
|
|
|
|
if (!aLineLayout.GetLineEndsInBR()) {
|
|
|
|
breakType = NS_STYLE_CLEAR_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aLine->SetBreakTypeAfter(breakType);
|
2008-04-08 07:42:52 -07:00
|
|
|
if (NS_FRAME_IS_COMPLETE(frameReflowStatus)) {
|
|
|
|
// Split line, but after the frame just reflowed
|
2013-06-18 23:09:22 -07:00
|
|
|
SplitLine(aState, aLineLayout, aLine, aFrame->GetNextSibling(), aLineReflowStatus);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-04-08 07:42:52 -07:00
|
|
|
if (NS_INLINE_IS_BREAK_AFTER(frameReflowStatus) &&
|
|
|
|
!aLineLayout.GetLineEndsInBR()) {
|
2009-10-26 18:43:56 -07:00
|
|
|
aLineLayout.SetDirtyNextLine();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-31 11:25:36 -07:00
|
|
|
if (!NS_FRAME_IS_FULLY_COMPLETE(frameReflowStatus)) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// Create a continuation for the incomplete frame. Note that the
|
|
|
|
// frame may already have a continuation.
|
2013-06-18 23:09:20 -07:00
|
|
|
CreateContinuationFor(aState, aLine, aFrame);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Remember that the line has wrapped
|
|
|
|
if (!aLineLayout.GetLineEndsInBR()) {
|
2011-10-17 07:59:28 -07:00
|
|
|
aLine->SetLineWrapped(true);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2008-08-05 17:31:25 -07:00
|
|
|
// If we just ended a first-letter frame or reflowed a placeholder then
|
2007-03-22 10:30:00 -07:00
|
|
|
// don't split the line and don't stop the line reflow...
|
2010-01-27 20:12:45 -08:00
|
|
|
// But if we are going to stop anyways we'd better split the line.
|
|
|
|
if ((!(frameReflowStatus & NS_INLINE_BREAK_FIRST_LETTER_COMPLETE) &&
|
2013-06-18 23:09:20 -07:00
|
|
|
nsGkAtoms::placeholderFrame != aFrame->GetType()) ||
|
2010-01-27 20:12:45 -08:00
|
|
|
*aLineReflowStatus == LINE_REFLOW_STOP) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// Split line after the current frame
|
|
|
|
*aLineReflowStatus = LINE_REFLOW_STOP;
|
2013-06-18 23:09:22 -07:00
|
|
|
SplitLine(aState, aLineLayout, aLine, aFrame->GetNextSibling(), aLineReflowStatus);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-06-18 23:09:20 -07:00
|
|
|
bool
|
2007-03-22 10:30:00 -07:00
|
|
|
nsBlockFrame::CreateContinuationFor(nsBlockReflowState& aState,
|
|
|
|
nsLineBox* aLine,
|
2013-06-18 23:09:20 -07:00
|
|
|
nsIFrame* aFrame)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-06-18 23:09:20 -07:00
|
|
|
nsIFrame* newFrame = nullptr;
|
2009-09-18 04:09:35 -07:00
|
|
|
|
|
|
|
if (!aFrame->GetNextInFlow()) {
|
2013-06-18 23:09:20 -07:00
|
|
|
newFrame = aState.mPresContext->PresShell()->FrameConstructor()->
|
2013-03-19 18:47:49 -07:00
|
|
|
CreateContinuingFrame(aState.mPresContext, aFrame, this);
|
2009-09-18 04:09:35 -07:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
mFrames.InsertFrame(nullptr, aFrame, newFrame);
|
2009-09-18 04:09:35 -07:00
|
|
|
|
2013-06-18 23:23:45 -07:00
|
|
|
if (aLine) {
|
2012-03-10 18:32:27 -08:00
|
|
|
aLine->NoteFrameAdded(newFrame);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifdef DEBUG
|
2011-10-17 07:59:28 -07:00
|
|
|
VerifyLines(false);
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
2013-06-18 23:09:20 -07:00
|
|
|
return !!newFrame;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2009-08-31 11:25:36 -07:00
|
|
|
nsBlockFrame::SplitFloat(nsBlockReflowState& aState,
|
|
|
|
nsIFrame* aFloat,
|
|
|
|
nsReflowStatus aFloatStatus)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-08-05 21:59:19 -07:00
|
|
|
nsIFrame* nextInFlow = aFloat->GetNextInFlow();
|
|
|
|
if (nextInFlow) {
|
|
|
|
nsContainerFrame *oldParent =
|
|
|
|
static_cast<nsContainerFrame*>(nextInFlow->GetParent());
|
2014-02-06 14:07:47 -08:00
|
|
|
DebugOnly<nsresult> rv = oldParent->StealFrame(nextInFlow);
|
2010-08-05 21:59:19 -07:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "StealFrame failed");
|
|
|
|
if (oldParent != this) {
|
|
|
|
ReparentFrame(nextInFlow, oldParent, this);
|
|
|
|
}
|
|
|
|
} else {
|
2013-03-19 18:47:49 -07:00
|
|
|
nextInFlow = aState.mPresContext->PresShell()->FrameConstructor()->
|
|
|
|
CreateContinuingFrame(aState.mPresContext, aFloat, this);
|
2009-09-18 04:09:35 -07:00
|
|
|
}
|
2009-08-31 11:25:36 -07:00
|
|
|
if (NS_FRAME_OVERFLOW_IS_INCOMPLETE(aFloatStatus))
|
|
|
|
aFloat->GetNextInFlow()->AddStateBits(NS_FRAME_IS_OVERFLOW_CONTAINER);
|
|
|
|
|
2010-08-05 21:59:19 -07:00
|
|
|
// The containing block is now overflow-incomplete.
|
|
|
|
NS_FRAME_SET_OVERFLOW_INCOMPLETE(aState.mReflowStatus);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-02-16 13:51:02 -08:00
|
|
|
if (aFloat->StyleDisplay()->mFloats == NS_STYLE_FLOAT_LEFT) {
|
2010-08-05 21:59:19 -07:00
|
|
|
aState.mFloatManager->SetSplitLeftFloatAcrossBreak();
|
|
|
|
} else {
|
2013-02-16 13:51:02 -08:00
|
|
|
NS_ABORT_IF_FALSE(aFloat->StyleDisplay()->mFloats ==
|
2010-08-05 21:59:19 -07:00
|
|
|
NS_STYLE_FLOAT_RIGHT, "unexpected float side");
|
|
|
|
aState.mFloatManager->SetSplitRightFloatAcrossBreak();
|
|
|
|
}
|
|
|
|
|
2010-08-05 21:59:20 -07:00
|
|
|
aState.AppendPushedFloat(nextInFlow);
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsFloatCache*
|
|
|
|
GetLastFloat(nsLineBox* aLine)
|
|
|
|
{
|
|
|
|
nsFloatCache* fc = aLine->GetFirstFloat();
|
|
|
|
while (fc && fc->Next()) {
|
|
|
|
fc = fc->Next();
|
|
|
|
}
|
|
|
|
return fc;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool
|
2007-03-22 10:30:00 -07:00
|
|
|
CheckPlaceholderInLine(nsIFrame* aBlock, nsLineBox* aLine, nsFloatCache* aFC)
|
|
|
|
{
|
2010-08-05 21:59:19 -07:00
|
|
|
if (!aFC)
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2010-08-05 21:59:19 -07:00
|
|
|
NS_ASSERTION(!aFC->mFloat->GetPrevContinuation(),
|
|
|
|
"float in a line should never be a continuation");
|
2010-08-05 21:59:20 -07:00
|
|
|
NS_ASSERTION(!(aFC->mFloat->GetStateBits() & NS_FRAME_IS_PUSHED_FLOAT),
|
2010-08-05 21:59:19 -07:00
|
|
|
"float in a line should never be a pushed float");
|
2009-08-31 11:25:35 -07:00
|
|
|
nsIFrame* ph = aBlock->PresContext()->FrameManager()->
|
2013-09-25 04:42:34 -07:00
|
|
|
GetPlaceholderFrameFor(aFC->mFloat->FirstInFlow());
|
2009-08-31 11:25:35 -07:00
|
|
|
for (nsIFrame* f = ph; f; f = f->GetParent()) {
|
2007-03-22 10:30:00 -07:00
|
|
|
if (f->GetParent() == aBlock)
|
|
|
|
return aLine->Contains(f);
|
|
|
|
}
|
2011-10-17 07:59:28 -07:00
|
|
|
NS_ASSERTION(false, "aBlock is not an ancestor of aFrame!");
|
|
|
|
return true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-06-18 23:09:22 -07:00
|
|
|
void
|
2007-03-22 10:30:00 -07:00
|
|
|
nsBlockFrame::SplitLine(nsBlockReflowState& aState,
|
|
|
|
nsLineLayout& aLineLayout,
|
|
|
|
line_iterator aLine,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
LineReflowStatus* aLineReflowStatus)
|
|
|
|
{
|
|
|
|
NS_ABORT_IF_FALSE(aLine->IsInline(), "illegal SplitLine on block line");
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t pushCount = aLine->GetChildCount() - aLineLayout.GetCurrentSpanCount();
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ABORT_IF_FALSE(pushCount >= 0, "bad push count");
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (gNoisyReflow) {
|
|
|
|
nsFrame::IndentBy(stdout, gNoiseIndent);
|
|
|
|
printf("split line: from line=%p pushCount=%d aFrame=",
|
2007-07-08 00:08:04 -07:00
|
|
|
static_cast<void*>(aLine.get()), pushCount);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (aFrame) {
|
|
|
|
nsFrame::ListTag(stdout, aFrame);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
printf("(null)");
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
if (gReallyNoisyReflow) {
|
|
|
|
aLine->List(stdout, gNoiseIndent+1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (0 != pushCount) {
|
|
|
|
NS_ABORT_IF_FALSE(aLine->GetChildCount() > pushCount, "bad push");
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_ABORT_IF_FALSE(nullptr != aFrame, "whoops");
|
2010-08-19 06:38:00 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
{
|
|
|
|
nsIFrame *f = aFrame;
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t count = pushCount;
|
2010-08-19 06:38:00 -07:00
|
|
|
while (f && count > 0) {
|
|
|
|
f = f->GetNextSibling();
|
|
|
|
--count;
|
|
|
|
}
|
|
|
|
NS_ASSERTION(count == 0, "Not enough frames to push");
|
|
|
|
}
|
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Put frames being split out into their own line
|
2012-03-10 18:32:27 -08:00
|
|
|
nsLineBox* newLine = NewLineBox(aLine, aFrame, pushCount);
|
2007-03-22 10:30:00 -07:00
|
|
|
mLines.after_insert(aLine, newLine);
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (gReallyNoisyReflow) {
|
|
|
|
newLine->List(stdout, gNoiseIndent+1);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Let line layout know that some frames are no longer part of its
|
|
|
|
// state.
|
|
|
|
aLineLayout.SplitLineTo(aLine->GetChildCount());
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2011-10-17 07:59:28 -07:00
|
|
|
VerifyLines(true);
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2012-01-12 09:52:21 -08:00
|
|
|
nsBlockFrame::IsLastLine(nsBlockReflowState& aState,
|
|
|
|
line_iterator aLine)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
while (++aLine != end_lines()) {
|
|
|
|
// There is another line
|
|
|
|
if (0 != aLine->GetChildCount()) {
|
2012-01-12 09:52:21 -08:00
|
|
|
// If the next line is a block line then this line is the last in a
|
2007-03-22 10:30:00 -07:00
|
|
|
// group of inline lines.
|
2012-01-12 09:52:21 -08:00
|
|
|
return aLine->IsBlock();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
// The next line is empty, try the next one
|
|
|
|
}
|
|
|
|
|
|
|
|
// XXX Not sure about this part
|
|
|
|
// Try our next-in-flows lines to answer the question
|
|
|
|
nsBlockFrame* nextInFlow = (nsBlockFrame*) GetNextInFlow();
|
2012-07-30 07:20:58 -07:00
|
|
|
while (nullptr != nextInFlow) {
|
2007-03-22 10:30:00 -07:00
|
|
|
for (line_iterator line = nextInFlow->begin_lines(),
|
|
|
|
line_end = nextInFlow->end_lines();
|
|
|
|
line != line_end;
|
|
|
|
++line)
|
|
|
|
{
|
|
|
|
if (0 != line->GetChildCount())
|
2012-01-12 09:52:21 -08:00
|
|
|
return line->IsBlock();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
nextInFlow = (nsBlockFrame*) nextInFlow->GetNextInFlow();
|
|
|
|
}
|
|
|
|
|
|
|
|
// This is the last line - so don't allow justification
|
2012-01-12 09:52:21 -08:00
|
|
|
return true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2007-03-22 10:30:00 -07:00
|
|
|
nsBlockFrame::PlaceLine(nsBlockReflowState& aState,
|
|
|
|
nsLineLayout& aLineLayout,
|
|
|
|
line_iterator aLine,
|
2009-05-20 04:21:34 -07:00
|
|
|
nsFloatManager::SavedState *aFloatStateBeforeLine,
|
|
|
|
nsRect& aFloatAvailableSpace,
|
2009-06-16 08:00:20 -07:00
|
|
|
nscoord& aAvailableSpaceHeight,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool* aKeepReflowGoing)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
// Trim extra white-space from the line before placing the frames
|
|
|
|
aLineLayout.TrimTrailingWhiteSpace();
|
|
|
|
|
|
|
|
// 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
|
|
|
|
// first or second line. It's only placed on the second line in a
|
2008-02-10 13:49:24 -08:00
|
|
|
// rare case: when the first line is empty.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool addedBullet = false;
|
2012-03-07 17:57:37 -08:00
|
|
|
if (HasOutsideBullet() &&
|
2008-02-10 13:49:24 -08:00
|
|
|
((aLine == mLines.front() &&
|
2014-03-11 13:23:50 -07:00
|
|
|
(!aLineLayout.IsZeroBSize() || (aLine == mLines.back()))) ||
|
2008-02-10 13:49:24 -08:00
|
|
|
(mLines.front() != mLines.back() &&
|
|
|
|
0 == mLines.front()->mBounds.height &&
|
|
|
|
aLine == mLines.begin().next()))) {
|
2013-12-31 05:50:31 -08:00
|
|
|
nsHTMLReflowMetrics metrics(aState.mReflowState);
|
2012-03-07 17:57:37 -08:00
|
|
|
nsIFrame* bullet = GetOutsideBullet();
|
|
|
|
ReflowBullet(bullet, aState, metrics, aState.mY);
|
2013-12-27 09:59:52 -08:00
|
|
|
NS_ASSERTION(!BulletIsEmpty() || metrics.Height() == 0,
|
2009-09-11 03:46:36 -07:00
|
|
|
"empty bullet took up space");
|
2012-03-07 17:57:37 -08:00
|
|
|
aLineLayout.AddBulletFrame(bullet, metrics);
|
2011-10-17 07:59:28 -07:00
|
|
|
addedBullet = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2014-03-11 13:23:50 -07:00
|
|
|
aLineLayout.BlockDirAlignLine();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-05-20 04:21:34 -07: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 08:00:20 -07:00
|
|
|
// As we redo for floats, we can't reduce the amount of height we're
|
|
|
|
// checking.
|
2013-01-15 04:22:03 -08:00
|
|
|
aAvailableSpaceHeight = std::max(aAvailableSpaceHeight, aLine->mBounds.height);
|
2009-05-20 04:21:34 -07:00
|
|
|
aFloatAvailableSpace =
|
|
|
|
aState.GetFloatAvailableSpaceForHeight(aLine->mBounds.y,
|
2009-06-16 08:00:20 -07:00
|
|
|
aAvailableSpaceHeight,
|
2009-05-20 04:21:34 -07: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)) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2009-05-20 04:21:34 -07:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
{
|
|
|
|
static nscoord lastHeight = 0;
|
2014-03-11 13:23:50 -07:00
|
|
|
if (CRAZY_SIZE(aLine->mBounds.y)) {
|
2007-03-22 10:30:00 -07:00
|
|
|
lastHeight = aLine->mBounds.y;
|
2014-03-11 13:23:50 -07:00
|
|
|
if (abs(aLine->mBounds.y - lastHeight) > CRAZY_COORD/10) {
|
2007-03-22 10:30:00 -07:00
|
|
|
nsFrame::ListTag(stdout);
|
|
|
|
printf(": line=%p y=%d line.bounds.height=%d\n",
|
2007-07-08 00:08:04 -07:00
|
|
|
static_cast<void*>(aLine.get()),
|
2007-03-22 10:30:00 -07:00
|
|
|
aLine->mBounds.y, aLine->mBounds.height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
lastHeight = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Only block frames horizontally align their children because
|
|
|
|
// inline frames "shrink-wrap" around their children (therefore
|
|
|
|
// there is no extra horizontal space).
|
2013-02-16 13:51:02 -08:00
|
|
|
const nsStyleText* styleText = StyleText();
|
2012-01-12 09:52:21 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* text-align-last defaults to the same value as text-align when
|
2012-08-02 04:38:47 -07:00
|
|
|
* text-align-last is set to auto (except when text-align is set to justify),
|
2012-01-12 09:52:21 -08:00
|
|
|
* so in that case we don't need to set isLastLine.
|
|
|
|
*
|
|
|
|
* In other words, isLastLine really means isLastLineAndWeCare.
|
|
|
|
*/
|
2012-08-02 04:38:47 -07:00
|
|
|
bool isLastLine =
|
|
|
|
!IsSVGText() &&
|
|
|
|
((NS_STYLE_TEXT_ALIGN_AUTO != styleText->mTextAlignLast ||
|
|
|
|
NS_STYLE_TEXT_ALIGN_JUSTIFY == styleText->mTextAlign) &&
|
|
|
|
(aLineLayout.GetLineEndsInBR() ||
|
|
|
|
IsLastLine(aState, aLine)));
|
2014-03-11 13:23:50 -07:00
|
|
|
|
|
|
|
aLineLayout.InlineDirAlignFrames(aLine->mBounds, isLastLine,
|
|
|
|
aLine->GetChildCount());
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-12-11 17:43:09 -08:00
|
|
|
// From here on, pfd->mBounds rectangles are incorrect because bidi
|
|
|
|
// might have moved frames around!
|
2010-10-06 21:25:45 -07:00
|
|
|
nsOverflowAreas overflowAreas;
|
|
|
|
aLineLayout.RelativePositionFrames(overflowAreas);
|
|
|
|
aLine->SetOverflowAreas(overflowAreas);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (addedBullet) {
|
2012-03-07 17:57:37 -08:00
|
|
|
aLineLayout.RemoveBulletFrame(GetOutsideBullet());
|
2007-03-22 10:30:00 -07: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;
|
|
|
|
|
|
|
|
if (!aLine->CachedIsEmpty()) {
|
|
|
|
// This line has some height. Therefore the application of the
|
|
|
|
// previous-bottom-margin should stick.
|
|
|
|
aState.mPrevBottomMargin.Zero();
|
|
|
|
newY = aLine->mBounds.YMost();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Don't let the previous-bottom-margin value affect the newY
|
|
|
|
// coordinate (it was applied in ReflowInlineFrames speculatively)
|
|
|
|
// since the line is empty.
|
|
|
|
// We already called |ShouldApplyTopMargin|, and if we applied it
|
|
|
|
// then BRS_APPLYTOPMARGIN is set.
|
|
|
|
nscoord dy = aState.GetFlag(BRS_APPLYTOPMARGIN)
|
|
|
|
? -aState.mPrevBottomMargin.get() : 0;
|
|
|
|
newY = aState.mY + dy;
|
|
|
|
}
|
|
|
|
|
2012-11-08 08:09:38 -08:00
|
|
|
if (!NS_FRAME_IS_FULLY_COMPLETE(aState.mReflowStatus) &&
|
|
|
|
ShouldAvoidBreakInside(aState.mReflowState)) {
|
|
|
|
aLine->AppendFloats(aState.mCurrentLineFloats);
|
|
|
|
aState.mReflowStatus = NS_INLINE_LINE_BREAK_BEFORE();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// See if the line fit (our first line always does).
|
2010-12-02 10:57:26 -08:00
|
|
|
if (mLines.front() != aLine &&
|
2007-03-22 10:30:00 -07:00
|
|
|
newY > aState.mBottomEdge &&
|
|
|
|
aState.mBottomEdge != NS_UNCONSTRAINEDSIZE) {
|
2012-11-08 08:09:38 -08:00
|
|
|
NS_ASSERTION(aState.mCurrentLine == aLine, "oops");
|
|
|
|
if (ShouldAvoidBreakInside(aState.mReflowState)) {
|
|
|
|
// All our content doesn't fit, start on the next page.
|
|
|
|
aState.mReflowStatus = NS_INLINE_LINE_BREAK_BEFORE();
|
|
|
|
} else {
|
|
|
|
// Push aLine and all of its children and anything else that
|
|
|
|
// follows to our next-in-flow.
|
|
|
|
PushTruncatedLine(aState, aLine, aKeepReflowGoing);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
aState.mY = newY;
|
|
|
|
|
|
|
|
// Add the already placed current-line floats to the line
|
|
|
|
aLine->AppendFloats(aState.mCurrentLineFloats);
|
|
|
|
|
|
|
|
// Any below current line floats to place?
|
|
|
|
if (aState.mBelowCurrentLineFloats.NotEmpty()) {
|
2010-08-05 21:59:20 -07:00
|
|
|
// Reflow the below-current-line floats, which places on the line's
|
|
|
|
// float list.
|
2010-08-05 21:59:20 -07:00
|
|
|
aState.PlaceBelowCurrentLineFloats(aState.mBelowCurrentLineFloats, aLine);
|
2010-08-05 21:59:20 -07:00
|
|
|
aLine->AppendFloats(aState.mBelowCurrentLineFloats);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// When a line has floats, factor them into the combined-area
|
|
|
|
// computations.
|
|
|
|
if (aLine->HasFloats()) {
|
|
|
|
// Combine the float combined area (stored in aState) and the
|
|
|
|
// value computed by the line layout code.
|
2010-10-06 21:25:45 -07:00
|
|
|
nsOverflowAreas lineOverflowAreas;
|
|
|
|
NS_FOR_FRAME_OVERFLOW_TYPES(otype) {
|
|
|
|
nsRect &o = lineOverflowAreas.Overflow(otype);
|
|
|
|
o = aLine->GetOverflowArea(otype);
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef NOISY_COMBINED_AREA
|
2010-10-06 21:25:45 -07: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);
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
2010-10-06 21:25:45 -07:00
|
|
|
o.UnionRect(aState.mFloatOverflowAreas.Overflow(otype), o);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifdef NOISY_COMBINED_AREA
|
2010-10-06 21:25:45 -07:00
|
|
|
printf(" ==> final lineCA=%d,%d,%d,%d\n",
|
|
|
|
o.x, o.y, o.width, o.height);
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
2010-10-06 21:25:45 -07:00
|
|
|
}
|
|
|
|
aLine->SetOverflowAreas(lineOverflowAreas);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Apply break-after clearing if necessary
|
|
|
|
// This must stay in sync with |ReflowDirtyLines|.
|
|
|
|
if (aLine->HasFloatBreakAfter()) {
|
|
|
|
aState.mY = aState.ClearFloats(aState.mY, aLine->GetBreakTypeAfter());
|
|
|
|
}
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBlockFrame::PushLines(nsBlockReflowState& aState,
|
|
|
|
nsLineList::iterator aLineBefore)
|
|
|
|
{
|
2012-03-07 17:57:37 -08:00
|
|
|
// NOTE: aLineBefore is always a normal line, not an overflow line.
|
|
|
|
// The following expression will assert otherwise.
|
|
|
|
DebugOnly<bool> check = aLineBefore == mLines.begin();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsLineList::iterator overBegin(aLineBefore.next());
|
|
|
|
|
|
|
|
// PushTruncatedPlaceholderLine sometimes pushes the first line. Ugh.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool firstLine = overBegin == begin_lines();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
if (overBegin != end_lines()) {
|
|
|
|
// Remove floats in the lines from mFloats
|
|
|
|
nsFrameList floats;
|
2013-02-27 15:05:45 -08:00
|
|
|
CollectFloats(overBegin->mFirstChild, floats, true);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
if (floats.NotEmpty()) {
|
|
|
|
// Push the floats onto the front of the overflow out-of-flows list
|
2009-09-18 04:09:36 -07:00
|
|
|
nsAutoOOFFrameList oofs(this);
|
2012-07-30 07:20:58 -07:00
|
|
|
oofs.mList.InsertFrames(nullptr, nullptr, floats);
|
2007-03-22 10:30:00 -07: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.
|
2012-03-07 17:57:37 -08:00
|
|
|
FrameLines* overflowLines = RemoveOverflowLines();
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!overflowLines) {
|
|
|
|
// XXXldb use presshell arena!
|
2012-03-07 17:57:37 -08:00
|
|
|
overflowLines = new FrameLines();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
if (overflowLines) {
|
2012-03-07 17:57:37 -08:00
|
|
|
nsIFrame* lineBeforeLastFrame;
|
2009-09-29 12:47:05 -07:00
|
|
|
if (firstLine) {
|
2012-07-30 07:20:58 -07:00
|
|
|
lineBeforeLastFrame = nullptr; // removes all frames
|
2009-09-29 12:47:05 -07:00
|
|
|
} else {
|
2012-02-17 17:34:20 -08:00
|
|
|
nsIFrame* f = overBegin->mFirstChild;
|
2012-03-07 17:57:37 -08:00
|
|
|
lineBeforeLastFrame = f ? f->GetPrevSibling() : mFrames.LastChild();
|
2012-02-17 17:34:20 -08:00
|
|
|
NS_ASSERTION(!f || lineBeforeLastFrame == aLineBefore->LastChild(),
|
|
|
|
"unexpected line frames");
|
2009-09-29 12:47:05 -07:00
|
|
|
}
|
2012-03-07 17:57:37 -08:00
|
|
|
nsFrameList pushedFrames = mFrames.RemoveFramesAfter(lineBeforeLastFrame);
|
2012-07-30 07:20:58 -07:00
|
|
|
overflowLines->mFrames.InsertFrames(nullptr, nullptr, pushedFrames);
|
2012-03-07 17:57:37 -08:00
|
|
|
|
|
|
|
overflowLines->mLines.splice(overflowLines->mLines.begin(), mLines,
|
|
|
|
overBegin, end_lines());
|
|
|
|
NS_ASSERTION(!overflowLines->mLines.empty(), "should not be empty");
|
2007-03-22 10:30:00 -07:00
|
|
|
// this takes ownership but it won't delete it immediately so we
|
|
|
|
// can keep using it.
|
|
|
|
SetOverflowLines(overflowLines);
|
|
|
|
|
|
|
|
// 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)?
|
2012-03-07 17:57:37 -08:00
|
|
|
for (line_iterator line = overflowLines->mLines.begin(),
|
|
|
|
line_end = overflowLines->mLines.end();
|
2007-03-22 10:30:00 -07:00
|
|
|
line != line_end;
|
|
|
|
++line)
|
2012-03-07 17:57:37 -08:00
|
|
|
{
|
|
|
|
line->MarkDirty();
|
|
|
|
line->MarkPreviousMarginDirty();
|
|
|
|
line->mBounds.SetRect(0, 0, 0, 0);
|
|
|
|
if (line->HasFloats()) {
|
|
|
|
line->FreeFloats(aState.mFloatCacheFreeList);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2012-03-07 17:57:37 -08:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
VerifyOverflowSituation();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2012-01-30 15:35:03 -08:00
|
|
|
nsBlockFrame::DrainOverflowLines()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
VerifyOverflowSituation();
|
|
|
|
#endif
|
|
|
|
|
2012-09-17 16:05:05 -07:00
|
|
|
// Steal the prev-in-flow's overflow lines and prepend them.
|
|
|
|
bool didFindOverflow = false;
|
|
|
|
nsBlockFrame* prevBlock = static_cast<nsBlockFrame*>(GetPrevInFlow());
|
2007-03-22 10:30:00 -07:00
|
|
|
if (prevBlock) {
|
2012-05-03 17:14:01 -07:00
|
|
|
prevBlock->ClearLineCursor();
|
2012-09-17 16:05:05 -07:00
|
|
|
FrameLines* overflowLines = prevBlock->RemoveOverflowLines();
|
2007-03-22 10:30:00 -07:00
|
|
|
if (overflowLines) {
|
2012-03-07 17:57:37 -08:00
|
|
|
// Make all the frames on the overflow line list mine.
|
|
|
|
ReparentFrames(overflowLines->mFrames, prevBlock, this);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-03-07 17:57:37 -08:00
|
|
|
// Make the overflow out-of-flow frames mine too.
|
2007-03-22 10:30:00 -07:00
|
|
|
nsAutoOOFFrameList oofs(prevBlock);
|
|
|
|
if (oofs.mList.NotEmpty()) {
|
2012-03-07 17:57:37 -08:00
|
|
|
ReparentFrames(oofs.mList, prevBlock, this);
|
2012-07-30 07:20:58 -07:00
|
|
|
mFloats.InsertFrames(nullptr, nullptr, oofs.mList);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2009-09-29 12:47:05 -07:00
|
|
|
if (!mLines.empty()) {
|
2012-09-17 16:05:05 -07: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 12:47:05 -07:00
|
|
|
}
|
2012-09-17 16:05:05 -07:00
|
|
|
// The overflow lines have already been marked dirty and their previous
|
|
|
|
// margins marked dirty also.
|
2009-09-29 12:47:05 -07:00
|
|
|
|
2012-09-17 16:05:05 -07:00
|
|
|
// Prepend the overflow frames/lines to our principal list.
|
2012-07-30 07:20:58 -07:00
|
|
|
mFrames.InsertFrames(nullptr, nullptr, overflowLines->mFrames);
|
2012-03-07 17:57:37 -08:00
|
|
|
mLines.splice(mLines.begin(), overflowLines->mLines);
|
|
|
|
NS_ASSERTION(overflowLines->mLines.empty(), "splice should empty list");
|
2012-09-17 16:05:05 -07:00
|
|
|
delete overflowLines;
|
|
|
|
didFindOverflow = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
2012-09-17 16:05:05 -07:00
|
|
|
|
|
|
|
// Now append our own overflow lines.
|
|
|
|
return DrainSelfOverflowList() || didFindOverflow;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
nsBlockFrame::DrainSelfOverflowList()
|
|
|
|
{
|
2013-02-07 17:19:57 -08:00
|
|
|
nsAutoPtr<FrameLines> ourOverflowLines(RemoveOverflowLines());
|
|
|
|
if (!ourOverflowLines) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-09-17 16:05:05 -07:00
|
|
|
// No need to reparent frames in our own overflow lines/oofs, because they're
|
|
|
|
// already ours. But we should put overflow floats back in mFloats.
|
2013-02-07 17:19:57 -08:00
|
|
|
nsAutoOOFFrameList oofs(this);
|
|
|
|
if (oofs.mList.NotEmpty()) {
|
|
|
|
// The overflow floats go after our regular floats.
|
|
|
|
mFloats.AppendFrames(nullptr, oofs.mList);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-09-17 16:05:05 -07:00
|
|
|
if (!ourOverflowLines->mLines.empty()) {
|
|
|
|
mFrames.AppendFrames(nullptr, ourOverflowLines->mFrames);
|
|
|
|
mLines.splice(mLines.end(), ourOverflowLines->mLines);
|
|
|
|
}
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-01-11 14:51:21 -08:00
|
|
|
/**
|
|
|
|
* Pushed floats are floats whose placeholders are in a previous
|
|
|
|
* continuation. They might themselves be next-continuations of a float
|
|
|
|
* that partially fit in an earlier continuation, or they might be the
|
|
|
|
* first continuation of a float that couldn't be placed at all.
|
|
|
|
*
|
|
|
|
* Pushed floats live permanently at the beginning of a block's float
|
|
|
|
* list, where they must live *before* any floats whose placeholders are
|
|
|
|
* in that block.
|
|
|
|
*
|
|
|
|
* Temporarily, during reflow, they also live on the pushed floats list,
|
|
|
|
* which only holds them between (a) when one continuation pushes them to
|
|
|
|
* its pushed floats list because they don't fit and (b) when the next
|
|
|
|
* continuation pulls them onto the beginning of its float list.
|
|
|
|
*
|
|
|
|
* DrainPushedFloats sets up pushed floats the way we need them at the
|
|
|
|
* start of reflow; they are then reflowed by ReflowPushedFloats (which
|
|
|
|
* might push some of them on). Floats with placeholders in this block
|
|
|
|
* are reflowed by (nsBlockReflowState/nsLineLayout)::AddFloat, which
|
|
|
|
* also maintains these invariants.
|
|
|
|
*/
|
2009-08-31 11:25:36 -07:00
|
|
|
void
|
2010-08-05 21:59:20 -07:00
|
|
|
nsBlockFrame::DrainPushedFloats(nsBlockReflowState& aState)
|
2009-08-31 11:25:36 -07:00
|
|
|
{
|
2011-01-11 17:09:21 -08: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
|
|
|
|
|
2013-01-11 14:51:21 -08:00
|
|
|
// If we're getting reflowed multiple times without our
|
|
|
|
// next-continuation being reflowed, we might need to pull back floats
|
|
|
|
// that we just put in the list to be pushed to our next-in-flow.
|
|
|
|
// We don't want to pull back any next-in-flows of floats on our own
|
|
|
|
// float list, and we only need to pull back first-in-flows whose
|
|
|
|
// placeholders were in earlier blocks (since first-in-flows whose
|
|
|
|
// placeholders are in this block will get pulled appropriately by
|
|
|
|
// AddFloat, and will then be more likely to be in the correct order).
|
|
|
|
// FIXME: What if there's a continuation in our pushed floats list
|
|
|
|
// whose prev-in-flow is in a previous continuation of this block
|
|
|
|
// rather than this block? Might we need to pull it back so we don't
|
|
|
|
// report ourselves complete?
|
|
|
|
// FIXME: Maybe we should just pull all of them back?
|
2013-04-01 08:26:02 -07:00
|
|
|
nsPresContext* presContext = PresContext();
|
|
|
|
nsFrameList* ourPushedFloats = GetPushedFloats();
|
2013-01-11 14:51:21 -08:00
|
|
|
if (ourPushedFloats) {
|
|
|
|
// When we pull back floats, we want to put them with the pushed
|
|
|
|
// floats, which must live at the start of our float list, but we
|
|
|
|
// want them at the end of those pushed floats.
|
|
|
|
// FIXME: This isn't quite right! What if they're all pushed floats?
|
|
|
|
nsIFrame *insertionPrevSibling = nullptr; /* beginning of list */
|
|
|
|
for (nsIFrame* f = mFloats.FirstChild();
|
|
|
|
f && (f->GetStateBits() & NS_FRAME_IS_PUSHED_FLOAT);
|
|
|
|
f = f->GetNextSibling()) {
|
|
|
|
insertionPrevSibling = f;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (nsIFrame *f = ourPushedFloats->LastChild(), *next; f; f = next) {
|
|
|
|
next = f->GetPrevSibling();
|
|
|
|
|
|
|
|
if (f->GetPrevContinuation()) {
|
|
|
|
// FIXME
|
|
|
|
} else {
|
|
|
|
nsPlaceholderFrame *placeholder =
|
|
|
|
presContext->FrameManager()->GetPlaceholderFrameFor(f);
|
|
|
|
nsIFrame *floatOriginalParent = presContext->PresShell()->
|
|
|
|
FrameConstructor()->GetFloatContainingBlock(placeholder);
|
|
|
|
if (floatOriginalParent != this) {
|
|
|
|
// This is a first continuation that was pushed from one of our
|
|
|
|
// previous continuations. Take it out of the pushed floats
|
|
|
|
// list and put it in our floats list, before any of our
|
|
|
|
// floats, but after other pushed floats.
|
|
|
|
ourPushedFloats->RemoveFrame(f);
|
|
|
|
mFloats.InsertFrame(nullptr, insertionPrevSibling, f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ourPushedFloats->IsEmpty()) {
|
2013-04-01 08:26:02 -07:00
|
|
|
RemovePushedFloats()->Delete(presContext->PresShell());
|
2013-01-11 14:51:21 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-11 14:51:21 -08:00
|
|
|
// After our prev-in-flow has completed reflow, it may have a pushed
|
|
|
|
// floats list, containing floats that we need to own. Take these.
|
2009-08-31 11:25:36 -07:00
|
|
|
nsBlockFrame* prevBlock = static_cast<nsBlockFrame*>(GetPrevInFlow());
|
2013-01-11 14:51:21 -08:00
|
|
|
if (prevBlock) {
|
2013-04-01 08:26:02 -07:00
|
|
|
AutoFrameListPtr list(presContext, prevBlock->RemovePushedFloats());
|
|
|
|
if (list && list->NotEmpty()) {
|
|
|
|
mFloats.InsertFrames(this, nullptr, *list);
|
2010-08-05 21:59:19 -07:00
|
|
|
}
|
2010-08-05 21:59:19 -07:00
|
|
|
}
|
2009-08-31 11:25:36 -07:00
|
|
|
}
|
|
|
|
|
2012-03-07 17:57:37 -08:00
|
|
|
nsBlockFrame::FrameLines*
|
2007-03-22 10:30:00 -07:00
|
|
|
nsBlockFrame::GetOverflowLines() const
|
|
|
|
{
|
2012-03-07 17:57:37 -08:00
|
|
|
if (!HasOverflowLines()) {
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2012-03-07 17:57:37 -08:00
|
|
|
FrameLines* prop =
|
|
|
|
static_cast<FrameLines*>(Properties().Get(OverflowLinesProperty()));
|
|
|
|
NS_ASSERTION(prop && !prop->mLines.empty() &&
|
2013-01-05 18:04:59 -08:00
|
|
|
prop->mLines.front()->GetChildCount() == 0 ? prop->mFrames.IsEmpty() :
|
|
|
|
prop->mLines.front()->mFirstChild == prop->mFrames.FirstChild(),
|
2007-03-22 10:30:00 -07:00
|
|
|
"value should always be stored and non-empty when state set");
|
2012-03-07 17:57:37 -08:00
|
|
|
return prop;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-03-07 17:57:37 -08:00
|
|
|
nsBlockFrame::FrameLines*
|
2007-03-22 10:30:00 -07:00
|
|
|
nsBlockFrame::RemoveOverflowLines()
|
|
|
|
{
|
2012-03-07 17:57:37 -08:00
|
|
|
if (!HasOverflowLines()) {
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2012-03-07 17:57:37 -08:00
|
|
|
FrameLines* prop =
|
|
|
|
static_cast<FrameLines*>(Properties().Remove(OverflowLinesProperty()));
|
|
|
|
NS_ASSERTION(prop && !prop->mLines.empty() &&
|
2013-01-05 18:04:59 -08:00
|
|
|
prop->mLines.front()->GetChildCount() == 0 ? prop->mFrames.IsEmpty() :
|
|
|
|
prop->mLines.front()->mFirstChild == prop->mFrames.FirstChild(),
|
2007-03-22 10:30:00 -07:00
|
|
|
"value should always be stored and non-empty when state set");
|
|
|
|
RemoveStateBits(NS_BLOCK_HAS_OVERFLOW_LINES);
|
2012-03-07 17:57:37 -08:00
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBlockFrame::DestroyOverflowLines()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(HasOverflowLines(), "huh?");
|
|
|
|
FrameLines* prop =
|
|
|
|
static_cast<FrameLines*>(Properties().Remove(OverflowLinesProperty()));
|
|
|
|
NS_ASSERTION(prop && prop->mLines.empty(),
|
|
|
|
"value should always be stored but empty when destroying");
|
|
|
|
RemoveStateBits(NS_BLOCK_HAS_OVERFLOW_LINES);
|
|
|
|
delete prop;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// This takes ownership of aOverflowLines.
|
|
|
|
// XXX We should allocate overflowLines from presShell arena!
|
2012-03-07 17:57:37 -08:00
|
|
|
void
|
|
|
|
nsBlockFrame::SetOverflowLines(FrameLines* aOverflowLines)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
NS_ASSERTION(aOverflowLines, "null lines");
|
2012-03-07 17:57:37 -08:00
|
|
|
NS_ASSERTION(!aOverflowLines->mLines.empty(), "empty lines");
|
|
|
|
NS_ASSERTION(aOverflowLines->mLines.front()->mFirstChild ==
|
|
|
|
aOverflowLines->mFrames.FirstChild(),
|
|
|
|
"invalid overflow lines / frames");
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ASSERTION(!(GetStateBits() & NS_BLOCK_HAS_OVERFLOW_LINES),
|
|
|
|
"Overwriting existing overflow lines");
|
|
|
|
|
2010-03-28 18:46:55 -07: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);
|
2007-03-22 10:30:00 -07:00
|
|
|
AddStateBits(NS_BLOCK_HAS_OVERFLOW_LINES);
|
|
|
|
}
|
|
|
|
|
2009-09-23 19:39:21 -07:00
|
|
|
nsFrameList*
|
2007-03-22 10:30:00 -07:00
|
|
|
nsBlockFrame::GetOverflowOutOfFlows() const
|
|
|
|
{
|
|
|
|
if (!(GetStateBits() & NS_BLOCK_HAS_OVERFLOW_OUT_OF_FLOWS)) {
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2009-09-23 19:39:21 -07:00
|
|
|
nsFrameList* result =
|
2014-02-06 14:07:47 -08:00
|
|
|
GetPropTableFrames(OverflowOutOfFlowsProperty());
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ASSERTION(result, "value should always be non-empty when state set");
|
2009-09-23 19:39:21 -07:00
|
|
|
return result;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// This takes ownership of the frames
|
|
|
|
void
|
2009-09-23 19:39:21 -07:00
|
|
|
nsBlockFrame::SetOverflowOutOfFlows(const nsFrameList& aList,
|
|
|
|
nsFrameList* aPropValue)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-09-23 19:39:21 -07:00
|
|
|
NS_PRECONDITION(!!(GetStateBits() & NS_BLOCK_HAS_OVERFLOW_OUT_OF_FLOWS) ==
|
|
|
|
!!aPropValue, "state does not match value");
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (aList.IsEmpty()) {
|
|
|
|
if (!(GetStateBits() & NS_BLOCK_HAS_OVERFLOW_OUT_OF_FLOWS)) {
|
|
|
|
return;
|
|
|
|
}
|
2014-02-06 14:07:47 -08:00
|
|
|
nsFrameList* list = RemovePropTableFrames(OverflowOutOfFlowsProperty());
|
2009-09-23 19:39:21 -07:00
|
|
|
NS_ASSERTION(aPropValue == list, "prop value mismatch");
|
2013-04-01 08:26:02 -07:00
|
|
|
list->Clear();
|
2014-02-06 14:07:47 -08:00
|
|
|
list->Delete(PresContext()->PresShell());
|
2007-03-22 10:30:00 -07:00
|
|
|
RemoveStateBits(NS_BLOCK_HAS_OVERFLOW_OUT_OF_FLOWS);
|
2009-09-23 19:39:21 -07:00
|
|
|
}
|
|
|
|
else if (GetStateBits() & NS_BLOCK_HAS_OVERFLOW_OUT_OF_FLOWS) {
|
2014-02-06 14:07:47 -08:00
|
|
|
NS_ASSERTION(aPropValue == GetPropTableFrames(OverflowOutOfFlowsProperty()),
|
2009-09-23 19:39:21 -07:00
|
|
|
"prop value mismatch");
|
|
|
|
*aPropValue = aList;
|
|
|
|
}
|
|
|
|
else {
|
2014-02-06 14:07:47 -08:00
|
|
|
SetPropTableFrames(new (PresContext()->PresShell()) nsFrameList(aList),
|
2010-03-28 18:46:55 -07:00
|
|
|
OverflowOutOfFlowsProperty());
|
2007-03-22 10:30:00 -07:00
|
|
|
AddStateBits(NS_BLOCK_HAS_OVERFLOW_OUT_OF_FLOWS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-07 17:57:37 -08:00
|
|
|
nsBulletFrame*
|
|
|
|
nsBlockFrame::GetInsideBullet() const
|
|
|
|
{
|
|
|
|
if (!HasInsideBullet()) {
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2012-03-07 17:57:37 -08:00
|
|
|
}
|
|
|
|
NS_ASSERTION(!HasOutsideBullet(), "invalid bullet state");
|
|
|
|
nsBulletFrame* frame =
|
|
|
|
static_cast<nsBulletFrame*>(Properties().Get(InsideBulletProperty()));
|
|
|
|
NS_ASSERTION(frame && frame->GetType() == nsGkAtoms::bulletFrame,
|
|
|
|
"bogus inside bullet frame");
|
|
|
|
return frame;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsBulletFrame*
|
|
|
|
nsBlockFrame::GetOutsideBullet() const
|
|
|
|
{
|
|
|
|
nsFrameList* list = GetOutsideBulletList();
|
|
|
|
return list ? static_cast<nsBulletFrame*>(list->FirstChild())
|
2012-07-30 07:20:58 -07:00
|
|
|
: nullptr;
|
2012-03-07 17:57:37 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
nsFrameList*
|
|
|
|
nsBlockFrame::GetOutsideBulletList() const
|
|
|
|
{
|
|
|
|
if (!HasOutsideBullet()) {
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2012-03-07 17:57:37 -08:00
|
|
|
}
|
|
|
|
NS_ASSERTION(!HasInsideBullet(), "invalid bullet state");
|
|
|
|
nsFrameList* list =
|
|
|
|
static_cast<nsFrameList*>(Properties().Get(OutsideBulletProperty()));
|
|
|
|
NS_ASSERTION(list && list->GetLength() == 1 &&
|
|
|
|
list->FirstChild()->GetType() == nsGkAtoms::bulletFrame,
|
|
|
|
"bogus outside bullet list");
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2010-08-05 21:59:19 -07:00
|
|
|
nsFrameList*
|
2010-08-05 21:59:20 -07:00
|
|
|
nsBlockFrame::GetPushedFloats() const
|
2010-08-05 21:59:19 -07:00
|
|
|
{
|
2012-03-07 17:57:37 -08:00
|
|
|
if (!HasPushedFloats()) {
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2010-08-05 21:59:19 -07:00
|
|
|
}
|
|
|
|
nsFrameList* result =
|
2010-08-05 21:59:20 -07:00
|
|
|
static_cast<nsFrameList*>(Properties().Get(PushedFloatProperty()));
|
2010-08-05 21:59:19 -07:00
|
|
|
NS_ASSERTION(result, "value should always be non-empty when state set");
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsFrameList*
|
2010-08-05 21:59:20 -07:00
|
|
|
nsBlockFrame::EnsurePushedFloats()
|
2010-08-05 21:59:19 -07:00
|
|
|
{
|
2010-08-05 21:59:20 -07:00
|
|
|
nsFrameList *result = GetPushedFloats();
|
2010-08-05 21:59:19 -07:00
|
|
|
if (result)
|
|
|
|
return result;
|
|
|
|
|
2013-04-01 08:26:02 -07:00
|
|
|
result = new (PresContext()->PresShell()) nsFrameList;
|
2010-08-05 21:59:20 -07:00
|
|
|
Properties().Set(PushedFloatProperty(), result);
|
|
|
|
AddStateBits(NS_BLOCK_HAS_PUSHED_FLOATS);
|
2010-08-05 21:59:19 -07:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsFrameList*
|
2010-08-05 21:59:20 -07:00
|
|
|
nsBlockFrame::RemovePushedFloats()
|
2010-08-05 21:59:19 -07:00
|
|
|
{
|
2012-03-07 17:57:37 -08:00
|
|
|
if (!HasPushedFloats()) {
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2010-08-05 21:59:19 -07:00
|
|
|
}
|
|
|
|
nsFrameList *result =
|
2010-08-05 21:59:20 -07:00
|
|
|
static_cast<nsFrameList*>(Properties().Remove(PushedFloatProperty()));
|
|
|
|
RemoveStateBits(NS_BLOCK_HAS_PUSHED_FLOATS);
|
2010-08-05 21:59:19 -07:00
|
|
|
NS_ASSERTION(result, "value should always be non-empty when state set");
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// Frame list manipulation routines
|
|
|
|
|
2014-02-17 23:47:48 -08:00
|
|
|
nsresult
|
2011-08-24 13:54:30 -07:00
|
|
|
nsBlockFrame::AppendFrames(ChildListID aListID,
|
2009-07-30 10:23:32 -07:00
|
|
|
nsFrameList& aFrameList)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-07-30 10:23:32 -07:00
|
|
|
if (aFrameList.IsEmpty()) {
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2011-08-24 13:54:30 -07:00
|
|
|
if (aListID != kPrincipalList) {
|
|
|
|
if (kAbsoluteList == aListID) {
|
2011-04-29 16:02:33 -07:00
|
|
|
return nsContainerFrame::AppendFrames(aListID, aFrameList);
|
2011-06-01 13:18:15 -07:00
|
|
|
}
|
2011-08-24 13:54:30 -07:00
|
|
|
else if (kFloatList == aListID) {
|
2012-07-30 07:20:58 -07:00
|
|
|
mFloats.AppendFrames(nullptr, aFrameList);
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
NS_ERROR("unexpected child list");
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Find the proper last-child for where the append should go
|
2012-02-17 17:34:20 -08:00
|
|
|
nsIFrame* lastKid = mFrames.LastChild();
|
2012-07-30 07:20:58 -07:00
|
|
|
NS_ASSERTION((mLines.empty() ? nullptr : mLines.back()->LastChild()) ==
|
2012-02-17 17:34:20 -08:00
|
|
|
lastKid, "out-of-sync mLines / mFrames");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Add frames after the last child
|
|
|
|
#ifdef NOISY_REFLOW_REASON
|
|
|
|
ListTag(stdout);
|
|
|
|
printf(": append ");
|
|
|
|
nsFrame::ListTag(stdout, aFrameList);
|
|
|
|
if (lastKid) {
|
|
|
|
printf(" after ");
|
|
|
|
nsFrame::ListTag(stdout, lastKid);
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
#endif
|
2009-07-30 10:23:32 -07:00
|
|
|
|
2013-03-23 13:10:34 -07:00
|
|
|
AddFrames(aFrameList, lastKid);
|
2009-07-30 10:23:32 -07:00
|
|
|
PresContext()->PresShell()->
|
|
|
|
FrameNeedsReflow(this, nsIPresShell::eTreeChange,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN); // XXX sufficient?
|
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2014-02-17 23:47:48 -08:00
|
|
|
nsresult
|
2011-08-24 13:54:30 -07:00
|
|
|
nsBlockFrame::InsertFrames(ChildListID aListID,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIFrame* aPrevFrame,
|
2009-07-30 10:23:32 -07:00
|
|
|
nsFrameList& aFrameList)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
NS_ASSERTION(!aPrevFrame || aPrevFrame->GetParent() == this,
|
|
|
|
"inserting after sibling frame with different parent");
|
|
|
|
|
2011-08-24 13:54:30 -07:00
|
|
|
if (aListID != kPrincipalList) {
|
|
|
|
if (kAbsoluteList == aListID) {
|
2011-04-29 16:02:33 -07:00
|
|
|
return nsContainerFrame::InsertFrames(aListID, aPrevFrame, aFrameList);
|
2011-06-01 13:18:15 -07:00
|
|
|
}
|
2011-08-24 13:54:30 -07:00
|
|
|
else if (kFloatList == aListID) {
|
2007-03-22 10:30:00 -07:00
|
|
|
mFloats.InsertFrames(this, aPrevFrame, aFrameList);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
#ifdef IBMBIDI
|
2011-08-24 13:54:30 -07:00
|
|
|
else if (kNoReflowPrincipalList == aListID) {}
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif // IBMBIDI
|
|
|
|
else {
|
|
|
|
NS_ERROR("unexpected child list");
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef NOISY_REFLOW_REASON
|
|
|
|
ListTag(stdout);
|
|
|
|
printf(": insert ");
|
|
|
|
nsFrame::ListTag(stdout, aFrameList);
|
|
|
|
if (aPrevFrame) {
|
|
|
|
printf(" after ");
|
|
|
|
nsFrame::ListTag(stdout, aPrevFrame);
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
#endif
|
2013-03-23 13:10:34 -07:00
|
|
|
|
|
|
|
AddFrames(aFrameList, aPrevFrame);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef IBMBIDI
|
2011-08-24 13:54:30 -07:00
|
|
|
if (aListID != kNoReflowPrincipalList)
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif // IBMBIDI
|
2007-03-30 14:11:41 -07:00
|
|
|
PresContext()->PresShell()->
|
2007-05-06 12:16:51 -07:00
|
|
|
FrameNeedsReflow(this, nsIPresShell::eTreeChange,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN); // XXX sufficient?
|
2009-07-30 10:23:32 -07:00
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool
|
2007-03-22 10:30:00 -07:00
|
|
|
ShouldPutNextSiblingOnNewLine(nsIFrame* aLastFrame)
|
|
|
|
{
|
|
|
|
nsIAtom* type = aLastFrame->GetType();
|
2013-02-18 17:44:14 -08:00
|
|
|
if (type == nsGkAtoms::brFrame) {
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2013-02-18 17:44:14 -08:00
|
|
|
}
|
2014-02-17 14:46:40 -08:00
|
|
|
// XXX the TEXT_OFFSETS_NEED_FIXING check is a wallpaper for bug 822910.
|
2013-02-18 17:44:14 -08:00
|
|
|
if (type == nsGkAtoms::textFrame &&
|
2014-02-17 14:46:40 -08:00
|
|
|
!(aLastFrame->GetStateBits() & TEXT_OFFSETS_NEED_FIXING)) {
|
2014-01-02 13:22:12 -08:00
|
|
|
return aLastFrame->HasSignificantTerminalNewline();
|
2013-02-18 17:44:14 -08:00
|
|
|
}
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-03-23 13:10:34 -07:00
|
|
|
void
|
2009-09-29 12:47:05 -07:00
|
|
|
nsBlockFrame::AddFrames(nsFrameList& aFrameList, nsIFrame* aPrevSibling)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
// Clear our line cursor, since our lines may change.
|
|
|
|
ClearLineCursor();
|
|
|
|
|
2009-07-28 05:51:10 -07:00
|
|
|
if (aFrameList.IsEmpty()) {
|
2013-03-23 13:10:34 -07:00
|
|
|
return;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// If we're inserting at the beginning of our list and we have an
|
|
|
|
// inside bullet, insert after that bullet.
|
2012-03-07 17:57:37 -08:00
|
|
|
if (!aPrevSibling && HasInsideBullet()) {
|
|
|
|
aPrevSibling = GetInsideBullet();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Attempt to find the line that contains the previous sibling
|
2012-03-07 17:57:37 -08:00
|
|
|
FrameLines* overflowLines;
|
2011-08-03 08:55:00 -07:00
|
|
|
nsLineList* lineList = &mLines;
|
|
|
|
nsLineList::iterator prevSibLine = lineList->end();
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t prevSiblingIndex = -1;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (aPrevSibling) {
|
|
|
|
// 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,
|
|
|
|
// which is appending content.
|
|
|
|
|
|
|
|
// Find the line that contains the previous sibling
|
2011-08-03 08:55:00 -07:00
|
|
|
if (!nsLineBox::RFindLineContaining(aPrevSibling, lineList->begin(),
|
|
|
|
prevSibLine, mFrames.LastChild(),
|
|
|
|
&prevSiblingIndex)) {
|
|
|
|
// Not in mLines - try overflow lines.
|
2012-03-07 17:57:37 -08:00
|
|
|
overflowLines = GetOverflowLines();
|
2012-07-30 07:20:58 -07:00
|
|
|
lineList = overflowLines ? &overflowLines->mLines : nullptr;
|
2012-03-07 17:57:37 -08:00
|
|
|
if (overflowLines) {
|
|
|
|
prevSibLine = overflowLines->mLines.end();
|
2011-08-03 08:55:00 -07:00
|
|
|
prevSiblingIndex = -1;
|
|
|
|
if (!nsLineBox::RFindLineContaining(aPrevSibling, lineList->begin(),
|
|
|
|
prevSibLine,
|
2012-03-07 17:57:37 -08:00
|
|
|
overflowLines->mFrames.LastChild(),
|
2011-08-03 08:55:00 -07:00
|
|
|
&prevSiblingIndex)) {
|
2012-07-30 07:20:58 -07:00
|
|
|
lineList = nullptr;
|
2011-08-03 08:55:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!lineList) {
|
|
|
|
// Note: defensive code! RFindLineContaining must not return
|
|
|
|
// false in this case, so if it does...
|
|
|
|
NS_NOTREACHED("prev sibling not in line list");
|
|
|
|
lineList = &mLines;
|
2012-07-30 07:20:58 -07:00
|
|
|
aPrevSibling = nullptr;
|
2011-08-03 08:55:00 -07:00
|
|
|
prevSibLine = lineList->end();
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Find the frame following aPrevSibling so that we can join up the
|
|
|
|
// two lists of frames.
|
|
|
|
if (aPrevSibling) {
|
|
|
|
// Split line containing aPrevSibling in two if the insertion
|
|
|
|
// point is somewhere in the middle of the line.
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t rem = prevSibLine->GetChildCount() - prevSiblingIndex - 1;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (rem) {
|
|
|
|
// Split the line in two where the frame(s) are being inserted.
|
2012-03-10 18:32:27 -08:00
|
|
|
nsLineBox* line = NewLineBox(prevSibLine, aPrevSibling->GetNextSibling(), rem);
|
2011-08-03 08:55:00 -07:00
|
|
|
lineList->after_insert(prevSibLine, line);
|
2007-11-08 22:55:32 -08: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.
|
2012-07-17 12:56:04 -07:00
|
|
|
MarkLineDirty(prevSibLine, lineList);
|
2007-11-08 22:55:32 -08:00
|
|
|
// The new line will also need its textruns recomputed because of the
|
|
|
|
// frame changes.
|
2009-05-19 08:54:42 -07:00
|
|
|
line->MarkDirty();
|
2011-10-17 07:59:28 -07:00
|
|
|
line->SetInvalidateTextRuns(true);
|
2007-09-17 20:00:16 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2011-08-03 08:55:00 -07:00
|
|
|
else if (! lineList->empty()) {
|
|
|
|
lineList->front()->MarkDirty();
|
2011-10-17 07:59:28 -07:00
|
|
|
lineList->front()->SetInvalidateTextRuns(true);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2012-03-07 17:57:37 -08:00
|
|
|
nsFrameList& frames = lineList == &mLines ? mFrames : overflowLines->mFrames;
|
2009-09-29 12:47:05 -07:00
|
|
|
const nsFrameList::Slice& newFrames =
|
2012-07-30 07:20:58 -07:00
|
|
|
frames.InsertFrames(nullptr, aPrevSibling, aFrameList);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Walk through the new frames being added and update the line data
|
|
|
|
// structures to fit.
|
2009-09-29 12:47:05 -07:00
|
|
|
for (nsFrameList::Enumerator e(newFrames); !e.AtEnd(); e.Next()) {
|
|
|
|
nsIFrame* newFrame = e.get();
|
|
|
|
NS_ASSERTION(!aPrevSibling || aPrevSibling->GetNextSibling() == newFrame,
|
|
|
|
"Unexpected aPrevSibling");
|
2007-07-23 18:42:23 -07:00
|
|
|
NS_ASSERTION(newFrame->GetType() != nsGkAtoms::placeholderFrame ||
|
2012-08-02 04:38:50 -07:00
|
|
|
(!newFrame->IsAbsolutelyPositioned() &&
|
2012-08-02 04:38:49 -07:00
|
|
|
!newFrame->IsFloating()),
|
2007-07-23 18:42:23 -07:00
|
|
|
"Placeholders should not float or be positioned");
|
|
|
|
|
2012-08-02 04:38:51 -07:00
|
|
|
bool isBlock = newFrame->IsBlockOutside();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// If the frame is a block frame, or if there is no previous line or if the
|
|
|
|
// previous line is a block line we need to make a new line. We also make
|
2009-08-31 11:25:35 -07: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.
|
2011-08-03 08:55:00 -07:00
|
|
|
if (isBlock || prevSibLine == lineList->end() || prevSibLine->IsBlock() ||
|
2007-03-22 10:30:00 -07:00
|
|
|
(aPrevSibling && ShouldPutNextSiblingOnNewLine(aPrevSibling))) {
|
|
|
|
// Create a new line for the frame and add its line to the line
|
|
|
|
// list.
|
2012-03-10 18:32:27 -08:00
|
|
|
nsLineBox* line = NewLineBox(newFrame, isBlock);
|
2011-08-03 08:55:00 -07:00
|
|
|
if (prevSibLine != lineList->end()) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// Append new line after prevSibLine
|
2011-08-03 08:55:00 -07:00
|
|
|
lineList->after_insert(prevSibLine, line);
|
2007-03-22 10:30:00 -07:00
|
|
|
++prevSibLine;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// New line is going before the other lines
|
2011-08-03 08:55:00 -07:00
|
|
|
lineList->push_front(line);
|
|
|
|
prevSibLine = lineList->begin();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2012-03-10 18:32:27 -08:00
|
|
|
prevSibLine->NoteFrameAdded(newFrame);
|
2007-11-08 22:55:32 -08: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.
|
2012-07-17 12:56:04 -07:00
|
|
|
MarkLineDirty(prevSibLine, lineList);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
aPrevSibling = newFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2013-03-23 13:10:34 -07:00
|
|
|
MOZ_ASSERT(aFrameList.IsEmpty());
|
2011-10-17 07:59:28 -07:00
|
|
|
VerifyLines(true);
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-02-27 15:05:45 -08:00
|
|
|
void
|
2013-03-15 15:32:35 -07:00
|
|
|
nsBlockFrame::RemoveFloatFromFloatCache(nsIFrame* aFloat)
|
2013-02-27 15:05:45 -08:00
|
|
|
{
|
2007-03-22 10:30:00 -07:00
|
|
|
// Find which line contains the float, so we can update
|
|
|
|
// the float cache.
|
|
|
|
line_iterator line = begin_lines(), line_end = end_lines();
|
|
|
|
for ( ; line != line_end; ++line) {
|
|
|
|
if (line->IsInline() && line->RemoveFloat(aFloat)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-03-15 15:32:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBlockFrame::RemoveFloat(nsIFrame* aFloat)
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
// Floats live in mFloats, or in the PushedFloat or OverflowOutOfFlows
|
|
|
|
// frame list properties.
|
|
|
|
if (!mFloats.ContainsFrame(aFloat)) {
|
|
|
|
MOZ_ASSERT((GetOverflowOutOfFlows() &&
|
|
|
|
GetOverflowOutOfFlows()->ContainsFrame(aFloat)) ||
|
|
|
|
(GetPushedFloats() &&
|
|
|
|
GetPushedFloats()->ContainsFrame(aFloat)),
|
|
|
|
"aFloat is not our child or on an unexpected frame list");
|
|
|
|
}
|
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-02-27 15:05:45 -08:00
|
|
|
if (mFloats.StartRemoveFrame(aFloat)) {
|
|
|
|
return;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-03-15 15:32:35 -07:00
|
|
|
nsFrameList* list = GetPushedFloats();
|
|
|
|
if (list && list->ContinueRemoveFrame(aFloat)) {
|
|
|
|
#if 0
|
|
|
|
// XXXmats not yet - need to investigate nsBlockReflowState::mPushedFloats
|
|
|
|
// first so we don't leave it pointing to a deleted list.
|
|
|
|
if (list->IsEmpty()) {
|
|
|
|
delete RemovePushedFloats();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsAutoOOFFrameList oofs(this);
|
2013-02-27 15:05:45 -08:00
|
|
|
if (oofs.mList.ContinueRemoveFrame(aFloat)) {
|
|
|
|
return;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-04 16:39:54 -08:00
|
|
|
static void MarkSameFloatManagerLinesDirty(nsBlockFrame* aBlock)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-01-04 16:39:54 -08:00
|
|
|
nsBlockFrame* blockWithFloatMgr = aBlock;
|
|
|
|
while (!(blockWithFloatMgr->GetStateBits() & NS_BLOCK_FLOAT_MGR)) {
|
|
|
|
nsBlockFrame* bf = nsLayoutUtils::GetAsBlock(blockWithFloatMgr->GetParent());
|
2008-07-13 15:10:23 -07:00
|
|
|
if (!bf) {
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
}
|
2009-01-04 16:39:54 -08:00
|
|
|
blockWithFloatMgr = bf;
|
2007-03-22 10:30:00 -07: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-04 16:39:54 -08:00
|
|
|
MarkAllDescendantLinesDirty(blockWithFloatMgr);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-10-17 07:59:28 -07:00
|
|
|
* Returns true if aFrame is a block that has one or more float children.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool BlockHasAnyFloats(nsIFrame* aFrame)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-07-13 15:10:23 -07:00
|
|
|
nsBlockFrame* block = nsLayoutUtils::GetAsBlock(aFrame);
|
|
|
|
if (!block)
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2011-08-24 13:54:30 -07:00
|
|
|
if (block->GetFirstChild(nsIFrame::kFloatList))
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsLineList::iterator line = block->begin_lines();
|
|
|
|
nsLineList::iterator endLine = block->end_lines();
|
|
|
|
while (line != endLine) {
|
|
|
|
if (line->IsBlock() && BlockHasAnyFloats(line->mFirstChild))
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2007-03-22 10:30:00 -07:00
|
|
|
++line;
|
|
|
|
}
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2014-02-17 23:47:48 -08:00
|
|
|
nsresult
|
2011-08-24 13:54:30 -07:00
|
|
|
nsBlockFrame::RemoveFrame(ChildListID aListID,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIFrame* aOldFrame)
|
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
#ifdef NOISY_REFLOW_REASON
|
|
|
|
ListTag(stdout);
|
|
|
|
printf(": remove ");
|
|
|
|
nsFrame::ListTag(stdout, aOldFrame);
|
|
|
|
printf("\n");
|
|
|
|
#endif
|
|
|
|
|
2011-08-24 13:54:30 -07:00
|
|
|
if (aListID == kPrincipalList) {
|
2011-09-28 23:19:26 -07:00
|
|
|
bool hasFloats = BlockHasAnyFloats(aOldFrame);
|
2008-12-02 17:27:19 -08:00
|
|
|
rv = DoRemoveFrame(aOldFrame, REMOVE_FIXED_CONTINUATIONS);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (hasFloats) {
|
2009-01-04 16:39:54 -08:00
|
|
|
MarkSameFloatManagerLinesDirty(this);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
2011-08-24 13:54:30 -07:00
|
|
|
else if (kAbsoluteList == aListID) {
|
2011-04-29 16:02:33 -07:00
|
|
|
nsContainerFrame::RemoveFrame(aListID, aOldFrame);
|
2011-06-01 13:18:15 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2011-08-24 13:54:30 -07:00
|
|
|
else if (kFloatList == aListID) {
|
2009-08-31 11:25:37 -07:00
|
|
|
// Make sure to mark affected lines dirty for the float frame
|
2007-08-17 17:06:46 -07:00
|
|
|
// we are removing; this way is a bit messy, but so is the rest of the code.
|
|
|
|
// See bug 390762.
|
2009-08-31 11:25:37 -07:00
|
|
|
NS_ASSERTION(!aOldFrame->GetPrevContinuation(),
|
2010-08-05 21:59:20 -07:00
|
|
|
"RemoveFrame should not be called on pushed floats.");
|
2009-08-31 11:25:37 -07:00
|
|
|
for (nsIFrame* f = aOldFrame;
|
|
|
|
f && !(f->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER);
|
|
|
|
f = f->GetNextContinuation()) {
|
|
|
|
MarkSameFloatManagerLinesDirty(static_cast<nsBlockFrame*>(f->GetParent()));
|
|
|
|
}
|
|
|
|
DoRemoveOutOfFlowFrame(aOldFrame);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
#ifdef IBMBIDI
|
2011-08-24 13:54:30 -07:00
|
|
|
else if (kNoReflowPrincipalList == aListID) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// Skip the call to |FrameNeedsReflow| below by returning now.
|
2008-12-02 17:27:19 -08:00
|
|
|
return DoRemoveFrame(aOldFrame, REMOVE_FIXED_CONTINUATIONS);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
#endif // IBMBIDI
|
|
|
|
else {
|
|
|
|
NS_ERROR("unexpected child list");
|
|
|
|
rv = NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2007-03-30 14:11:41 -07:00
|
|
|
PresContext()->PresShell()->
|
2007-05-06 12:16:51 -07:00
|
|
|
FrameNeedsReflow(this, nsIPresShell::eTreeChange,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN); // XXX sufficient?
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBlockFrame::DoRemoveOutOfFlowFrame(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
// The containing block is always the parent of aFrame.
|
|
|
|
nsBlockFrame* block = (nsBlockFrame*)aFrame->GetParent();
|
2007-07-25 21:03:29 -07:00
|
|
|
|
|
|
|
// Remove aFrame from the appropriate list.
|
2012-08-02 04:38:50 -07:00
|
|
|
if (aFrame->IsAbsolutelyPositioned()) {
|
2007-10-01 22:57:45 -07:00
|
|
|
// This also deletes the next-in-flows
|
2011-04-29 16:02:33 -07:00
|
|
|
block->GetAbsoluteContainingBlock()->RemoveFrame(block,
|
|
|
|
kAbsoluteList,
|
|
|
|
aFrame);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
else {
|
2013-02-27 15:05:45 -08:00
|
|
|
// First remove aFrame's next-in-flows.
|
2009-08-31 11:25:36 -07:00
|
|
|
nsIFrame* nif = aFrame->GetNextInFlow();
|
|
|
|
if (nif) {
|
|
|
|
static_cast<nsContainerFrame*>(nif->GetParent())
|
2014-02-06 14:07:47 -08:00
|
|
|
->DeleteNextInFlowChild(nif, false);
|
2007-10-01 22:57:45 -07:00
|
|
|
}
|
2013-02-27 15:05:45 -08:00
|
|
|
// Now remove aFrame from its child list and Destroy it.
|
2013-03-15 15:32:35 -07:00
|
|
|
block->RemoveFloatFromFloatCache(aFrame);
|
2007-03-22 10:30:00 -07:00
|
|
|
block->RemoveFloat(aFrame);
|
2013-02-27 15:05:45 -08:00
|
|
|
aFrame->Destroy();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This helps us iterate over the list of all normal + overflow lines
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
nsBlockFrame::TryAllLines(nsLineList::iterator* aIterator,
|
2007-10-07 10:32:07 -07:00
|
|
|
nsLineList::iterator* aStartIterator,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsLineList::iterator* aEndIterator,
|
2012-03-07 17:57:37 -08:00
|
|
|
bool* aInOverflowLines,
|
|
|
|
FrameLines** aOverflowLines)
|
|
|
|
{
|
2007-03-22 10:30:00 -07:00
|
|
|
if (*aIterator == *aEndIterator) {
|
|
|
|
if (!*aInOverflowLines) {
|
|
|
|
// Try the overflow lines
|
2012-03-07 17:57:37 -08:00
|
|
|
*aInOverflowLines = true;
|
|
|
|
FrameLines* lines = GetOverflowLines();
|
|
|
|
if (lines) {
|
|
|
|
*aStartIterator = lines->mLines.begin();
|
2007-10-07 10:32:07 -07:00
|
|
|
*aIterator = *aStartIterator;
|
2012-03-07 17:57:37 -08:00
|
|
|
*aEndIterator = lines->mLines.end();
|
|
|
|
*aOverflowLines = lines;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-07 17:57:37 -08:00
|
|
|
nsBlockInFlowLineIterator::nsBlockInFlowLineIterator(nsBlockFrame* aFrame,
|
|
|
|
line_iterator aLine)
|
2012-07-20 11:27:03 -07:00
|
|
|
: mFrame(aFrame), mLine(aLine), mLineList(&aFrame->mLines)
|
2012-03-07 17:57:37 -08:00
|
|
|
{
|
|
|
|
// This will assert if aLine isn't in mLines of aFrame:
|
|
|
|
DebugOnly<bool> check = aLine == mFrame->begin_lines();
|
|
|
|
}
|
|
|
|
|
2007-08-22 02:08:13 -07:00
|
|
|
nsBlockInFlowLineIterator::nsBlockInFlowLineIterator(nsBlockFrame* aFrame,
|
2011-09-28 23:19:26 -07:00
|
|
|
line_iterator aLine, bool aInOverflow)
|
2012-07-20 11:27:03 -07:00
|
|
|
: mFrame(aFrame), mLine(aLine),
|
|
|
|
mLineList(aInOverflow ? &aFrame->GetOverflowLines()->mLines
|
|
|
|
: &aFrame->mLines)
|
2007-08-22 02:08:13 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-02-23 23:31:29 -08:00
|
|
|
nsBlockInFlowLineIterator::nsBlockInFlowLineIterator(nsBlockFrame* aFrame,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool* aFoundValidLine)
|
2012-07-20 11:27:03 -07:00
|
|
|
: mFrame(aFrame), mLineList(&aFrame->mLines)
|
2008-02-23 23:31:29 -08:00
|
|
|
{
|
|
|
|
mLine = aFrame->begin_lines();
|
|
|
|
*aFoundValidLine = FindValidLine();
|
|
|
|
}
|
|
|
|
|
2008-02-27 01:53:48 -08:00
|
|
|
static nsIFrame*
|
|
|
|
FindChildContaining(nsBlockFrame* aFrame, nsIFrame* aFindFrame)
|
|
|
|
{
|
2009-02-19 09:48:37 -08:00
|
|
|
NS_ASSERTION(aFrame, "must have frame");
|
2008-02-27 01:53:48 -08:00
|
|
|
nsIFrame* child;
|
2011-10-17 07:59:28 -07:00
|
|
|
while (true) {
|
2008-02-27 01:53:48 -08:00
|
|
|
nsIFrame* block = aFrame;
|
2009-02-19 09:48:37 -08:00
|
|
|
do {
|
2008-02-27 01:53:48 -08:00
|
|
|
child = nsLayoutUtils::FindChildContainingDescendant(block, aFindFrame);
|
|
|
|
if (child)
|
|
|
|
break;
|
|
|
|
block = block->GetNextContinuation();
|
2009-02-19 09:48:37 -08:00
|
|
|
} while (block);
|
2008-02-27 01:53:48 -08:00
|
|
|
if (!child)
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2008-02-27 01:53:48 -08:00
|
|
|
if (!(child->GetStateBits() & NS_FRAME_OUT_OF_FLOW))
|
|
|
|
break;
|
|
|
|
aFindFrame = aFrame->PresContext()->FrameManager()->GetPlaceholderFrameFor(child);
|
|
|
|
}
|
|
|
|
|
|
|
|
return child;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsBlockInFlowLineIterator::nsBlockInFlowLineIterator(nsBlockFrame* aFrame,
|
2011-09-28 23:19:26 -07:00
|
|
|
nsIFrame* aFindFrame, bool* aFoundValidLine)
|
2012-07-20 11:27:03 -07:00
|
|
|
: mFrame(aFrame), mLineList(&aFrame->mLines)
|
2008-02-27 01:53:48 -08:00
|
|
|
{
|
2011-10-17 07:59:28 -07:00
|
|
|
*aFoundValidLine = false;
|
2008-02-27 01:53:48 -08:00
|
|
|
|
|
|
|
nsIFrame* child = FindChildContaining(aFrame, aFindFrame);
|
|
|
|
if (!child)
|
|
|
|
return;
|
|
|
|
|
2010-09-08 17:15:24 -07:00
|
|
|
// Try to use the cursor if it exists, otherwise fall back to the first line
|
2012-05-03 17:14:01 -07:00
|
|
|
nsLineBox* cursor = aFrame->GetLineCursor();
|
2010-09-08 17:15:24 -07:00
|
|
|
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 12:09:08 -07: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-08 17:15:24 -07:00
|
|
|
if (line != line_end) {
|
|
|
|
if (line->Contains(child)) {
|
2011-10-17 07:59:28 -07:00
|
|
|
*aFoundValidLine = true;
|
2010-09-08 17:15:24 -07:00
|
|
|
mLine = line;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
++line;
|
|
|
|
}
|
|
|
|
if (rline != rline_end) {
|
|
|
|
if (rline->Contains(child)) {
|
2011-10-17 07:59:28 -07:00
|
|
|
*aFoundValidLine = true;
|
2010-09-08 17:15:24 -07:00
|
|
|
mLine = rline;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
++rline;
|
|
|
|
}
|
|
|
|
}
|
2010-09-17 12:09:08 -07:00
|
|
|
// Didn't find the line
|
2010-09-08 17:15:24 -07: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 01:53:48 -08:00
|
|
|
if (!FindValidLine())
|
|
|
|
return;
|
|
|
|
|
|
|
|
do {
|
|
|
|
if (mLine->Contains(child)) {
|
2011-10-17 07:59:28 -07:00
|
|
|
*aFoundValidLine = true;
|
2008-02-27 01:53:48 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
} while (Next());
|
|
|
|
}
|
|
|
|
|
2008-04-11 22:32:49 -07:00
|
|
|
nsBlockFrame::line_iterator
|
|
|
|
nsBlockInFlowLineIterator::End()
|
|
|
|
{
|
2012-07-20 11:27:03 -07:00
|
|
|
return mLineList->end();
|
2008-04-11 22:32:49 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2008-01-29 15:39:39 -08:00
|
|
|
nsBlockInFlowLineIterator::IsLastLineInList()
|
|
|
|
{
|
2008-04-11 22:32:49 -07:00
|
|
|
line_iterator end = End();
|
2008-01-29 15:39:39 -08:00
|
|
|
return mLine != end && mLine.next() == end;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2007-08-22 02:08:13 -07:00
|
|
|
nsBlockInFlowLineIterator::Next()
|
|
|
|
{
|
|
|
|
++mLine;
|
2008-02-23 23:31:29 -08:00
|
|
|
return FindValidLine();
|
2007-08-22 02:08:13 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2007-08-22 02:08:13 -07:00
|
|
|
nsBlockInFlowLineIterator::Prev()
|
|
|
|
{
|
2012-07-20 11:27:03 -07:00
|
|
|
line_iterator begin = mLineList->begin();
|
2007-08-22 02:08:13 -07:00
|
|
|
if (mLine != begin) {
|
|
|
|
--mLine;
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2007-08-22 02:08:13 -07:00
|
|
|
}
|
2012-07-20 11:27:03 -07:00
|
|
|
bool currentlyInOverflowLines = GetInOverflow();
|
2011-10-17 07:59:28 -07:00
|
|
|
while (true) {
|
2007-08-22 02:08:13 -07:00
|
|
|
if (currentlyInOverflowLines) {
|
2012-07-20 11:27:03 -07:00
|
|
|
mLineList = &mFrame->mLines;
|
|
|
|
mLine = mLineList->end();
|
|
|
|
if (mLine != mLineList->begin()) {
|
2007-08-22 02:08:13 -07:00
|
|
|
--mLine;
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2007-08-22 02:08:13 -07:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
mFrame = static_cast<nsBlockFrame*>(mFrame->GetPrevInFlow());
|
|
|
|
if (!mFrame)
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2012-03-07 17:57:37 -08:00
|
|
|
nsBlockFrame::FrameLines* overflowLines = mFrame->GetOverflowLines();
|
2012-07-20 11:27:03 -07:00
|
|
|
if (overflowLines) {
|
|
|
|
mLineList = &overflowLines->mLines;
|
|
|
|
mLine = mLineList->end();
|
|
|
|
NS_ASSERTION(mLine != mLineList->begin(), "empty overflow line list?");
|
2007-08-22 02:08:13 -07:00
|
|
|
--mLine;
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2007-08-22 02:08:13 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
currentlyInOverflowLines = !currentlyInOverflowLines;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2008-02-23 23:31:29 -08:00
|
|
|
nsBlockInFlowLineIterator::FindValidLine()
|
|
|
|
{
|
2012-07-20 11:27:03 -07:00
|
|
|
line_iterator end = mLineList->end();
|
2008-02-23 23:31:29 -08:00
|
|
|
if (mLine != end)
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2012-07-20 11:27:03 -07:00
|
|
|
bool currentlyInOverflowLines = GetInOverflow();
|
2011-10-17 07:59:28 -07:00
|
|
|
while (true) {
|
2008-02-23 23:31:29 -08:00
|
|
|
if (currentlyInOverflowLines) {
|
|
|
|
mFrame = static_cast<nsBlockFrame*>(mFrame->GetNextInFlow());
|
|
|
|
if (!mFrame)
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2012-07-20 11:27:03 -07:00
|
|
|
mLineList = &mFrame->mLines;
|
|
|
|
mLine = mLineList->begin();
|
|
|
|
if (mLine != mLineList->end())
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2008-02-23 23:31:29 -08:00
|
|
|
} else {
|
2012-03-07 17:57:37 -08:00
|
|
|
nsBlockFrame::FrameLines* overflowLines = mFrame->GetOverflowLines();
|
2012-07-20 11:27:03 -07:00
|
|
|
if (overflowLines) {
|
|
|
|
mLineList = &overflowLines->mLines;
|
|
|
|
mLine = mLineList->begin();
|
|
|
|
NS_ASSERTION(mLine != mLineList->end(), "empty overflow line list?");
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2008-02-23 23:31:29 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
currentlyInOverflowLines = !currentlyInOverflowLines;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-31 11:25:35 -07:00
|
|
|
static nsresult RemoveBlockChild(nsIFrame* aFrame,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aRemoveOnlyFluidContinuations)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
if (!aFrame)
|
|
|
|
return NS_OK;
|
|
|
|
|
2008-07-13 15:10:23 -07:00
|
|
|
nsBlockFrame* nextBlock = nsLayoutUtils::GetAsBlock(aFrame->GetParent());
|
|
|
|
NS_ASSERTION(nextBlock,
|
2007-03-22 10:30:00 -07:00
|
|
|
"Our child's continuation's parent is not a block?");
|
2008-12-02 17:27:19 -08:00
|
|
|
return nextBlock->DoRemoveFrame(aFrame,
|
|
|
|
(aRemoveOnlyFluidContinuations ? 0 : nsBlockFrame::REMOVE_FIXED_CONTINUATIONS));
|
2007-03-22 10:30:00 -07: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
|
|
|
|
// aDeletedFrame->GetNextContinuation, then locate the line containing
|
|
|
|
// aDeletedFrame and remove aDeletedFrame from that line. But here we
|
|
|
|
// start by locating aDeletedFrame and then scanning from that point
|
|
|
|
// on looking for continuations.
|
|
|
|
nsresult
|
2012-08-22 08:56:38 -07:00
|
|
|
nsBlockFrame::DoRemoveFrame(nsIFrame* aDeletedFrame, uint32_t aFlags)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
// Clear our line cursor, since our lines may change.
|
|
|
|
ClearLineCursor();
|
2007-10-01 22:57:45 -07:00
|
|
|
|
2009-08-31 11:25:36 -07: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 {
|
2014-02-06 14:07:47 -08:00
|
|
|
nsContainerFrame::DeleteNextInFlowChild(aDeletedFrame,
|
2009-08-31 11:25:36 -07:00
|
|
|
(aFlags & FRAMES_ARE_EMPTY) != 0);
|
|
|
|
}
|
2007-10-10 15:09:53 -07:00
|
|
|
return NS_OK;
|
2007-10-01 22:57:45 -07:00
|
|
|
}
|
|
|
|
|
2009-10-02 09:27:37 -07:00
|
|
|
// Find the line that contains deletedFrame
|
2007-10-07 10:32:07 -07:00
|
|
|
nsLineList::iterator line_start = mLines.begin(),
|
2007-03-22 10:30:00 -07:00
|
|
|
line_end = mLines.end();
|
2007-10-07 10:32:07 -07:00
|
|
|
nsLineList::iterator line = line_start;
|
2012-07-30 07:20:58 -07:00
|
|
|
FrameLines* overflowLines = nullptr;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool searchingOverflowList = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
// Make sure we look in the overflow lines even if the normal line
|
|
|
|
// list is empty
|
2012-03-07 17:57:37 -08:00
|
|
|
TryAllLines(&line, &line_start, &line_end, &searchingOverflowList,
|
|
|
|
&overflowLines);
|
2007-03-22 10:30:00 -07:00
|
|
|
while (line != line_end) {
|
2009-10-02 09:27:37 -07:00
|
|
|
if (line->Contains(aDeletedFrame)) {
|
|
|
|
break;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
++line;
|
2012-03-07 17:57:37 -08:00
|
|
|
TryAllLines(&line, &line_start, &line_end, &searchingOverflowList,
|
|
|
|
&overflowLines);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2009-10-02 09:27:37 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (line == line_end) {
|
|
|
|
NS_ERROR("can't find deleted frame in lines");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2007-09-17 20:00:16 -07:00
|
|
|
|
2008-12-02 17:27:19 -08:00
|
|
|
if (!(aFlags & FRAMES_ARE_EMPTY)) {
|
|
|
|
if (line != line_start) {
|
2009-05-19 08:54:42 -07:00
|
|
|
line.prev()->MarkDirty();
|
2011-10-17 07:59:28 -07:00
|
|
|
line.prev()->SetInvalidateTextRuns(true);
|
2008-12-02 17:27:19 -08:00
|
|
|
}
|
|
|
|
else if (searchingOverflowList && !mLines.empty()) {
|
2009-05-19 08:54:42 -07:00
|
|
|
mLines.back()->MarkDirty();
|
2011-10-17 07:59:28 -07:00
|
|
|
mLines.back()->SetInvalidateTextRuns(true);
|
2008-12-02 17:27:19 -08:00
|
|
|
}
|
2007-10-07 10:32:07 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-03-07 17:57:37 -08:00
|
|
|
while (line != line_end && aDeletedFrame) {
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ASSERTION(this == aDeletedFrame->GetParent(), "messed up delete code");
|
|
|
|
NS_ASSERTION(line->Contains(aDeletedFrame), "frame not in line");
|
|
|
|
|
2008-12-02 17:27:19 -08:00
|
|
|
if (!(aFlags & FRAMES_ARE_EMPTY)) {
|
2009-05-19 08:54:42 -07:00
|
|
|
line->MarkDirty();
|
2011-10-17 07:59:28 -07:00
|
|
|
line->SetInvalidateTextRuns(true);
|
2008-12-02 17:27:19 -08:00
|
|
|
}
|
2007-09-17 20:00:16 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// If the frame being deleted is the last one on the line then
|
|
|
|
// optimize away the line->Contains(next-in-flow) call below.
|
2012-02-17 17:34:20 -08:00
|
|
|
bool isLastFrameOnLine = 1 == line->GetChildCount();
|
|
|
|
if (!isLastFrameOnLine) {
|
|
|
|
line_iterator next = line.next();
|
|
|
|
nsIFrame* lastFrame = next != line_end ?
|
|
|
|
next->mFirstChild->GetPrevSibling() :
|
2012-03-07 17:57:37 -08:00
|
|
|
(searchingOverflowList ? overflowLines->mFrames.LastChild() :
|
|
|
|
mFrames.LastChild());
|
2012-02-17 17:34:20 -08:00
|
|
|
NS_ASSERTION(next == line_end || lastFrame == line->LastChild(),
|
|
|
|
"unexpected line frames");
|
|
|
|
isLastFrameOnLine = lastFrame == aDeletedFrame;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Remove aDeletedFrame from the line
|
|
|
|
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.
|
2012-03-07 17:57:37 -08:00
|
|
|
line->mFirstChild = aDeletedFrame->GetNextSibling();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Hmm, this won't do anything if we're removing a frame in the first
|
|
|
|
// overflow line... Hopefully doesn't matter
|
|
|
|
--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;
|
|
|
|
|
|
|
|
// Take aDeletedFrame out of the sibling list. Note that
|
2012-07-30 07:20:58 -07:00
|
|
|
// prevSibling will only be nullptr when we are deleting the very
|
2007-03-22 10:30:00 -07:00
|
|
|
// first frame in the main or overflow list.
|
2009-09-29 12:47:05 -07:00
|
|
|
if (searchingOverflowList) {
|
2012-03-07 17:57:37 -08:00
|
|
|
overflowLines->mFrames.RemoveFrame(aDeletedFrame);
|
2009-09-29 12:47:05 -07:00
|
|
|
} else {
|
2009-10-02 09:27:37 -07:00
|
|
|
mFrames.RemoveFrame(aDeletedFrame);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Update the child count of the line to be accurate
|
2012-03-10 18:32:27 -08:00
|
|
|
line->NoteFrameRemoved(aDeletedFrame);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Destroy frame; capture its next continuation first in case we need
|
|
|
|
// to destroy that too.
|
2008-12-02 17:27:19 -08:00
|
|
|
nsIFrame* deletedNextContinuation = (aFlags & REMOVE_FIXED_CONTINUATIONS) ?
|
|
|
|
aDeletedFrame->GetNextContinuation() : aDeletedFrame->GetNextInFlow();
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef NOISY_REMOVE_FRAME
|
|
|
|
printf("DoRemoveFrame: %s line=%p frame=",
|
|
|
|
searchingOverflowList?"overflow":"normal", line.get());
|
|
|
|
nsFrame::ListTag(stdout, aDeletedFrame);
|
2010-06-01 16:32:59 -07:00
|
|
|
printf(" prevSibling=%p deletedNextContinuation=%p\n",
|
|
|
|
aDeletedFrame->GetPrevSibling(), deletedNextContinuation);
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
2010-06-01 16:32:59 -07: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())
|
2014-02-06 14:07:47 -08:00
|
|
|
->DeleteNextInFlowChild(deletedNextContinuation, false);
|
2012-07-30 07:20:58 -07:00
|
|
|
deletedNextContinuation = nullptr;
|
2010-06-01 16:32:59 -07:00
|
|
|
}
|
|
|
|
|
2009-08-31 11:25:35 -07:00
|
|
|
aDeletedFrame->Destroy();
|
2007-03-22 10:30:00 -07:00
|
|
|
aDeletedFrame = deletedNextContinuation;
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool haveAdvancedToNextLine = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
// If line is empty, remove it now.
|
2012-03-10 18:32:27 -08:00
|
|
|
if (0 == line->GetChildCount()) {
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef NOISY_REMOVE_FRAME
|
|
|
|
printf("DoRemoveFrame: %s line=%p became empty so it will be removed\n",
|
|
|
|
searchingOverflowList?"overflow":"normal", line.get());
|
|
|
|
#endif
|
|
|
|
nsLineBox *cur = line;
|
|
|
|
if (!searchingOverflowList) {
|
|
|
|
line = mLines.erase(line);
|
|
|
|
// 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...
|
|
|
|
#ifdef NOISY_BLOCK_INVALIDATE
|
2012-10-09 22:00:05 -07:00
|
|
|
nsRect visOverflow(cur->GetVisualOverflowArea());
|
2007-03-22 10:30:00 -07:00
|
|
|
printf("%p invalidate 10 (%d, %d, %d, %d)\n",
|
2010-10-06 21:25:45 -07:00
|
|
|
this, visOverflow.x, visOverflow.y,
|
|
|
|
visOverflow.width, visOverflow.height);
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
} else {
|
2012-03-07 17:57:37 -08:00
|
|
|
line = overflowLines->mLines.erase(line);
|
2013-03-03 15:46:56 -08:00
|
|
|
if (overflowLines->mLines.empty()) {
|
|
|
|
DestroyOverflowLines();
|
|
|
|
overflowLines = nullptr;
|
2009-12-25 05:59:08 -08: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-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
2012-05-03 17:14:01 -07:00
|
|
|
FreeLineBox(cur);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// 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();
|
|
|
|
}
|
2011-10-17 07:59:28 -07:00
|
|
|
haveAdvancedToNextLine = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
} else {
|
|
|
|
// Make the line that just lost a frame dirty, and advance to
|
|
|
|
// the next line.
|
|
|
|
if (!deletedNextContinuation || isLastFrameOnLine ||
|
|
|
|
!line->Contains(deletedNextContinuation)) {
|
|
|
|
line->MarkDirty();
|
|
|
|
++line;
|
2011-10-17 07:59:28 -07:00
|
|
|
haveAdvancedToNextLine = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (deletedNextContinuation) {
|
|
|
|
// See if we should keep looking in the current flow's line list.
|
|
|
|
if (deletedNextContinuation->GetParent() != this) {
|
|
|
|
// 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 00:12:54 -07: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;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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 &&
|
|
|
|
!line->Contains(deletedNextContinuation)) {
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
2012-03-07 17:57:37 -08:00
|
|
|
TryAllLines(&line, &line_start, &line_end, &searchingOverflowList,
|
|
|
|
&overflowLines);
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef NOISY_REMOVE_FRAME
|
2009-10-02 09:27:37 -07:00
|
|
|
printf("DoRemoveFrame: now on %s line=%p\n",
|
|
|
|
searchingOverflowList?"overflow":"normal", line.get());
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-12-02 17:27:19 -08:00
|
|
|
|
|
|
|
if (!(aFlags & FRAMES_ARE_EMPTY) && line.next() != line_end) {
|
2009-05-19 08:54:42 -07:00
|
|
|
line.next()->MarkDirty();
|
2011-10-17 07:59:28 -07:00
|
|
|
line.next()->SetInvalidateTextRuns(true);
|
2007-09-17 20:00:16 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2011-10-17 07:59:28 -07:00
|
|
|
VerifyLines(true);
|
2012-05-03 17:14:01 -07:00
|
|
|
VerifyOverflowSituation();
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// Advance to next flow block if the frame has more continuations
|
2009-08-31 11:25:35 -07:00
|
|
|
return RemoveBlockChild(aDeletedFrame, !(aFlags & REMOVE_FIXED_CONTINUATIONS));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-03-23 13:49:45 -07:00
|
|
|
static bool
|
|
|
|
FindBlockLineFor(nsIFrame* aChild,
|
|
|
|
nsLineList::iterator aBegin,
|
|
|
|
nsLineList::iterator aEnd,
|
|
|
|
nsLineList::iterator* aResult)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aChild->IsBlockOutside());
|
|
|
|
for (nsLineList::iterator line = aBegin; line != aEnd; ++line) {
|
|
|
|
MOZ_ASSERT(line->GetChildCount() > 0);
|
|
|
|
if (line->IsBlock() && line->mFirstChild == aChild) {
|
|
|
|
MOZ_ASSERT(line->GetChildCount() == 1);
|
|
|
|
*aResult = line;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
FindInlineLineFor(nsIFrame* aChild,
|
|
|
|
const nsFrameList& aFrameList,
|
|
|
|
nsLineList::iterator aBegin,
|
|
|
|
nsLineList::iterator aEnd,
|
|
|
|
nsLineList::iterator* aResult)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!aChild->IsBlockOutside());
|
|
|
|
for (nsLineList::iterator line = aBegin; line != aEnd; ++line) {
|
|
|
|
MOZ_ASSERT(line->GetChildCount() > 0);
|
|
|
|
if (!line->IsBlock()) {
|
|
|
|
// Optimize by comparing the line's last child first.
|
|
|
|
nsLineList::iterator next = line.next();
|
|
|
|
if (aChild == (next == aEnd ? aFrameList.LastChild()
|
|
|
|
: next->mFirstChild->GetPrevSibling()) ||
|
|
|
|
line->Contains(aChild)) {
|
|
|
|
*aResult = line;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
FindLineFor(nsIFrame* aChild,
|
|
|
|
const nsFrameList& aFrameList,
|
|
|
|
nsLineList::iterator aBegin,
|
|
|
|
nsLineList::iterator aEnd,
|
|
|
|
nsLineList::iterator* aResult)
|
|
|
|
{
|
|
|
|
return aChild->IsBlockOutside() ?
|
|
|
|
FindBlockLineFor(aChild, aBegin, aEnd, aResult) :
|
|
|
|
FindInlineLineFor(aChild, aFrameList, aBegin, aEnd, aResult);
|
|
|
|
}
|
|
|
|
|
2007-07-25 21:03:29 -07:00
|
|
|
nsresult
|
2014-02-06 14:07:48 -08:00
|
|
|
nsBlockFrame::StealFrame(nsIFrame* aChild,
|
|
|
|
bool aForceNormal)
|
2007-07-25 21:03:29 -07:00
|
|
|
{
|
2013-03-23 13:49:45 -07:00
|
|
|
MOZ_ASSERT(aChild->GetParent() == this);
|
2007-07-25 21:03:29 -07:00
|
|
|
|
2009-08-31 11:25:36 -07:00
|
|
|
if ((aChild->GetStateBits() & NS_FRAME_OUT_OF_FLOW) &&
|
2012-08-02 04:38:49 -07:00
|
|
|
aChild->IsFloating()) {
|
2013-03-15 15:32:35 -07:00
|
|
|
RemoveFloat(aChild);
|
|
|
|
return NS_OK;
|
2009-08-31 11:25:36 -07:00
|
|
|
}
|
|
|
|
|
2007-07-25 21:03:29 -07:00
|
|
|
if ((aChild->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER)
|
2013-03-23 13:49:45 -07:00
|
|
|
&& !aForceNormal) {
|
2014-02-06 14:07:47 -08:00
|
|
|
return nsContainerFrame::StealFrame(aChild);
|
2013-03-23 13:49:45 -07:00
|
|
|
}
|
2007-07-25 21:03:29 -07:00
|
|
|
|
2013-03-23 13:49:45 -07:00
|
|
|
MOZ_ASSERT(!(aChild->GetStateBits() & NS_FRAME_OUT_OF_FLOW));
|
2013-03-23 13:10:34 -07:00
|
|
|
|
2013-03-23 13:49:45 -07:00
|
|
|
nsLineList::iterator line;
|
|
|
|
if (FindLineFor(aChild, mFrames, mLines.begin(), mLines.end(), &line)) {
|
|
|
|
RemoveFrameFromLine(aChild, line, mFrames, mLines);
|
|
|
|
} else {
|
|
|
|
FrameLines* overflowLines = GetOverflowLines();
|
|
|
|
DebugOnly<bool> found;
|
|
|
|
found = FindLineFor(aChild, overflowLines->mFrames,
|
|
|
|
overflowLines->mLines.begin(),
|
|
|
|
overflowLines->mLines.end(), &line);
|
|
|
|
MOZ_ASSERT(found);
|
|
|
|
RemoveFrameFromLine(aChild, line, overflowLines->mFrames,
|
|
|
|
overflowLines->mLines);
|
|
|
|
if (overflowLines->mLines.empty()) {
|
|
|
|
DestroyOverflowLines();
|
2013-03-23 13:45:53 -07:00
|
|
|
}
|
2013-03-23 13:49:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBlockFrame::RemoveFrameFromLine(nsIFrame* aChild, nsLineList::iterator aLine,
|
|
|
|
nsFrameList& aFrameList, nsLineList& aLineList)
|
|
|
|
{
|
|
|
|
aFrameList.RemoveFrame(aChild);
|
|
|
|
if (aChild == aLine->mFirstChild) {
|
|
|
|
aLine->mFirstChild = aChild->GetNextSibling();
|
|
|
|
}
|
|
|
|
aLine->NoteFrameRemoved(aChild);
|
|
|
|
if (aLine->GetChildCount() > 0) {
|
|
|
|
aLine->MarkDirty();
|
|
|
|
} else {
|
|
|
|
// The line became empty - destroy it.
|
|
|
|
nsLineBox* lineBox = aLine;
|
|
|
|
aLine = aLineList.erase(aLine);
|
|
|
|
if (aLine != aLineList.end()) {
|
|
|
|
aLine->MarkPreviousMarginDirty();
|
2009-09-29 12:47:05 -07:00
|
|
|
}
|
2013-03-23 13:49:45 -07:00
|
|
|
FreeLineBox(lineBox);
|
2007-07-25 21:03:29 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
void
|
2014-02-06 14:07:48 -08:00
|
|
|
nsBlockFrame::DeleteNextInFlowChild(nsIFrame* aNextInFlow,
|
|
|
|
bool aDeletingEmptyFrames)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-09-20 06:42:03 -07:00
|
|
|
NS_PRECONDITION(aNextInFlow->GetPrevInFlow(), "bad next-in-flow");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-08-31 11:25:37 -07:00
|
|
|
if (aNextInFlow->GetStateBits() &
|
|
|
|
(NS_FRAME_OUT_OF_FLOW | NS_FRAME_IS_OVERFLOW_CONTAINER)) {
|
2014-02-06 14:07:47 -08:00
|
|
|
nsContainerFrame::DeleteNextInFlowChild(aNextInFlow, aDeletingEmptyFrames);
|
2007-07-25 21:03:29 -07:00
|
|
|
}
|
|
|
|
else {
|
2011-01-11 17:09:22 -08:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (aDeletingEmptyFrames) {
|
|
|
|
nsLayoutUtils::AssertTreeOnlyEmptyNextInFlows(aNextInFlow);
|
|
|
|
}
|
|
|
|
#endif
|
2008-12-02 17:27:19 -08:00
|
|
|
DoRemoveFrame(aNextInFlow,
|
|
|
|
aDeletingEmptyFrames ? FRAMES_ARE_EMPTY : 0);
|
2007-07-25 21:03:29 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-12-13 09:42:43 -08:00
|
|
|
const nsStyleText*
|
|
|
|
nsBlockFrame::StyleTextForLineLayout()
|
|
|
|
{
|
|
|
|
// Return the pointer to an unmodified style text
|
|
|
|
return StyleText();
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
// Float support
|
|
|
|
|
2008-06-10 16:53:22 -07:00
|
|
|
nsRect
|
2009-04-08 13:52:36 -07:00
|
|
|
nsBlockFrame::AdjustFloatAvailableSpace(nsBlockReflowState& aState,
|
|
|
|
const nsRect& aFloatAvailableSpace,
|
|
|
|
nsIFrame* aFloatFrame)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
// Compute the available width. By default, assume the width of the
|
|
|
|
// containing block.
|
|
|
|
nscoord availWidth;
|
2013-02-16 13:51:02 -08:00
|
|
|
const nsStyleDisplay* floatDisplay = aFloatFrame->StyleDisplay();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE != floatDisplay->mDisplay ||
|
|
|
|
eCompatibility_NavQuirks != aState.mPresContext->CompatibilityMode() ) {
|
|
|
|
availWidth = aState.mContentArea.width;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// 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 13:52:36 -07:00
|
|
|
availWidth = aFloatAvailableSpace.width;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nscoord availHeight = NS_UNCONSTRAINEDSIZE == aState.mContentArea.height
|
2008-08-12 02:32:10 -07:00
|
|
|
? NS_UNCONSTRAINEDSIZE
|
2013-01-15 04:22:03 -08:00
|
|
|
: std::max(0, aState.mContentArea.YMost() - aState.mY);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-08-12 02:32:10 -07: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 12:32:53 -07:00
|
|
|
return nsRect(aState.mContentArea.x,
|
|
|
|
aState.mContentArea.y,
|
2008-06-10 16:53:22 -07:00
|
|
|
availWidth, availHeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord
|
|
|
|
nsBlockFrame::ComputeFloatWidth(nsBlockReflowState& aState,
|
2009-04-08 13:52:36 -07:00
|
|
|
const nsRect& aFloatAvailableSpace,
|
2009-08-31 11:25:35 -07:00
|
|
|
nsIFrame* aFloat)
|
2008-06-10 16:53:22 -07:00
|
|
|
{
|
2009-08-31 11:25:35 -07:00
|
|
|
NS_PRECONDITION(aFloat->GetStateBits() & NS_FRAME_OUT_OF_FLOW,
|
|
|
|
"aFloat must be an out-of-flow frame");
|
2008-06-10 16:53:22 -07:00
|
|
|
// Reflow the float.
|
2009-04-08 13:52:36 -07:00
|
|
|
nsRect availSpace = AdjustFloatAvailableSpace(aState, aFloatAvailableSpace,
|
2009-08-31 11:25:35 -07:00
|
|
|
aFloat);
|
2008-06-10 16:53:22 -07:00
|
|
|
|
2009-08-31 11:25:35 -07:00
|
|
|
nsHTMLReflowState floatRS(aState.mPresContext, aState.mReflowState, aFloat,
|
2013-08-14 05:27:20 -07:00
|
|
|
availSpace.Size());
|
2013-12-27 09:59:21 -08:00
|
|
|
return floatRS.ComputedWidth() + floatRS.ComputedPhysicalBorderPadding().LeftRight() +
|
|
|
|
floatRS.ComputedPhysicalMargin().LeftRight();
|
2008-06-10 16:53:22 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsBlockFrame::ReflowFloat(nsBlockReflowState& aState,
|
2010-08-05 21:59:18 -07:00
|
|
|
const nsRect& aAdjustedAvailableSpace,
|
2009-08-31 11:25:35 -07:00
|
|
|
nsIFrame* aFloat,
|
2008-06-10 16:53:22 -07:00
|
|
|
nsMargin& aFloatMargin,
|
2013-07-29 21:53:13 -07:00
|
|
|
nsMargin& aFloatOffsets,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aFloatPushedDown,
|
2008-06-10 16:53:22 -07:00
|
|
|
nsReflowStatus& aReflowStatus)
|
|
|
|
{
|
2009-08-31 11:25:35 -07:00
|
|
|
NS_PRECONDITION(aFloat->GetStateBits() & NS_FRAME_OUT_OF_FLOW,
|
|
|
|
"aFloat must be an out-of-flow frame");
|
2008-06-10 16:53:22 -07: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 11:25:35 -07:00
|
|
|
aFloat, this,
|
2009-04-08 13:52:36 -07:00
|
|
|
aFloatAvailableSpace.x, aFloatAvailableSpace.y,
|
|
|
|
aFloatAvailableSpace.width, aFloatAvailableSpace.height
|
2008-06-10 16:53:22 -07:00
|
|
|
);
|
|
|
|
#endif
|
|
|
|
|
2009-08-31 11:25:35 -07:00
|
|
|
nsHTMLReflowState floatRS(aState.mPresContext, aState.mReflowState, aFloat,
|
2010-08-05 21:59:18 -07:00
|
|
|
nsSize(aAdjustedAvailableSpace.width,
|
|
|
|
aAdjustedAvailableSpace.height));
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-08-05 21:59:19 -07: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)) {
|
2011-10-17 07:59:28 -07:00
|
|
|
floatRS.mFlags.mIsTopOfPage = false;
|
2010-08-05 21:59:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Setup a block reflow context to reflow the float.
|
2007-03-22 10:30:00 -07:00
|
|
|
nsBlockReflowContext brc(aState.mPresContext, aState.mReflowState);
|
|
|
|
|
|
|
|
// Reflow the float
|
2011-09-28 23:19:26 -07:00
|
|
|
bool isAdjacentWithTop = aState.IsAdjacentWithTop();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
nsIFrame* clearanceFrame = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult rv;
|
|
|
|
do {
|
|
|
|
nsCollapsingMargin margin;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mayNeedRetry = false;
|
2012-07-30 07:20:58 -07:00
|
|
|
floatRS.mDiscoveredClearance = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
// Only first in flow gets a top margin.
|
2009-08-31 11:25:35 -07:00
|
|
|
if (!aFloat->GetPrevInFlow()) {
|
2007-03-22 10:30:00 -07:00
|
|
|
nsBlockReflowContext::ComputeCollapsedTopMargin(floatRS, &margin,
|
|
|
|
clearanceFrame, &mayNeedRetry);
|
|
|
|
|
|
|
|
if (mayNeedRetry && !clearanceFrame) {
|
|
|
|
floatRS.mDiscoveredClearance = &clearanceFrame;
|
2009-01-04 16:39:54 -08: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
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
rv = brc.ReflowBlock(aAdjustedAvailableSpace, true, margin,
|
2007-03-22 10:30:00 -07:00
|
|
|
0, isAdjacentWithTop,
|
2012-07-30 07:20:58 -07:00
|
|
|
nullptr, floatRS,
|
2007-10-01 22:57:45 -07:00
|
|
|
aReflowStatus, aState);
|
2007-03-22 10:30:00 -07:00
|
|
|
} while (NS_SUCCEEDED(rv) && clearanceFrame);
|
|
|
|
|
2012-11-08 08:09:38 -08:00
|
|
|
if (!NS_FRAME_IS_FULLY_COMPLETE(aReflowStatus) &&
|
|
|
|
ShouldAvoidBreakInside(floatRS)) {
|
|
|
|
aReflowStatus = NS_INLINE_LINE_BREAK_BEFORE();
|
|
|
|
} else if (NS_FRAME_IS_NOT_COMPLETE(aReflowStatus) &&
|
|
|
|
(NS_UNCONSTRAINEDSIZE == aAdjustedAvailableSpace.height)) {
|
|
|
|
// An incomplete reflow status means we should split the float
|
|
|
|
// if the height is constrained (bug 145305).
|
2007-03-22 10:30:00 -07:00
|
|
|
aReflowStatus = NS_FRAME_COMPLETE;
|
2012-11-08 08:09:38 -08:00
|
|
|
}
|
2007-07-25 21:03:29 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (aReflowStatus & NS_FRAME_REFLOW_NEXTINFLOW) {
|
|
|
|
aState.mReflowStatus |= NS_FRAME_REFLOW_NEXTINFLOW;
|
|
|
|
}
|
|
|
|
|
2009-08-31 11:25:35 -07:00
|
|
|
if (aFloat->GetType() == nsGkAtoms::letterFrame) {
|
2007-03-22 10:30:00 -07: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;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2013-07-29 21:53:13 -07:00
|
|
|
// Capture the margin and offsets information for the caller
|
2013-12-27 09:59:21 -08:00
|
|
|
aFloatMargin = floatRS.ComputedPhysicalMargin(); // float margins don't collapse
|
|
|
|
aFloatOffsets = floatRS.ComputedPhysicalOffsets();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
const nsHTMLReflowMetrics& metrics = brc.GetMetrics();
|
|
|
|
|
|
|
|
// Set the rect, make sure the view is properly sized and positioned,
|
|
|
|
// and tell the frame we're done reflowing it
|
|
|
|
// XXXldb This seems like the wrong place to be doing this -- shouldn't
|
|
|
|
// we be doing this in nsBlockReflowState::FlowAndPlaceFloat after
|
|
|
|
// we've positioned the float, and shouldn't we be doing the equivalent
|
2013-11-15 05:19:02 -08:00
|
|
|
// of |PlaceFrameView| here?
|
2013-12-27 09:59:52 -08:00
|
|
|
aFloat->SetSize(nsSize(metrics.Width(), metrics.Height()));
|
2009-08-31 11:25:35 -07:00
|
|
|
if (aFloat->HasView()) {
|
|
|
|
nsContainerFrame::SyncFrameViewAfterReflow(aState.mPresContext, aFloat,
|
|
|
|
aFloat->GetView(),
|
2010-10-06 21:25:45 -07:00
|
|
|
metrics.VisualOverflow(),
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_FRAME_NO_MOVE_VIEW);
|
|
|
|
}
|
|
|
|
// Pass floatRS so the frame hierarchy can be used (redoFloatRS has the same hierarchy)
|
2009-08-31 11:25:35 -07:00
|
|
|
aFloat->DidReflow(aState.mPresContext, &floatRS,
|
2012-11-13 22:47:33 -08:00
|
|
|
nsDidReflowStatus::FINISHED);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifdef NOISY_FLOAT
|
|
|
|
printf("end ReflowFloat %p, sized to %d,%d\n",
|
2013-12-27 09:59:52 -08:00
|
|
|
aFloat, metrics.Width(), metrics.Height());
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t
|
2009-08-31 11:25:36 -07:00
|
|
|
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 14:07:30 -07:00
|
|
|
return NS_STYLE_CLEAR_NONE;
|
2009-08-31 11:25:36 -07:00
|
|
|
}
|
|
|
|
|
2013-06-18 23:09:22 -07:00
|
|
|
void
|
2010-08-05 21:59:20 -07:00
|
|
|
nsBlockFrame::ReflowPushedFloats(nsBlockReflowState& aState,
|
2010-10-06 21:25:45 -07:00
|
|
|
nsOverflowAreas& aOverflowAreas,
|
|
|
|
nsReflowStatus& aStatus)
|
2009-08-31 11:25:36 -07:00
|
|
|
{
|
2013-01-11 14:51:21 -08:00
|
|
|
// Pushed floats live at the start of our float list; see comment
|
|
|
|
// above nsBlockFrame::DrainPushedFloats.
|
2010-08-05 21:59:19 -07:00
|
|
|
for (nsIFrame* f = mFloats.FirstChild(), *next;
|
2010-08-05 21:59:20 -07:00
|
|
|
f && (f->GetStateBits() & NS_FRAME_IS_PUSHED_FLOAT);
|
2010-08-05 21:59:19 -07:00
|
|
|
f = next) {
|
|
|
|
// save next sibling now, since reflowing could push the entire
|
|
|
|
// float, changing its siblings
|
|
|
|
next = f->GetNextSibling();
|
|
|
|
|
2011-01-11 17:09:21 -08: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;
|
|
|
|
}
|
|
|
|
|
2013-01-11 14:51:21 -08:00
|
|
|
// Always call FlowAndPlaceFloat; we might need to place this float
|
|
|
|
// if didn't belong to this block the last time it was reflowed.
|
|
|
|
aState.FlowAndPlaceFloat(f);
|
2009-08-31 11:25:36 -07:00
|
|
|
|
2010-10-06 21:25:45 -07:00
|
|
|
ConsiderChildOverflow(aOverflowAreas, f);
|
2009-08-31 11:25:36 -07:00
|
|
|
}
|
|
|
|
|
2009-08-31 11:25:36 -07:00
|
|
|
// If there are continued floats, then we may need to continue BR clearance
|
2014-03-02 09:42:16 -08:00
|
|
|
if (0 != aState.ClearFloats(0, NS_STYLE_CLEAR_BOTH)) {
|
2009-08-31 11:25:36 -07:00
|
|
|
aState.mFloatBreakType = static_cast<nsBlockFrame*>(GetPrevInFlow())
|
|
|
|
->FindTrailingClear();
|
|
|
|
}
|
2009-08-31 11:25:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBlockFrame::RecoverFloats(nsFloatManager& aFloatManager)
|
|
|
|
{
|
|
|
|
// Recover our own floats
|
2012-07-30 07:20:58 -07:00
|
|
|
nsIFrame* stop = nullptr; // Stop before we reach pushed floats that
|
2009-08-31 11:25:36 -07: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
|
2011-08-24 13:54:30 -07:00
|
|
|
for (nsIFrame* oc = GetFirstChild(kOverflowContainersList);
|
2009-08-31 11:25:36 -07:00
|
|
|
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.
|
2013-08-08 17:20:17 -07:00
|
|
|
nsPoint pos = block->GetNormalPosition();
|
2009-08-31 11:25:36 -07:00
|
|
|
aFloatManager.Translate(pos.x, pos.y);
|
|
|
|
block->RecoverFloats(aFloatManager);
|
|
|
|
aFloatManager.Translate(-pos.x, -pos.y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// Painting, event handling
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2010-10-06 21:25:45 -07:00
|
|
|
static void ComputeVisualOverflowArea(nsLineList& aLines,
|
|
|
|
nscoord aWidth, nscoord aHeight,
|
|
|
|
nsRect& aResult)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nscoord xa = 0, ya = 0, xb = aWidth, yb = aHeight;
|
|
|
|
for (nsLineList::iterator line = aLines.begin(), line_end = aLines.end();
|
|
|
|
line != line_end;
|
|
|
|
++line) {
|
|
|
|
// Compute min and max x/y values for the reflowed frame's
|
|
|
|
// combined areas
|
2010-10-06 21:25:45 -07:00
|
|
|
nsRect visOverflow(line->GetVisualOverflowArea());
|
|
|
|
nscoord x = visOverflow.x;
|
|
|
|
nscoord y = visOverflow.y;
|
|
|
|
nscoord xmost = x + visOverflow.width;
|
|
|
|
nscoord ymost = y + visOverflow.height;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (x < xa) {
|
|
|
|
xa = x;
|
|
|
|
}
|
|
|
|
if (xmost > xb) {
|
|
|
|
xb = xmost;
|
|
|
|
}
|
|
|
|
if (y < ya) {
|
|
|
|
ya = y;
|
|
|
|
}
|
|
|
|
if (ymost > yb) {
|
|
|
|
yb = ymost;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
aResult.x = xa;
|
|
|
|
aResult.y = ya;
|
|
|
|
aResult.width = xb - xa;
|
|
|
|
aResult.height = yb - ya;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2007-03-22 10:30:00 -07:00
|
|
|
nsBlockFrame::IsVisibleInSelection(nsISelection* aSelection)
|
|
|
|
{
|
2013-01-12 13:53:01 -08:00
|
|
|
if (mContent->IsHTML() && (mContent->Tag() == nsGkAtoms::html ||
|
|
|
|
mContent->Tag() == nsGkAtoms::body))
|
2011-10-17 07:59:28 -07:00
|
|
|
return true;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(mContent));
|
2011-09-28 23:19:26 -07:00
|
|
|
bool visible;
|
2011-10-17 07:59:28 -07:00
|
|
|
nsresult rv = aSelection->ContainsNode(node, true, &visible);
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_SUCCEEDED(rv) && visible;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2012-08-22 08:56:38 -07:00
|
|
|
static void DebugOutputDrawLine(int32_t aDepth, nsLineBox* aLine, bool aDrawn) {
|
2007-03-22 10:30:00 -07:00
|
|
|
if (nsBlockFrame::gNoisyDamageRepair) {
|
|
|
|
nsFrame::IndentBy(stdout, aDepth+1);
|
2010-10-06 21:25:45 -07:00
|
|
|
nsRect lineArea = aLine->GetVisualOverflowArea();
|
2007-03-22 10:30:00 -07:00
|
|
|
printf("%s line=%p bounds=%d,%d,%d,%d ca=%d,%d,%d,%d\n",
|
|
|
|
aDrawn ? "draw" : "skip",
|
2007-07-08 00:08:04 -07:00
|
|
|
static_cast<void*>(aLine),
|
2007-03-22 10:30:00 -07:00
|
|
|
aLine->mBounds.x, aLine->mBounds.y,
|
|
|
|
aLine->mBounds.width, aLine->mBounds.height,
|
|
|
|
lineArea.x, lineArea.y,
|
|
|
|
lineArea.width, lineArea.height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-02-14 03:12:27 -08:00
|
|
|
static void
|
2007-03-22 10:30:00 -07:00
|
|
|
DisplayLine(nsDisplayListBuilder* aBuilder, const nsRect& aLineArea,
|
|
|
|
const nsRect& aDirtyRect, nsBlockFrame::line_iterator& aLine,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aDepth, int32_t& aDrawnLines, const nsDisplayListSet& aLists,
|
2011-06-22 11:11:48 -07:00
|
|
|
nsBlockFrame* aFrame, TextOverflow* aTextOverflow) {
|
2007-03-22 10:30:00 -07: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.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool intersect = aLineArea.Intersects(aDirtyRect);
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (nsBlockFrame::gLamePaintMetrics) {
|
|
|
|
aDrawnLines++;
|
|
|
|
}
|
|
|
|
DebugOutputDrawLine(aDepth, aLine.get(), intersect);
|
|
|
|
#endif
|
|
|
|
// 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 05:54:50 -08: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.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool lineInline = aLine->IsInline();
|
|
|
|
bool lineMayHaveTextOverflow = aTextOverflow && lineInline;
|
2011-06-22 11:11:48 -07:00
|
|
|
if (!intersect && !aBuilder->ShouldDescendIntoFrame(aFrame) &&
|
|
|
|
!lineMayHaveTextOverflow)
|
2013-02-14 03:12:27 -08:00
|
|
|
return;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-06-28 00:22:57 -07:00
|
|
|
// Collect our line's display items in a temporary nsDisplayListCollection,
|
|
|
|
// so that we can apply any "text-overflow" clipping to the entire collection
|
|
|
|
// without affecting previous lines.
|
|
|
|
nsDisplayListCollection collection;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Block-level child backgrounds go on the blockBorderBackgrounds list ...
|
|
|
|
// Inline-level child backgrounds go on the regular child content list.
|
2013-06-28 00:22:57 -07:00
|
|
|
nsDisplayListSet childLists(collection,
|
|
|
|
lineInline ? collection.Content() : collection.BlockBorderBackgrounds());
|
2012-11-28 00:08:30 -08:00
|
|
|
|
|
|
|
uint32_t flags = lineInline ? nsIFrame::DISPLAY_CHILD_INLINE : 0;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIFrame* kid = aLine->mFirstChild;
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t n = aLine->GetChildCount();
|
2007-03-22 10:30:00 -07:00
|
|
|
while (--n >= 0) {
|
2013-02-14 03:12:27 -08:00
|
|
|
aFrame->BuildDisplayListForChild(aBuilder, kid, aDirtyRect,
|
|
|
|
childLists, flags);
|
2007-03-22 10:30:00 -07:00
|
|
|
kid = kid->GetNextSibling();
|
|
|
|
}
|
|
|
|
|
2011-06-22 11:11:48 -07:00
|
|
|
if (lineMayHaveTextOverflow) {
|
2013-06-28 00:22:57 -07:00
|
|
|
aTextOverflow->ProcessLine(collection, aLine.get());
|
2011-06-22 11:11:48 -07:00
|
|
|
}
|
2013-06-28 00:22:57 -07:00
|
|
|
|
|
|
|
collection.MoveTo(aLists);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-02-14 03:12:27 -08:00
|
|
|
void
|
2007-03-22 10:30:00 -07:00
|
|
|
nsBlockFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t drawnLines; // Will only be used if set (gLamePaintMetrics).
|
|
|
|
int32_t depth = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (gNoisyDamageRepair) {
|
|
|
|
depth = GetDepth();
|
|
|
|
nsRect ca;
|
2010-10-06 21:25:45 -07:00
|
|
|
::ComputeVisualOverflowArea(mLines, mRect.width, mRect.height, ca);
|
2007-03-22 10:30:00 -07: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);
|
|
|
|
}
|
2012-10-25 16:25:59 -07:00
|
|
|
PRTime start = 0; // Initialize these variables to silence the compiler.
|
2007-03-22 10:30:00 -07:00
|
|
|
if (gLamePaintMetrics) {
|
|
|
|
start = PR_Now();
|
|
|
|
drawnLines = 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
DisplayBorderBackgroundOutline(aBuilder, aLists);
|
2007-07-25 21:03:29 -07:00
|
|
|
|
|
|
|
if (GetPrevInFlow()) {
|
|
|
|
DisplayOverflowContainers(aBuilder, aDirtyRect, aLists);
|
2009-08-31 11:25:36 -07:00
|
|
|
for (nsIFrame* f = mFloats.FirstChild(); f; f = f->GetNextSibling()) {
|
2010-08-05 21:59:20 -07:00
|
|
|
if (f->GetStateBits() & NS_FRAME_IS_PUSHED_FLOAT)
|
2009-08-31 11:25:36 -07:00
|
|
|
BuildDisplayListForChild(aBuilder, f, aDirtyRect, aLists);
|
|
|
|
}
|
2007-07-25 21:03:29 -07:00
|
|
|
}
|
|
|
|
|
2009-07-28 05:51:09 -07:00
|
|
|
aBuilder->MarkFramesForDisplayList(this, mFloats, aDirtyRect);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-06-22 11:11:48 -07:00
|
|
|
// Prepare for text-overflow processing.
|
|
|
|
nsAutoPtr<TextOverflow> textOverflow(
|
2012-07-22 23:08:24 -07:00
|
|
|
TextOverflow::WillProcessLines(aBuilder, this));
|
2011-06-22 11:11:48 -07:00
|
|
|
|
2012-07-22 23:08:20 -07:00
|
|
|
// We'll collect our lines' display items here, & then append this to aLists.
|
|
|
|
nsDisplayListCollection linesDisplayListCollection;
|
|
|
|
|
2007-03-22 10:30:00 -07: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 05:54:50 -08: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) ?
|
2012-07-30 07:20:58 -07:00
|
|
|
nullptr : GetFirstLineContaining(aDirtyRect.y);
|
2007-03-22 10:30:00 -07:00
|
|
|
line_iterator line_end = end_lines();
|
|
|
|
|
|
|
|
if (cursor) {
|
|
|
|
for (line_iterator line = mLines.begin(cursor);
|
|
|
|
line != line_end;
|
|
|
|
++line) {
|
2010-10-06 21:25:45 -07:00
|
|
|
nsRect lineArea = line->GetVisualOverflowArea();
|
2007-03-22 10:30:00 -07: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;
|
|
|
|
}
|
2013-02-14 03:08:08 -08:00
|
|
|
DisplayLine(aBuilder, lineArea, aDirtyRect, line, depth, drawnLines,
|
|
|
|
linesDisplayListCollection, this, textOverflow);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2011-09-28 23:19:26 -07:00
|
|
|
bool nonDecreasingYs = true;
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t lineCount = 0;
|
2012-09-27 23:57:33 -07:00
|
|
|
nscoord lastY = INT32_MIN;
|
|
|
|
nscoord lastYMost = INT32_MIN;
|
2007-03-22 10:30:00 -07:00
|
|
|
for (line_iterator line = begin_lines();
|
|
|
|
line != line_end;
|
|
|
|
++line) {
|
2010-10-06 21:25:45 -07:00
|
|
|
nsRect lineArea = line->GetVisualOverflowArea();
|
2013-02-14 03:08:08 -08:00
|
|
|
DisplayLine(aBuilder, lineArea, aDirtyRect, line, depth, drawnLines,
|
|
|
|
linesDisplayListCollection, this, textOverflow);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!lineArea.IsEmpty()) {
|
|
|
|
if (lineArea.y < lastY
|
|
|
|
|| lineArea.YMost() < lastYMost) {
|
2011-10-17 07:59:28 -07:00
|
|
|
nonDecreasingYs = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
lastY = lineArea.y;
|
|
|
|
lastYMost = lineArea.YMost();
|
|
|
|
}
|
|
|
|
lineCount++;
|
|
|
|
}
|
|
|
|
|
2013-02-14 03:08:08 -08:00
|
|
|
if (nonDecreasingYs && lineCount >= MIN_LINES_NEEDING_CURSOR) {
|
2007-03-22 10:30:00 -07:00
|
|
|
SetupLineCursor();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-22 23:08:20 -07:00
|
|
|
// Pick up the resulting text-overflow markers. We append them to
|
|
|
|
// PositionedDescendants just before we append the lines' display items,
|
|
|
|
// so that our text-overflow markers will appear on top of this block's
|
|
|
|
// normal content but below any of its its' positioned children.
|
|
|
|
if (textOverflow) {
|
|
|
|
aLists.PositionedDescendants()->AppendToTop(&textOverflow->GetMarkers());
|
|
|
|
}
|
|
|
|
linesDisplayListCollection.MoveTo(aLists);
|
|
|
|
|
2013-02-14 03:08:08 -08:00
|
|
|
if (HasOutsideBullet()) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// Display outside bullets manually
|
2012-03-07 17:57:37 -08:00
|
|
|
nsIFrame* bullet = GetOutsideBullet();
|
2013-02-14 03:08:08 -08:00
|
|
|
BuildDisplayListForChild(aBuilder, bullet, aDirtyRect, aLists);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (gLamePaintMetrics) {
|
|
|
|
PRTime end = PR_Now();
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t numLines = mLines.size();
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!numLines) numLines = 1;
|
|
|
|
PRTime lines, deltaPerLine, delta;
|
2012-10-12 10:29:11 -07:00
|
|
|
lines = int64_t(numLines);
|
2012-10-04 22:05:27 -07:00
|
|
|
delta = end - start;
|
2012-10-04 22:05:28 -07:00
|
|
|
deltaPerLine = delta / lines;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
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);
|
|
|
|
printf("%s\n", buf);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef ACCESSIBILITY
|
2012-09-28 14:53:44 -07:00
|
|
|
a11y::AccType
|
|
|
|
nsBlockFrame::AccessibleType()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
// block frame may be for <hr>
|
|
|
|
if (mContent->Tag() == nsGkAtoms::hr) {
|
2012-12-17 17:25:52 -08:00
|
|
|
return a11y::eHTMLHRType;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-09-28 14:53:44 -07:00
|
|
|
if (!HasBullet() || !PresContext()) {
|
2008-04-21 10:19:32 -07:00
|
|
|
if (!mContent->GetParent()) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// Don't create accessible objects for the root content node, they are redundant with
|
|
|
|
// the nsDocAccessible object created with the document node
|
2012-12-12 02:04:12 -08:00
|
|
|
return a11y::eNoType;
|
2007-03-22 10:30:00 -07: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
|
2012-12-12 02:04:12 -08:00
|
|
|
return a11y::eNoType;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Not a bullet, treat as normal HTML container
|
2012-12-17 17:25:52 -08:00
|
|
|
return a11y::eHyperTextType;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Create special list bullet accessible
|
2012-12-17 17:25:52 -08:00
|
|
|
return a11y::eHTMLLiType;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-09-11 03:46:36 -07:00
|
|
|
void nsBlockFrame::ClearLineCursor()
|
|
|
|
{
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!(GetStateBits() & NS_BLOCK_HAS_LINE_CURSOR)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-03-28 18:46:55 -07:00
|
|
|
Properties().Delete(LineCursorProperty());
|
2007-03-22 10:30:00 -07:00
|
|
|
RemoveStateBits(NS_BLOCK_HAS_LINE_CURSOR);
|
|
|
|
}
|
|
|
|
|
2009-09-11 03:46:36 -07:00
|
|
|
void nsBlockFrame::SetupLineCursor()
|
|
|
|
{
|
2007-03-22 10:30:00 -07:00
|
|
|
if (GetStateBits() & NS_BLOCK_HAS_LINE_CURSOR
|
|
|
|
|| mLines.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-03-28 18:46:55 -07:00
|
|
|
Properties().Set(LineCursorProperty(), mLines.front());
|
2007-03-22 10:30:00 -07:00
|
|
|
AddStateBits(NS_BLOCK_HAS_LINE_CURSOR);
|
|
|
|
}
|
|
|
|
|
2009-09-11 03:46:36 -07:00
|
|
|
nsLineBox* nsBlockFrame::GetFirstLineContaining(nscoord y)
|
|
|
|
{
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!(GetStateBits() & NS_BLOCK_HAS_LINE_CURSOR)) {
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-03-28 18:46:55 -07:00
|
|
|
FrameProperties props = Properties();
|
|
|
|
|
2007-07-08 00:08:04 -07:00
|
|
|
nsLineBox* property = static_cast<nsLineBox*>
|
2010-03-28 18:46:55 -07:00
|
|
|
(props.Get(LineCursorProperty()));
|
2007-03-22 10:30:00 -07:00
|
|
|
line_iterator cursor = mLines.begin(property);
|
2010-10-06 21:25:45 -07:00
|
|
|
nsRect cursorArea = cursor->GetVisualOverflowArea();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
while ((cursorArea.IsEmpty() || cursorArea.YMost() > y)
|
|
|
|
&& cursor != mLines.front()) {
|
|
|
|
cursor = cursor.prev();
|
2010-10-06 21:25:45 -07:00
|
|
|
cursorArea = cursor->GetVisualOverflowArea();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
while ((cursorArea.IsEmpty() || cursorArea.YMost() <= y)
|
|
|
|
&& cursor != mLines.back()) {
|
|
|
|
cursor = cursor.next();
|
2010-10-06 21:25:45 -07:00
|
|
|
cursorArea = cursor->GetVisualOverflowArea();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (cursor.get() != property) {
|
2010-03-28 18:46:55 -07:00
|
|
|
props.Set(LineCursorProperty(), cursor.get());
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return cursor.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ void
|
|
|
|
nsBlockFrame::ChildIsDirty(nsIFrame* aChild)
|
|
|
|
{
|
|
|
|
// See if the child is absolutely positioned
|
|
|
|
if (aChild->GetStateBits() & NS_FRAME_OUT_OF_FLOW &&
|
2012-08-02 04:38:50 -07:00
|
|
|
aChild->IsAbsolutelyPositioned()) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// do nothing
|
2012-03-07 17:57:37 -08:00
|
|
|
} else if (aChild == GetOutsideBullet()) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// 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();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bulletLine != end_lines()) {
|
2012-07-20 11:27:03 -07:00
|
|
|
MarkLineDirty(bulletLine, &mLines);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
// otherwise we have an empty line list, and ReflowDirtyLines
|
|
|
|
// will handle reflowing the bullet.
|
|
|
|
} else {
|
2013-05-10 17:35:08 -07:00
|
|
|
// Note that we should go through our children to mark lines dirty
|
|
|
|
// before the next reflow. Doing it now could make things O(N^2)
|
|
|
|
// since finding the right line is O(N).
|
|
|
|
// We don't need to worry about marking lines on the overflow list
|
|
|
|
// as dirty; we're guaranteed to reflow them if we take them off the
|
|
|
|
// overflow list.
|
|
|
|
// However, we might have gotten a float, in which case we need to
|
|
|
|
// reflow the line containing its placeholder. So find the
|
|
|
|
// ancestor-or-self of the placeholder that's a child of the block,
|
|
|
|
// and mark it as NS_FRAME_HAS_DIRTY_CHILDREN too, so that we mark
|
|
|
|
// its line dirty when we handle NS_BLOCK_LOOK_FOR_DIRTY_FRAMES.
|
|
|
|
// We need to take some care to handle the case where a float is in
|
|
|
|
// a different continuation than its placeholder, including marking
|
|
|
|
// an extra block with NS_BLOCK_LOOK_FOR_DIRTY_FRAMES.
|
|
|
|
if (!(aChild->GetStateBits() & NS_FRAME_OUT_OF_FLOW)) {
|
|
|
|
AddStateBits(NS_BLOCK_LOOK_FOR_DIRTY_FRAMES);
|
|
|
|
} else {
|
|
|
|
NS_ASSERTION(aChild->IsFloating(), "should be a float");
|
2013-09-25 04:42:34 -07:00
|
|
|
nsIFrame *thisFC = FirstContinuation();
|
2013-05-10 17:35:08 -07:00
|
|
|
nsIFrame *placeholderPath =
|
|
|
|
PresContext()->FrameManager()->GetPlaceholderFrameFor(aChild);
|
|
|
|
// SVG code sometimes sends FrameNeedsReflow notifications during
|
|
|
|
// frame destruction, leading to null placeholders, but we're safe
|
|
|
|
// ignoring those.
|
|
|
|
if (placeholderPath) {
|
|
|
|
for (;;) {
|
|
|
|
nsIFrame *parent = placeholderPath->GetParent();
|
|
|
|
if (parent->GetContent() == mContent &&
|
2013-09-25 04:42:34 -07:00
|
|
|
parent->FirstContinuation() == thisFC) {
|
2013-05-10 17:35:08 -07:00
|
|
|
parent->AddStateBits(NS_BLOCK_LOOK_FOR_DIRTY_FRAMES);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
placeholderPath = parent;
|
|
|
|
}
|
|
|
|
placeholderPath->AddStateBits(NS_FRAME_HAS_DIRTY_CHILDREN);
|
|
|
|
}
|
2007-09-17 20:00:16 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsBlockFrameSuper::ChildIsDirty(aChild);
|
|
|
|
}
|
|
|
|
|
2013-03-19 18:47:48 -07:00
|
|
|
void
|
2007-03-22 10:30:00 -07:00
|
|
|
nsBlockFrame::Init(nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
|
|
|
if (aPrevInFlow) {
|
2012-03-07 17:57:37 -08:00
|
|
|
// Copy over the inherited block frame bits from the prev-in-flow.
|
|
|
|
SetFlags(aPrevInFlow->GetStateBits() &
|
|
|
|
(NS_BLOCK_FLAGS_MASK & ~NS_BLOCK_FLAGS_NON_INHERITED_MASK));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-03-19 18:47:48 -07:00
|
|
|
nsBlockFrameSuper::Init(aContent, aParent, aPrevInFlow);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-10-11 04:41:04 -07:00
|
|
|
if (!aPrevInFlow ||
|
|
|
|
aPrevInFlow->GetStateBits() & NS_BLOCK_NEEDS_BIDI_RESOLUTION)
|
2007-09-02 23:51:11 -07:00
|
|
|
AddStateBits(NS_BLOCK_NEEDS_BIDI_RESOLUTION);
|
|
|
|
|
2012-04-16 15:32:12 -07:00
|
|
|
if ((GetStateBits() &
|
|
|
|
(NS_FRAME_FONT_INFLATION_CONTAINER | NS_BLOCK_FLOAT_MGR)) ==
|
|
|
|
(NS_FRAME_FONT_INFLATION_CONTAINER | NS_BLOCK_FLOAT_MGR)) {
|
|
|
|
AddStateBits(NS_FRAME_FONT_INFLATION_FLOW_ROOT);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2014-02-17 23:47:48 -08:00
|
|
|
nsresult
|
2011-08-24 13:54:30 -07:00
|
|
|
nsBlockFrame::SetInitialChildList(ChildListID aListID,
|
2009-07-28 05:53:20 -07:00
|
|
|
nsFrameList& aChildList)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-03-07 17:57:37 -08:00
|
|
|
NS_ASSERTION(aListID != kPrincipalList ||
|
|
|
|
(GetStateBits() & (NS_BLOCK_FRAME_HAS_INSIDE_BULLET |
|
|
|
|
NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET)) == 0,
|
|
|
|
"how can we have a bullet already?");
|
|
|
|
|
2011-08-24 13:54:30 -07:00
|
|
|
if (kAbsoluteList == aListID) {
|
2011-04-29 16:02:33 -07:00
|
|
|
nsContainerFrame::SetInitialChildList(aListID, aChildList);
|
2011-06-01 13:18:15 -07:00
|
|
|
}
|
2011-08-24 13:54:30 -07:00
|
|
|
else if (kFloatList == aListID) {
|
2007-03-22 10:30:00 -07:00
|
|
|
mFloats.SetFrames(aChildList);
|
|
|
|
}
|
|
|
|
else {
|
2007-03-30 14:11:41 -07:00
|
|
|
nsPresContext* presContext = PresContext();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-05-02 13:32:17 -07: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-25 16:15:20 -08: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.
|
2013-02-15 21:38:33 -08:00
|
|
|
nsIAtom *pseudo = StyleContext()->GetPseudo();
|
2011-09-28 23:19:26 -07:00
|
|
|
bool haveFirstLetterStyle =
|
2007-05-02 13:32:17 -07:00
|
|
|
(!pseudo ||
|
|
|
|
(pseudo == nsCSSAnonBoxes::cellContent &&
|
2013-02-15 21:38:33 -08:00
|
|
|
mParent->StyleContext()->GetPseudo() == nullptr) ||
|
2007-05-02 13:32:17 -07:00
|
|
|
pseudo == nsCSSAnonBoxes::fieldsetContent ||
|
|
|
|
pseudo == nsCSSAnonBoxes::scrolledContent ||
|
2012-08-02 04:38:48 -07:00
|
|
|
pseudo == nsCSSAnonBoxes::columnContent ||
|
|
|
|
pseudo == nsCSSAnonBoxes::mozSVGText) &&
|
2007-10-10 21:36:48 -07:00
|
|
|
!IsFrameOfType(eMathML) &&
|
2012-07-30 07:20:58 -07:00
|
|
|
nsRefPtr<nsStyleContext>(GetFirstLetterStyle(presContext)) != nullptr;
|
2007-05-02 13:32:17 -07:00
|
|
|
NS_ASSERTION(haveFirstLetterStyle ==
|
2007-04-15 17:42:54 -07:00
|
|
|
((mState & NS_BLOCK_HAS_FIRST_LETTER_STYLE) != 0),
|
|
|
|
"NS_BLOCK_HAS_FIRST_LETTER_STYLE state out of sync");
|
2007-05-02 13:32:17 -07:00
|
|
|
#endif
|
2007-04-15 17:42:54 -07:00
|
|
|
|
2013-03-23 13:10:34 -07:00
|
|
|
AddFrames(aChildList, nullptr);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-06-11 12:23:13 -07: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;
|
|
|
|
}
|
2012-03-07 17:57:37 -08:00
|
|
|
if (NS_STYLE_DISPLAY_LIST_ITEM ==
|
2013-02-16 13:51:02 -08:00
|
|
|
possibleListItem->StyleDisplay()->mDisplay &&
|
2012-03-07 17:57:37 -08:00
|
|
|
!GetPrevInFlow()) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// Resolve style for the bullet frame
|
2013-02-16 13:51:02 -08:00
|
|
|
const nsStyleList* styleList = StyleList();
|
2009-12-10 23:37:40 -08:00
|
|
|
nsCSSPseudoElements::Type pseudoType;
|
2007-03-22 10:30:00 -07:00
|
|
|
switch (styleList->mListStyleType) {
|
|
|
|
case NS_STYLE_LIST_STYLE_DISC:
|
|
|
|
case NS_STYLE_LIST_STYLE_CIRCLE:
|
|
|
|
case NS_STYLE_LIST_STYLE_SQUARE:
|
2009-12-10 23:37:40 -08:00
|
|
|
pseudoType = nsCSSPseudoElements::ePseudo_mozListBullet;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
default:
|
2009-12-10 23:37:40 -08:00
|
|
|
pseudoType = nsCSSPseudoElements::ePseudo_mozListNumber;
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIPresShell *shell = presContext->PresShell();
|
|
|
|
|
2007-08-02 15:07:52 -07:00
|
|
|
nsStyleContext* parentStyle =
|
2009-12-10 23:37:40 -08:00
|
|
|
CorrectStyleParentFrame(this,
|
2013-02-15 21:38:33 -08:00
|
|
|
nsCSSPseudoElements::GetPseudoAtom(pseudoType))->StyleContext();
|
2007-03-22 10:30:00 -07:00
|
|
|
nsRefPtr<nsStyleContext> kidSC = shell->StyleSet()->
|
2010-04-30 06:12:06 -07:00
|
|
|
ResolvePseudoElementStyle(mContent->AsElement(), pseudoType,
|
2013-11-27 22:46:38 -08:00
|
|
|
parentStyle, nullptr);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Create bullet frame
|
|
|
|
nsBulletFrame* bullet = new (shell) nsBulletFrame(kidSC);
|
2012-07-30 07:20:58 -07:00
|
|
|
bullet->Init(mContent, this, nullptr);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// If the list bullet frame should be positioned inside then add
|
|
|
|
// it to the flow now.
|
|
|
|
if (NS_STYLE_LIST_STYLE_POSITION_INSIDE ==
|
2012-03-07 17:57:37 -08:00
|
|
|
styleList->mListStylePosition) {
|
2009-09-29 12:47:05 -07:00
|
|
|
nsFrameList bulletList(bullet, bullet);
|
2012-07-30 07:20:58 -07:00
|
|
|
AddFrames(bulletList, nullptr);
|
2012-03-07 17:57:37 -08:00
|
|
|
Properties().Set(InsideBulletProperty(), bullet);
|
|
|
|
AddStateBits(NS_BLOCK_FRAME_HAS_INSIDE_BULLET);
|
|
|
|
} else {
|
2013-04-01 08:26:02 -07:00
|
|
|
nsFrameList* bulletList = new (shell) nsFrameList(bullet, bullet);
|
2012-03-07 17:57:37 -08:00
|
|
|
Properties().Set(OutsideBulletProperty(), bulletList);
|
|
|
|
AddStateBits(NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
2009-09-11 03:46:36 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2009-09-11 03:46:36 -07:00
|
|
|
nsBlockFrame::BulletIsEmpty() const
|
|
|
|
{
|
2013-02-16 13:51:02 -08:00
|
|
|
NS_ASSERTION(mContent->GetPrimaryFrame()->StyleDisplay()->mDisplay ==
|
2012-03-07 17:57:37 -08:00
|
|
|
NS_STYLE_DISPLAY_LIST_ITEM && HasOutsideBullet(),
|
2009-09-11 03:46:36 -07:00
|
|
|
"should only care when we have an outside bullet");
|
2013-02-16 13:51:02 -08:00
|
|
|
const nsStyleList* list = StyleList();
|
2009-09-11 03:46:36 -07:00
|
|
|
return list->mListStyleType == NS_STYLE_LIST_STYLE_NONE &&
|
2009-12-10 20:02:13 -08:00
|
|
|
!list->GetListStyleImage();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-10-14 02:05:22 -07:00
|
|
|
void
|
|
|
|
nsBlockFrame::GetBulletText(nsAString& aText) const
|
|
|
|
{
|
|
|
|
aText.Truncate();
|
|
|
|
|
2013-02-16 13:51:02 -08:00
|
|
|
const nsStyleList* myList = StyleList();
|
2010-10-14 02:05:22 -07:00
|
|
|
if (myList->GetListStyleImage() ||
|
2010-10-15 08:34:24 -07: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 02:05:22 -07:00
|
|
|
}
|
|
|
|
else if (myList->mListStyleType != NS_STYLE_LIST_STYLE_NONE) {
|
2012-03-07 17:57:37 -08:00
|
|
|
nsBulletFrame* bullet = GetBullet();
|
|
|
|
if (bullet) {
|
|
|
|
nsAutoString text;
|
|
|
|
bullet->GetListItemText(*myList, text);
|
|
|
|
aText = text;
|
|
|
|
}
|
2011-03-28 06:59:54 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// static
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2007-03-22 10:30:00 -07:00
|
|
|
nsBlockFrame::FrameStartsCounterScope(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
nsIContent* content = aFrame->GetContent();
|
2009-08-24 13:02:07 -07:00
|
|
|
if (!content || !content->IsHTML())
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsIAtom *localName = content->NodeInfo()->NameAtom();
|
|
|
|
return localName == nsGkAtoms::ol ||
|
|
|
|
localName == nsGkAtoms::ul ||
|
|
|
|
localName == nsGkAtoms::dir ||
|
|
|
|
localName == nsGkAtoms::menu;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2007-03-22 10:30:00 -07:00
|
|
|
nsBlockFrame::RenumberLists(nsPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
if (!FrameStartsCounterScope(this)) {
|
|
|
|
// If this frame doesn't start a counter scope then we don't need
|
|
|
|
// to renumber child list items.
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-09-07 19:30:24 -07:00
|
|
|
MOZ_ASSERT(mContent->IsHTML(),
|
|
|
|
"FrameStartsCounterScope should only return true for HTML elements");
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Setup initial list ordinal value
|
|
|
|
// XXX Map html's start property to counter-reset style
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t ordinal = 1;
|
2012-09-07 19:30:24 -07:00
|
|
|
int32_t increment;
|
|
|
|
if (mContent->Tag() == nsGkAtoms::ol &&
|
|
|
|
mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::reversed)) {
|
|
|
|
increment = -1;
|
|
|
|
} else {
|
|
|
|
increment = 1;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsGenericHTMLElement *hc = nsGenericHTMLElement::FromContent(mContent);
|
2012-09-07 19:30:24 -07:00
|
|
|
// Must be non-null, since FrameStartsCounterScope only returns true
|
|
|
|
// for HTML elements.
|
|
|
|
MOZ_ASSERT(hc, "How is mContent not HTML?");
|
|
|
|
const nsAttrValue* attr = hc->GetParsedAttr(nsGkAtoms::start);
|
|
|
|
if (attr && attr->Type() == nsAttrValue::eInteger) {
|
|
|
|
ordinal = attr->GetIntegerValue();
|
|
|
|
} else if (increment < 0) {
|
|
|
|
// <ol reversed> case, or some other case with a negative increment: count
|
|
|
|
// up the child list
|
|
|
|
ordinal = 0;
|
|
|
|
for (nsIContent* kid = mContent->GetFirstChild(); kid;
|
|
|
|
kid = kid->GetNextSibling()) {
|
|
|
|
if (kid->IsHTML(nsGkAtoms::li)) {
|
2013-02-22 10:13:37 -08:00
|
|
|
// FIXME: This isn't right in terms of what CSS says to do for
|
|
|
|
// overflow of counters (but it only matters when this node has
|
|
|
|
// more than numeric_limits<int32_t>::max() children).
|
2012-09-07 19:30:24 -07:00
|
|
|
ordinal -= increment;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get to first-in-flow
|
2013-09-25 04:42:35 -07:00
|
|
|
nsBlockFrame* block = static_cast<nsBlockFrame*>(FirstInFlow());
|
2012-09-07 19:30:24 -07:00
|
|
|
return RenumberListsInBlock(aPresContext, block, &ordinal, 0, increment);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2007-03-22 10:30:00 -07:00
|
|
|
nsBlockFrame::RenumberListsInBlock(nsPresContext* aPresContext,
|
|
|
|
nsBlockFrame* aBlockFrame,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t* aOrdinal,
|
2012-09-07 19:30:24 -07:00
|
|
|
int32_t aDepth,
|
|
|
|
int32_t aIncrement)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-02-23 23:31:29 -08:00
|
|
|
// Examine each line in the block
|
2011-09-28 23:19:26 -07:00
|
|
|
bool foundValidLine;
|
2008-02-23 23:31:29 -08:00
|
|
|
nsBlockInFlowLineIterator bifLineIter(aBlockFrame, &foundValidLine);
|
|
|
|
|
|
|
|
if (!foundValidLine)
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2008-02-23 23:31:29 -08:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool renumberedABullet = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-02-23 23:31:29 -08:00
|
|
|
do {
|
|
|
|
nsLineList::iterator line = bifLineIter.GetLine();
|
|
|
|
nsIFrame* kid = line->mFirstChild;
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t n = line->GetChildCount();
|
2008-02-23 23:31:29 -08:00
|
|
|
while (--n >= 0) {
|
2012-09-07 19:30:24 -07:00
|
|
|
bool kidRenumberedABullet = RenumberListsFor(aPresContext, kid, aOrdinal,
|
|
|
|
aDepth, aIncrement);
|
2008-02-23 23:31:29 -08:00
|
|
|
if (kidRenumberedABullet) {
|
|
|
|
line->MarkDirty();
|
2011-10-17 07:59:28 -07:00
|
|
|
renumberedABullet = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2008-02-23 23:31:29 -08:00
|
|
|
kid = kid->GetNextSibling();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2008-02-23 23:31:29 -08:00
|
|
|
} while (bifLineIter.Next());
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-05-10 17:35:08 -07:00
|
|
|
// We need to set NS_FRAME_HAS_DIRTY_CHILDREN bits up the tree between
|
|
|
|
// the bullet and the caller of RenumberLists. But the caller itself
|
|
|
|
// has to be responsible for setting the bit itself, since that caller
|
|
|
|
// might be making a FrameNeedsReflow call, which requires that the
|
|
|
|
// bit not be set yet.
|
|
|
|
if (renumberedABullet && aDepth != 0) {
|
|
|
|
aBlockFrame->AddStateBits(NS_FRAME_HAS_DIRTY_CHILDREN);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
return renumberedABullet;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2007-03-22 10:30:00 -07:00
|
|
|
nsBlockFrame::RenumberListsFor(nsPresContext* aPresContext,
|
|
|
|
nsIFrame* aKid,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t* aOrdinal,
|
2012-09-07 19:30:24 -07:00
|
|
|
int32_t aDepth,
|
|
|
|
int32_t aIncrement)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(aPresContext && aKid && aOrdinal, "null params are immoral!");
|
|
|
|
|
|
|
|
// add in a sanity check for absurdly deep frame trees. See bug 42138
|
|
|
|
if (MAX_DEPTH_FOR_LIST_RENUMBERING < aDepth)
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// if the frame is a placeholder, then get the out of flow frame
|
|
|
|
nsIFrame* kid = nsPlaceholderFrame::GetRealFrameFor(aKid);
|
2013-02-16 13:51:02 -08:00
|
|
|
const nsStyleDisplay* display = kid->StyleDisplay();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// drill down through any wrappers to the real frame
|
|
|
|
kid = kid->GetContentInsertionFrame();
|
|
|
|
|
2008-02-23 23:31:29 -08:00
|
|
|
// possible there is no content insertion frame
|
|
|
|
if (!kid)
|
2011-10-17 07:59:28 -07:00
|
|
|
return false;
|
2008-02-23 23:31:29 -08:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool kidRenumberedABullet = false;
|
2008-02-23 23:31:29 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// If the frame is a list-item and the frame implements our
|
|
|
|
// block frame API then get its bullet and set the list item
|
|
|
|
// ordinal.
|
|
|
|
if (NS_STYLE_DISPLAY_LIST_ITEM == display->mDisplay) {
|
|
|
|
// Make certain that the frame is a block frame in case
|
|
|
|
// something foreign has crept in.
|
2008-07-13 15:10:23 -07:00
|
|
|
nsBlockFrame* listItem = nsLayoutUtils::GetAsBlock(kid);
|
|
|
|
if (listItem) {
|
2012-03-07 17:57:37 -08:00
|
|
|
nsBulletFrame* bullet = listItem->GetBullet();
|
|
|
|
if (bullet) {
|
2011-09-28 23:19:26 -07:00
|
|
|
bool changed;
|
2012-09-07 19:30:24 -07:00
|
|
|
*aOrdinal = bullet->SetListItemOrdinal(*aOrdinal, &changed, aIncrement);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (changed) {
|
2011-10-17 07:59:28 -07:00
|
|
|
kidRenumberedABullet = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-05-10 17:35:08 -07:00
|
|
|
// The ordinal changed - mark the bullet frame, and any
|
|
|
|
// intermediate frames between it and the block (are there
|
|
|
|
// ever any?), dirty.
|
|
|
|
// The calling code will make the necessary FrameNeedsReflow
|
|
|
|
// call for the list ancestor.
|
|
|
|
bullet->AddStateBits(NS_FRAME_IS_DIRTY);
|
|
|
|
nsIFrame *f = bullet;
|
|
|
|
do {
|
|
|
|
nsIFrame *parent = f->GetParent();
|
|
|
|
parent->ChildIsDirty(f);
|
|
|
|
f = parent;
|
|
|
|
} while (f != listItem);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// XXX temporary? if the list-item has child list-items they
|
|
|
|
// should be numbered too; especially since the list-item is
|
|
|
|
// itself (ASSUMED!) not to be a counter-resetter.
|
2012-09-07 19:30:24 -07:00
|
|
|
bool meToo = RenumberListsInBlock(aPresContext, listItem, aOrdinal,
|
|
|
|
aDepth + 1, aIncrement);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (meToo) {
|
2011-10-17 07:59:28 -07:00
|
|
|
kidRenumberedABullet = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (NS_STYLE_DISPLAY_BLOCK == display->mDisplay) {
|
|
|
|
if (FrameStartsCounterScope(kid)) {
|
|
|
|
// 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 {
|
|
|
|
// 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 15:10:23 -07:00
|
|
|
nsBlockFrame* kidBlock = nsLayoutUtils::GetAsBlock(kid);
|
|
|
|
if (kidBlock) {
|
2012-09-07 19:30:24 -07:00
|
|
|
kidRenumberedABullet = RenumberListsInBlock(aPresContext, kidBlock,
|
|
|
|
aOrdinal, aDepth + 1,
|
|
|
|
aIncrement);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return kidRenumberedABullet;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-03-07 17:57:37 -08:00
|
|
|
nsBlockFrame::ReflowBullet(nsIFrame* aBulletFrame,
|
|
|
|
nsBlockReflowState& aState,
|
2008-02-10 13:49:24 -08:00
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
nscoord aLineTop)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
const nsHTMLReflowState &rs = aState.mReflowState;
|
|
|
|
|
|
|
|
// Reflow the bullet now
|
|
|
|
nsSize availSize;
|
|
|
|
// Make up a width since it doesn't really matter (XXX).
|
2010-08-11 12:32:53 -07:00
|
|
|
availSize.width = aState.mContentArea.width;
|
2007-03-22 10:30:00 -07:00
|
|
|
availSize.height = NS_UNCONSTRAINEDSIZE;
|
|
|
|
|
|
|
|
// Get the reason right.
|
|
|
|
// XXXwaterson Should this look just like the logic in
|
|
|
|
// nsBlockReflowContext::ReflowBlock and nsLineLayout::ReflowFrame?
|
|
|
|
nsHTMLReflowState reflowState(aState.mPresContext, rs,
|
2012-03-07 17:57:37 -08:00
|
|
|
aBulletFrame, availSize);
|
2007-03-22 10:30:00 -07:00
|
|
|
nsReflowStatus status;
|
2012-03-07 17:57:37 -08:00
|
|
|
aBulletFrame->WillReflow(aState.mPresContext);
|
|
|
|
aBulletFrame->Reflow(aState.mPresContext, aMetrics, reflowState, status);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-04-08 13:52:36 -07: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 13:52:37 -07:00
|
|
|
nsRect floatAvailSpace =
|
2010-08-05 21:59:18 -07:00
|
|
|
aState.GetFloatAvailableSpaceWithState(aLineTop,
|
2009-04-08 13:52:37 -07:00
|
|
|
&aState.mFloatManagerStateBefore)
|
|
|
|
.mRect;
|
2009-04-08 13:52:36 -07: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.
|
2014-03-11 02:08:36 -07:00
|
|
|
|
|
|
|
// IStart from floatAvailSpace gives us the content/float start edge
|
|
|
|
// in the current writing mode. Then we subtract out the start
|
|
|
|
// border/padding and the bullet's width and margin to offset the position.
|
|
|
|
WritingMode wm = rs.GetWritingMode();
|
|
|
|
LogicalRect logicalFAS(wm, floatAvailSpace, floatAvailSpace.XMost());
|
|
|
|
nscoord iStart = logicalFAS.IStart(wm) -
|
|
|
|
rs.ComputedLogicalBorderPadding().IStart(wm)
|
|
|
|
- reflowState.ComputedLogicalMargin().IEnd(wm) - aMetrics.ISize();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Approximate the bullets position; vertical alignment will provide
|
|
|
|
// the final vertical location.
|
2014-03-11 02:08:36 -07:00
|
|
|
nscoord bStart = logicalFAS.BStart(wm);
|
|
|
|
aBulletFrame->SetRect(LogicalRect(wm, LogicalPoint(wm, iStart, bStart),
|
|
|
|
LogicalSize(wm, aMetrics.ISize(),
|
|
|
|
aMetrics.BSize())),
|
|
|
|
floatAvailSpace.XMost());
|
2012-03-07 17:57:37 -08:00
|
|
|
aBulletFrame->DidReflow(aState.mPresContext, &aState.mReflowState,
|
2012-11-13 22:47:33 -08:00
|
|
|
nsDidReflowStatus::FINISHED);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// This is used to scan frames for any float placeholders, add their
|
2009-09-18 04:09:36 -07:00
|
|
|
// floats to the list represented by aList, and remove the
|
2007-03-22 10:30:00 -07:00
|
|
|
// floats from whatever list they might be in. We don't search descendants
|
2013-02-06 17:13:34 -08:00
|
|
|
// that are float containing blocks. Floats that or not children of 'this'
|
|
|
|
// are ignored (they are not added to aList).
|
|
|
|
void
|
2013-02-27 15:05:45 -08:00
|
|
|
nsBlockFrame::DoCollectFloats(nsIFrame* aFrame, nsFrameList& aList,
|
|
|
|
bool aCollectSiblings)
|
2013-02-06 17:13:34 -08:00
|
|
|
{
|
2007-03-22 10:30:00 -07:00
|
|
|
while (aFrame) {
|
|
|
|
// Don't descend into float containing blocks.
|
|
|
|
if (!aFrame->IsFloatContainingBlock()) {
|
2009-11-16 13:00:07 -08:00
|
|
|
nsIFrame *outOfFlowFrame =
|
|
|
|
aFrame->GetType() == nsGkAtoms::placeholderFrame ?
|
2012-07-30 07:20:58 -07:00
|
|
|
nsLayoutUtils::GetFloatFromPlaceholder(aFrame) : nullptr;
|
2013-02-06 17:13:34 -08:00
|
|
|
if (outOfFlowFrame && outOfFlowFrame->GetParent() == this) {
|
2013-03-15 15:32:35 -07:00
|
|
|
RemoveFloat(outOfFlowFrame);
|
2013-02-06 17:13:34 -08:00
|
|
|
aList.AppendFrame(nullptr, outOfFlowFrame);
|
|
|
|
// FIXME: By not pulling floats whose parent is one of our
|
|
|
|
// later siblings, are we risking the pushed floats getting
|
|
|
|
// out-of-order?
|
|
|
|
// XXXmats nsInlineFrame's lazy reparenting depends on NOT doing that.
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2013-02-27 15:05:45 -08:00
|
|
|
DoCollectFloats(aFrame->GetFirstPrincipalChild(), aList, true);
|
|
|
|
DoCollectFloats(aFrame->GetFirstChild(kOverflowList), aList, true);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2007-04-20 17:42:58 -07:00
|
|
|
if (!aCollectSiblings)
|
|
|
|
break;
|
2007-03-22 10:30:00 -07:00
|
|
|
aFrame = aFrame->GetNextSibling();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBlockFrame::CheckFloats(nsBlockReflowState& aState)
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
2007-11-29 17:49:01 -08: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.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool anyLineDirty = false;
|
2007-11-29 17:49:01 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Check that the float list is what we would have built
|
2009-02-03 06:42:18 -08:00
|
|
|
nsAutoTArray<nsIFrame*, 8> lineFloats;
|
2007-03-22 10:30:00 -07:00
|
|
|
for (line_iterator line = begin_lines(), line_end = end_lines();
|
|
|
|
line != line_end; ++line) {
|
|
|
|
if (line->HasFloats()) {
|
|
|
|
nsFloatCache* fc = line->GetFirstFloat();
|
|
|
|
while (fc) {
|
2009-08-31 11:25:35 -07:00
|
|
|
lineFloats.AppendElement(fc->mFloat);
|
2007-03-22 10:30:00 -07:00
|
|
|
fc = fc->Next();
|
|
|
|
}
|
|
|
|
}
|
2007-11-29 17:49:01 -08:00
|
|
|
if (line->IsDirty()) {
|
2011-10-17 07:59:28 -07:00
|
|
|
anyLineDirty = true;
|
2007-11-29 17:49:01 -08:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2009-02-03 06:42:18 -08:00
|
|
|
nsAutoTArray<nsIFrame*, 8> storedFloats;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool equal = true;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t i = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
for (nsIFrame* f = mFloats.FirstChild(); f; f = f->GetNextSibling()) {
|
2010-08-05 21:59:20 -07:00
|
|
|
if (f->GetStateBits() & NS_FRAME_IS_PUSHED_FLOAT)
|
2009-08-31 11:25:36 -07:00
|
|
|
continue;
|
2007-03-22 10:30:00 -07:00
|
|
|
storedFloats.AppendElement(f);
|
2009-02-03 06:42:18 -08:00
|
|
|
if (i < lineFloats.Length() && lineFloats.ElementAt(i) != f) {
|
2011-10-17 07:59:28 -07:00
|
|
|
equal = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
2009-02-03 06:42:18 -08:00
|
|
|
if ((!equal || lineFloats.Length() != storedFloats.Length()) && !anyLineDirty) {
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_WARNING("nsBlockFrame::CheckFloats: Explicit float list is out of sync with float cache");
|
|
|
|
#if defined(DEBUG_roc)
|
2009-08-20 14:52:48 -07:00
|
|
|
nsFrame::RootFrameList(PresContext(), stdout, 0);
|
2009-02-03 06:42:18 -08:00
|
|
|
for (i = 0; i < lineFloats.Length(); ++i) {
|
2007-03-22 10:30:00 -07:00
|
|
|
printf("Line float: %p\n", lineFloats.ElementAt(i));
|
|
|
|
}
|
2009-02-03 06:42:18 -08:00
|
|
|
for (i = 0; i < storedFloats.Length(); ++i) {
|
2007-03-22 10:30:00 -07:00
|
|
|
printf("Stored float: %p\n", storedFloats.ElementAt(i));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-09-23 19:39:21 -07:00
|
|
|
const nsFrameList* oofs = GetOverflowOutOfFlows();
|
|
|
|
if (oofs && oofs->NotEmpty()) {
|
2009-01-04 16:39:54 -08:00
|
|
|
// Floats that were pushed should be removed from our float
|
|
|
|
// manager. Otherwise the float manager's YMost or XMost might
|
2007-03-22 10:30:00 -07:00
|
|
|
// be larger than necessary, causing this block to get an
|
|
|
|
// incorrect desired height (or width). Some of these floats
|
2009-01-04 16:39:54 -08:00
|
|
|
// may not actually have been added to the float manager because
|
2007-03-22 10:30:00 -07:00
|
|
|
// they weren't reflowed before being pushed; that's OK,
|
|
|
|
// RemoveRegions will ignore them. It is safe to do this here
|
2009-01-04 16:39:54 -08:00
|
|
|
// because we know from here on the float manager will only be
|
2007-03-22 10:30:00 -07:00
|
|
|
// used for its XMost and YMost, not to place new floats and
|
|
|
|
// lines.
|
2009-09-23 19:39:21 -07:00
|
|
|
aState.mFloatManager->RemoveTrailingRegions(oofs->FirstChild());
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-20 11:27:04 -07:00
|
|
|
void
|
|
|
|
nsBlockFrame::IsMarginRoot(bool* aTopMarginRoot, bool* aBottomMarginRoot)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-07-20 11:27:04 -07:00
|
|
|
if (!(GetStateBits() & NS_BLOCK_MARGIN_ROOT)) {
|
|
|
|
nsIFrame* parent = GetParent();
|
|
|
|
if (!parent || parent->IsFloatContainingBlock()) {
|
|
|
|
*aTopMarginRoot = false;
|
|
|
|
*aBottomMarginRoot = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (parent->GetType() == nsGkAtoms::columnSetFrame) {
|
2012-07-30 07:20:58 -07:00
|
|
|
*aTopMarginRoot = GetPrevInFlow() == nullptr;
|
|
|
|
*aBottomMarginRoot = GetNextInFlow() == nullptr;
|
2012-07-20 11:27:04 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-07-20 11:27:04 -07:00
|
|
|
*aTopMarginRoot = true;
|
|
|
|
*aBottomMarginRoot = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* static */
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2009-01-04 16:39:54 -08:00
|
|
|
nsBlockFrame::BlockNeedsFloatManager(nsIFrame* aBlock)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(aBlock, "Must have a frame");
|
2008-07-13 15:10:23 -07:00
|
|
|
NS_ASSERTION(nsLayoutUtils::GetAsBlock(aBlock), "aBlock must be a block");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsIFrame* parent = aBlock->GetParent();
|
2009-01-04 16:39:54 -08:00
|
|
|
return (aBlock->GetStateBits() & NS_BLOCK_FLOAT_MGR) ||
|
2007-03-22 10:30:00 -07:00
|
|
|
(parent && !parent->IsFloatContainingBlock());
|
|
|
|
}
|
2008-01-28 23:40:05 -08:00
|
|
|
|
|
|
|
/* static */
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2008-01-28 23:40:05 -08:00
|
|
|
nsBlockFrame::BlockCanIntersectFloats(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
return aFrame->IsFrameOfType(nsIFrame::eBlockFrame) &&
|
|
|
|
!aFrame->IsFrameOfType(nsIFrame::eReplaced) &&
|
2009-01-04 16:39:54 -08:00
|
|
|
!(aFrame->GetStateBits() & NS_BLOCK_FLOAT_MGR);
|
2008-01-28 23:40:05 -08:00
|
|
|
}
|
|
|
|
|
2008-04-14 18:05:17 -07: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-28 23:40:05 -08:00
|
|
|
/* static */
|
2008-04-14 18:05:17 -07:00
|
|
|
nsBlockFrame::ReplacedElementWidthToClear
|
2008-01-28 23:40:05 -08:00
|
|
|
nsBlockFrame::WidthToClearPastFloats(nsBlockReflowState& aState,
|
2009-04-08 13:52:37 -07:00
|
|
|
const nsRect& aFloatAvailableSpace,
|
2008-01-28 23:40:05 -08:00
|
|
|
nsIFrame* aFrame)
|
|
|
|
{
|
2008-04-14 18:05:17 -07:00
|
|
|
nscoord leftOffset, rightOffset;
|
|
|
|
nsCSSOffsetState offsetState(aFrame, aState.mReflowState.rendContext,
|
|
|
|
aState.mContentArea.width);
|
|
|
|
|
|
|
|
ReplacedElementWidthToClear result;
|
Bug 659828 - Part 1: Apply table margins to the outer table frame instead of the inner table frame (also fixes bug 87277); r=dbaron
Outer table frames act as CSS2.1 table wrapper boxes. We used to lay them out
without taking their margins into the account, which meant that their width was
always equal to the available width. This breaks horizontal positioning of
absolutely positioned kids of a table frame.
The main purpose of this patch is to apply the margins of tables to their outer
frame, instead of the inner frame. This means that the inner table frame will
always have a zero margin, which means that a lot of the stuff which used to
rely on the fact that table margins are applied to the inner frame need to
change.
In particular, in order to get the computed margins of a table, we used to query
the inner table frame, and this patch corrects that. Also, when shrink wrapping
tables, we used to not take the margins of the inner table frame into account,
which is fixed by this patch too. nsBlockReflowState::
ComputeReplacedBlockOffsetsForFloats also needed to be changed to read the
margin values from the outer frame too.
Also, as part of this patch, we start to respect the CSS2.1 margin model for
captions on all sides. This means that in particular, the top/bottom margins on
the top-outside and bottom-outside captions will not be collapsed with the
top/bottom margins of the table, and that the margins of the caption element
contribute to the width and height of the outer table frame. The
427129-table-caption reftest has been modified to match this new behavior.
Another side effect of this bug is fixing bug 87277, and the reftests for that
bug are marked as passing in this patch.
2011-05-31 16:02:56 -07:00
|
|
|
aState.ComputeReplacedBlockOffsetsForFloats(aFrame, aFloatAvailableSpace,
|
|
|
|
leftOffset, rightOffset);
|
|
|
|
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() +
|
2013-12-27 09:59:21 -08:00
|
|
|
reflowState.ComputedPhysicalBorderPadding().LeftRight();
|
Bug 659828 - Part 1: Apply table margins to the outer table frame instead of the inner table frame (also fixes bug 87277); r=dbaron
Outer table frames act as CSS2.1 table wrapper boxes. We used to lay them out
without taking their margins into the account, which meant that their width was
always equal to the available width. This breaks horizontal positioning of
absolutely positioned kids of a table frame.
The main purpose of this patch is to apply the margins of tables to their outer
frame, instead of the inner frame. This means that the inner table frame will
always have a zero margin, which means that a lot of the stuff which used to
rely on the fact that table margins are applied to the inner frame need to
change.
In particular, in order to get the computed margins of a table, we used to query
the inner table frame, and this patch corrects that. Also, when shrink wrapping
tables, we used to not take the margins of the inner table frame into account,
which is fixed by this patch too. nsBlockReflowState::
ComputeReplacedBlockOffsetsForFloats also needed to be changed to read the
margin values from the outer frame too.
Also, as part of this patch, we start to respect the CSS2.1 margin model for
captions on all sides. This means that in particular, the top/bottom margins on
the top-outside and bottom-outside captions will not be collapsed with the
top/bottom margins of the table, and that the margins of the caption element
contribute to the width and height of the outer table frame. The
427129-table-caption reftest has been modified to match this new behavior.
Another side effect of this bug is fixing bug 87277, and the reftests for that
bug are marked as passing in this patch.
2011-05-31 16:02:56 -07:00
|
|
|
// Use the margins from offsetState rather than reflowState so that
|
|
|
|
// they aren't reduced by ignoring margins in overconstrained cases.
|
2013-12-27 09:59:21 -08:00
|
|
|
result.marginLeft = offsetState.ComputedPhysicalMargin().left;
|
|
|
|
result.marginRight = offsetState.ComputedPhysicalMargin().right;
|
2008-01-28 23:40:05 -08:00
|
|
|
return result;
|
|
|
|
}
|
2007-09-03 00:00:10 -07:00
|
|
|
|
2007-10-19 10:41:29 -07:00
|
|
|
/* static */
|
|
|
|
nsBlockFrame*
|
|
|
|
nsBlockFrame::GetNearestAncestorBlock(nsIFrame* aCandidate)
|
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
nsBlockFrame* block = nullptr;
|
2007-10-19 10:41:29 -07:00
|
|
|
while(aCandidate) {
|
2008-07-13 15:10:23 -07:00
|
|
|
block = nsLayoutUtils::GetAsBlock(aCandidate);
|
2007-10-19 10:41:29 -07: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!");
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2007-10-19 10:41:29 -07:00
|
|
|
}
|
|
|
|
|
2013-07-25 08:34:22 -07:00
|
|
|
void
|
|
|
|
nsBlockFrame::ComputeFinalHeight(const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus* aStatus,
|
|
|
|
nscoord aContentHeight,
|
|
|
|
const nsMargin& aBorderPadding,
|
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
nscoord aConsumed)
|
|
|
|
{
|
|
|
|
|
|
|
|
// Figure out how much of the computed height should be
|
|
|
|
// applied to this frame.
|
|
|
|
nscoord computedHeightLeftOver = GetEffectiveComputedHeight(aReflowState,
|
|
|
|
aConsumed);
|
|
|
|
NS_ASSERTION(!( IS_TRUE_OVERFLOW_CONTAINER(this)
|
|
|
|
&& computedHeightLeftOver ),
|
|
|
|
"overflow container must not have computedHeightLeftOver");
|
|
|
|
|
2013-12-27 09:59:52 -08:00
|
|
|
aMetrics.Height() =
|
2013-07-25 08:34:22 -07:00
|
|
|
NSCoordSaturatingAdd(NSCoordSaturatingAdd(aBorderPadding.top,
|
|
|
|
computedHeightLeftOver),
|
|
|
|
aBorderPadding.bottom);
|
|
|
|
|
|
|
|
if (NS_FRAME_IS_NOT_COMPLETE(*aStatus)
|
2013-12-27 09:59:52 -08:00
|
|
|
&& aMetrics.Height() < aReflowState.AvailableHeight()) {
|
2013-07-25 08:34:22 -07:00
|
|
|
// We ran out of height on this page but we're incomplete
|
|
|
|
// Set status to complete except for overflow
|
|
|
|
NS_FRAME_SET_OVERFLOW_INCOMPLETE(*aStatus);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_FRAME_IS_COMPLETE(*aStatus)) {
|
|
|
|
if (computedHeightLeftOver > 0 &&
|
2013-12-27 09:59:21 -08:00
|
|
|
NS_UNCONSTRAINEDSIZE != aReflowState.AvailableHeight() &&
|
2013-12-27 09:59:52 -08:00
|
|
|
aMetrics.Height() > aReflowState.AvailableHeight()) {
|
2013-07-25 08:34:22 -07:00
|
|
|
if (ShouldAvoidBreakInside(aReflowState)) {
|
|
|
|
*aStatus = NS_INLINE_LINE_BREAK_BEFORE();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// 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.
|
2013-12-27 09:59:52 -08:00
|
|
|
aMetrics.Height() = std::max(aReflowState.AvailableHeight(),
|
2013-07-25 08:34:22 -07:00
|
|
|
aContentHeight);
|
|
|
|
NS_FRAME_SET_INCOMPLETE(*aStatus);
|
|
|
|
if (!GetNextInFlow())
|
|
|
|
*aStatus |= NS_FRAME_REFLOW_NEXTINFLOW;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef IBMBIDI
|
2007-05-28 07:40:56 -07:00
|
|
|
nsresult
|
|
|
|
nsBlockFrame::ResolveBidi()
|
|
|
|
{
|
2007-09-02 23:51:11 -07:00
|
|
|
NS_ASSERTION(!GetPrevInFlow(),
|
|
|
|
"ResolveBidi called on non-first continuation");
|
|
|
|
|
|
|
|
nsPresContext* presContext = PresContext();
|
|
|
|
if (!presContext->BidiEnabled()) {
|
2007-05-28 07:40:56 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-04-13 02:23:49 -07:00
|
|
|
return nsBidiPresUtils::Resolve(this);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
void
|
2011-09-28 23:19:26 -07:00
|
|
|
nsBlockFrame::VerifyLines(bool aFinalCheckOK)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
if (!gVerifyLines) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (mLines.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-05-03 17:14:01 -07:00
|
|
|
nsLineBox* cursor = GetLineCursor();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Add up the counts on each line. Also validate that IsFirstLine is
|
|
|
|
// set properly.
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t count = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
line_iterator line, line_end;
|
|
|
|
for (line = begin_lines(), line_end = end_lines();
|
|
|
|
line != line_end;
|
|
|
|
++line) {
|
2012-05-03 17:14:01 -07:00
|
|
|
if (line == cursor) {
|
2012-07-30 07:20:58 -07:00
|
|
|
cursor = nullptr;
|
2012-05-03 17:14:01 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
if (aFinalCheckOK) {
|
|
|
|
NS_ABORT_IF_FALSE(line->GetChildCount(), "empty line");
|
|
|
|
if (line->IsBlock()) {
|
|
|
|
NS_ASSERTION(1 == line->GetChildCount(), "bad first line");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
count += line->GetChildCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Then count the frames
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t frameCount = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIFrame* frame = mLines.front()->mFirstChild;
|
|
|
|
while (frame) {
|
|
|
|
frameCount++;
|
|
|
|
frame = frame->GetNextSibling();
|
|
|
|
}
|
|
|
|
NS_ASSERTION(count == frameCount, "bad line list");
|
|
|
|
|
|
|
|
// Next: test that each line has right number of frames on it
|
|
|
|
for (line = begin_lines(), line_end = end_lines();
|
|
|
|
line != line_end;
|
|
|
|
) {
|
|
|
|
count = line->GetChildCount();
|
|
|
|
frame = line->mFirstChild;
|
|
|
|
while (--count >= 0) {
|
|
|
|
frame = frame->GetNextSibling();
|
|
|
|
}
|
|
|
|
++line;
|
|
|
|
if ((line != line_end) && (0 != line->GetChildCount())) {
|
|
|
|
NS_ASSERTION(frame == line->mFirstChild, "bad line list");
|
|
|
|
}
|
|
|
|
}
|
2012-05-03 17:14:01 -07:00
|
|
|
|
|
|
|
if (cursor) {
|
|
|
|
FrameLines* overflowLines = GetOverflowLines();
|
|
|
|
if (overflowLines) {
|
|
|
|
line_iterator line = overflowLines->mLines.begin();
|
|
|
|
line_iterator line_end = overflowLines->mLines.end();
|
|
|
|
for (; line != line_end; ++line) {
|
|
|
|
if (line == cursor) {
|
2012-07-30 07:20:58 -07:00
|
|
|
cursor = nullptr;
|
2012-05-03 17:14:01 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_ASSERTION(!cursor, "stale LineCursorProperty");
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsBlockFrame::VerifyOverflowSituation()
|
|
|
|
{
|
2013-09-25 04:42:34 -07:00
|
|
|
nsBlockFrame* flow = static_cast<nsBlockFrame*>(FirstInFlow());
|
2012-03-07 17:57:37 -08:00
|
|
|
while (flow) {
|
2012-05-03 17:14:01 -07:00
|
|
|
FrameLines* overflowLines = flow->GetOverflowLines();
|
2012-03-07 17:57:37 -08:00
|
|
|
if (overflowLines) {
|
|
|
|
NS_ASSERTION(!overflowLines->mLines.empty(),
|
|
|
|
"should not be empty if present");
|
|
|
|
NS_ASSERTION(overflowLines->mLines.front()->mFirstChild,
|
|
|
|
"bad overflow lines");
|
|
|
|
NS_ASSERTION(overflowLines->mLines.front()->mFirstChild ==
|
|
|
|
overflowLines->mFrames.FirstChild(),
|
|
|
|
"bad overflow frames / lines");
|
|
|
|
}
|
2012-05-03 17:14:01 -07:00
|
|
|
nsLineBox* cursor = flow->GetLineCursor();
|
|
|
|
if (cursor) {
|
|
|
|
line_iterator line = flow->begin_lines();
|
|
|
|
line_iterator line_end = flow->end_lines();
|
|
|
|
for (; line != line_end && line != cursor; ++line)
|
|
|
|
;
|
|
|
|
if (line == line_end && overflowLines) {
|
|
|
|
line = overflowLines->mLines.begin();
|
|
|
|
line_end = overflowLines->mLines.end();
|
|
|
|
for (; line != line_end && line != cursor; ++line)
|
|
|
|
;
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(line != line_end, "stale LineCursorProperty");
|
|
|
|
}
|
2012-03-07 17:57:37 -08:00
|
|
|
flow = static_cast<nsBlockFrame*>(flow->GetNextInFlow());
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t
|
2007-03-22 10:30:00 -07:00
|
|
|
nsBlockFrame::GetDepth() const
|
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t depth = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIFrame* parent = mParent;
|
|
|
|
while (parent) {
|
|
|
|
parent = parent->GetParent();
|
|
|
|
depth++;
|
|
|
|
}
|
|
|
|
return depth;
|
|
|
|
}
|
|
|
|
#endif
|