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
|
|
|
* This Original Code has been modified by IBM Corporation. Modifications made by IBM
|
|
|
|
* described herein are Copyright (c) International Business Machines Corporation, 2000.
|
|
|
|
* Modifications to Mozilla code or documentation identified per MPL Section 3.3
|
|
|
|
*
|
|
|
|
* Date Modified by Description of modification
|
|
|
|
* 04/20/2000 IBM Corp. OS/2 VisualAge build.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* state and methods used while laying out a single line of a block frame */
|
|
|
|
|
|
|
|
#ifndef nsLineLayout_h___
|
|
|
|
#define nsLineLayout_h___
|
|
|
|
|
|
|
|
#include "nsLineBox.h"
|
|
|
|
#include "nsBlockReflowState.h"
|
|
|
|
#include "plarena.h"
|
2008-07-24 00:16:18 -07:00
|
|
|
#include "gfxTypes.h"
|
2014-03-11 13:23:50 -07:00
|
|
|
#include "WritingModes.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-01-04 16:39:54 -08:00
|
|
|
class nsFloatManager;
|
2007-03-22 10:30:00 -07:00
|
|
|
struct nsStyleText;
|
|
|
|
|
|
|
|
class nsLineLayout {
|
|
|
|
public:
|
|
|
|
nsLineLayout(nsPresContext* aPresContext,
|
2009-01-04 16:39:54 -08:00
|
|
|
nsFloatManager* aFloatManager,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsHTMLReflowState* aOuterReflowState,
|
|
|
|
const nsLineList::iterator* aLine);
|
|
|
|
~nsLineLayout();
|
|
|
|
|
2014-03-11 13:23:50 -07:00
|
|
|
void Init(nsBlockReflowState* aState, nscoord aMinLineBSize,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aLineNumber) {
|
2007-03-22 10:30:00 -07:00
|
|
|
mBlockRS = aState;
|
2014-03-11 13:23:50 -07:00
|
|
|
mMinLineBSize = aMinLineBSize;
|
2007-03-22 10:30:00 -07:00
|
|
|
mLineNumber = aLineNumber;
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t GetLineNumber() const {
|
2007-03-22 10:30:00 -07:00
|
|
|
return mLineNumber;
|
|
|
|
}
|
|
|
|
|
2014-03-11 13:23:50 -07:00
|
|
|
void BeginLineReflow(nscoord aICoord, nscoord aBCoord,
|
|
|
|
nscoord aISize, nscoord aBSize,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aImpactedByFloats,
|
2011-10-18 05:51:58 -07:00
|
|
|
bool aIsTopOfPage,
|
2014-03-11 13:23:50 -07:00
|
|
|
mozilla::WritingMode aWritingMode,
|
|
|
|
nscoord aContainerWidth);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
void EndLineReflow();
|
|
|
|
|
2008-06-10 16:53:22 -07:00
|
|
|
/**
|
|
|
|
* Called when a float has been placed. This method updates the
|
|
|
|
* inline frame and span data to account for any change in positions
|
|
|
|
* due to available space for the line boxes changing.
|
|
|
|
* @param aX/aY/aWidth/aHeight are the new available
|
|
|
|
* space rectangle, relative to the containing block.
|
|
|
|
* @param aFloatFrame the float frame that was placed.
|
|
|
|
*/
|
|
|
|
void UpdateBand(const nsRect& aNewAvailableSpace,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIFrame* aFloatFrame);
|
|
|
|
|
2013-02-23 02:38:15 -08:00
|
|
|
void BeginSpan(nsIFrame* aFrame, const nsHTMLReflowState* aSpanReflowState,
|
|
|
|
nscoord aLeftEdge, nscoord aRightEdge, nscoord* aBaseline);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-12-12 13:51:18 -08:00
|
|
|
// Returns the width of the span
|
|
|
|
nscoord EndSpan(nsIFrame* aFrame);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t GetCurrentSpanCount() const;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
void SplitLineTo(int32_t aNewCount);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-03-11 13:23:50 -07:00
|
|
|
bool IsZeroBSize();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
// Reflows the frame and returns the reflow status. aPushedFrame is true
|
2014-05-12 17:47:53 -07:00
|
|
|
// if the frame is pushed to the next line because it doesn't fit.
|
|
|
|
void ReflowFrame(nsIFrame* aFrame,
|
|
|
|
nsReflowStatus& aReflowStatus,
|
|
|
|
nsHTMLReflowMetrics* aMetrics,
|
|
|
|
bool& aPushedFrame);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-02-23 02:38:15 -08:00
|
|
|
void AddBulletFrame(nsIFrame* aFrame, const nsHTMLReflowMetrics& aMetrics);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
void RemoveBulletFrame(nsIFrame* aFrame) {
|
|
|
|
PushFrame(aFrame);
|
|
|
|
}
|
|
|
|
|
2014-03-11 13:23:50 -07:00
|
|
|
void BlockDirAlignLine();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool TrimTrailingWhiteSpace();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-04-16 01:03:28 -07:00
|
|
|
void InlineDirAlignFrames(nsLineBox* aLine, bool aIsLastLine);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle all the relative positioning in the line, compute the
|
|
|
|
* combined area (== overflow area) for the line, and handle view
|
2009-04-05 17:31:50 -07:00
|
|
|
* sizing/positioning and the setting of the overflow rect.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2010-10-06 21:25:45 -07:00
|
|
|
void RelativePositionFrames(nsOverflowAreas& aOverflowAreas);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-10-01 19:36:26 -07:00
|
|
|
// Support methods for word-wrapping during line reflow
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
void SetTextJustificationWeights(int32_t aNumSpaces, int32_t aNumLetters) {
|
2007-03-22 10:30:00 -07:00
|
|
|
mTextJustificationNumSpaces = aNumSpaces;
|
|
|
|
mTextJustificationNumLetters = aNumLetters;
|
|
|
|
}
|
|
|
|
|
2008-06-14 01:28:07 -07:00
|
|
|
/**
|
|
|
|
* @return true if so far during reflow no non-empty content has been
|
2010-03-09 16:14:14 -08:00
|
|
|
* placed in the line (according to nsIFrame::IsEmpty())
|
2008-06-14 01:28:07 -07:00
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool LineIsEmpty() const
|
2008-06-14 01:28:07 -07:00
|
|
|
{
|
2012-09-27 18:56:40 -07:00
|
|
|
return mLineIsEmpty;
|
2008-06-14 01:28:07 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-03-09 16:14:14 -08:00
|
|
|
/**
|
|
|
|
* @return true if so far during reflow no non-empty leaf content
|
|
|
|
* (non-collapsed whitespace, replaced element, inline-block, etc) has been
|
|
|
|
* placed in the line
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool LineAtStart() const
|
2010-03-09 16:14:14 -08:00
|
|
|
{
|
2012-09-27 18:56:40 -07:00
|
|
|
return mLineAtStart;
|
2010-03-09 16:14:14 -08:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool LineIsBreakable() const;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool GetLineEndsInBR() const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-09-27 18:56:40 -07:00
|
|
|
return mLineEndsInBR;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
void SetLineEndsInBR(bool aOn)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-09-27 18:56:40 -07:00
|
|
|
mLineEndsInBR = aOn;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------
|
|
|
|
// Inform the line-layout about the presence of a floating frame
|
|
|
|
// XXX get rid of this: use get-frame-type?
|
2011-09-28 23:19:26 -07:00
|
|
|
bool AddFloat(nsIFrame* aFloat, nscoord aAvailableWidth)
|
2009-08-31 11:25:35 -07:00
|
|
|
{
|
2010-08-05 21:59:20 -07:00
|
|
|
return mBlockRS->AddFloat(this, aFloat, aAvailableWidth);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2007-10-20 00:30:26 -07:00
|
|
|
void SetTrimmableWidth(nscoord aTrimmableWidth) {
|
|
|
|
mTrimmableWidth = aTrimmableWidth;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool GetFirstLetterStyleOK() const {
|
2012-09-27 18:56:40 -07:00
|
|
|
return mFirstLetterStyleOK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
void SetFirstLetterStyleOK(bool aSetting) {
|
2012-09-27 18:56:40 -07:00
|
|
|
mFirstLetterStyleOK = aSetting;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool GetInFirstLetter() const {
|
2012-09-27 18:56:40 -07:00
|
|
|
return mInFirstLetter;
|
2009-01-04 16:36:56 -08:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
void SetInFirstLetter(bool aSetting) {
|
2012-09-27 18:56:40 -07:00
|
|
|
mInFirstLetter = aSetting;
|
2009-01-04 16:36:56 -08:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool GetInFirstLine() const {
|
2012-09-27 18:56:40 -07:00
|
|
|
return mInFirstLine;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
void SetInFirstLine(bool aSetting) {
|
2012-09-27 18:56:40 -07:00
|
|
|
mInFirstLine = aSetting;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2009-10-26 18:43:56 -07:00
|
|
|
// Calling this during block reflow ensures that the next line of inlines
|
|
|
|
// will be marked dirty, if there is one.
|
|
|
|
void SetDirtyNextLine() {
|
2012-09-27 18:56:40 -07:00
|
|
|
mDirtyNextLine = true;
|
2009-10-26 18:43:56 -07:00
|
|
|
}
|
2011-09-28 23:19:26 -07:00
|
|
|
bool GetDirtyNextLine() {
|
2012-09-27 18:56:40 -07:00
|
|
|
return mDirtyNextLine;
|
2009-10-26 18:43:56 -07:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
//----------------------------------------
|
|
|
|
|
|
|
|
nsPresContext* mPresContext;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Record where an optional break could have been placed. During line reflow,
|
|
|
|
* frames containing optional break points (e.g., whitespace in text frames)
|
|
|
|
* can call SetLastOptionalBreakPosition to record where a break could
|
|
|
|
* have been made, but wasn't because we decided to place more content on
|
|
|
|
* the line. For non-text frames, offset 0 means
|
2012-09-27 23:57:33 -07:00
|
|
|
* before the content, offset INT32_MAX means after the content.
|
2007-03-22 10:30:00 -07:00
|
|
|
*
|
|
|
|
* Currently this is used to handle cases where a single word comprises
|
|
|
|
* multiple frames, and the first frame fits on the line but the whole word
|
|
|
|
* doesn't. We look back to the last optional break position and
|
|
|
|
* reflow the whole line again, forcing a break at that position. The last
|
|
|
|
* optional break position could be in a text frame or else after a frame
|
|
|
|
* that cannot be part of a text run, so those are the positions we record.
|
|
|
|
*
|
|
|
|
* @param aFits set to true if the break position is within the available width.
|
|
|
|
*
|
2008-07-24 00:16:18 -07:00
|
|
|
* @param aPriority the priority of the break opportunity. If we are
|
|
|
|
* prioritizing break opportunities, we will not set a break if we have
|
|
|
|
* already set a break with a higher priority. @see gfxBreakPriority.
|
|
|
|
*
|
2011-10-17 07:59:28 -07:00
|
|
|
* @return true if we are actually reflowing with forced break position and we
|
2007-03-22 10:30:00 -07:00
|
|
|
* should break here
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
bool NotifyOptionalBreakPosition(nsIContent* aContent, int32_t aOffset,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aFits, gfxBreakPriority aPriority) {
|
2012-09-27 18:56:40 -07:00
|
|
|
NS_ASSERTION(!aFits || !mNeedBackup,
|
2007-12-07 01:17:19 -08:00
|
|
|
"Shouldn't be updating the break position with a break that fits after we've already flagged an overrun");
|
2007-03-22 10:30:00 -07:00
|
|
|
// Remember the last break position that fits; if there was no break that fit,
|
|
|
|
// just remember the first break
|
2008-07-24 00:16:18 -07:00
|
|
|
if ((aFits && aPriority >= mLastOptionalBreakPriority) ||
|
|
|
|
!mLastOptionalBreakContent) {
|
2007-03-22 10:30:00 -07:00
|
|
|
mLastOptionalBreakContent = aContent;
|
|
|
|
mLastOptionalBreakContentOffset = aOffset;
|
2008-07-24 00:16:18 -07:00
|
|
|
mLastOptionalBreakPriority = aPriority;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
return aContent && mForceBreakContent == aContent &&
|
|
|
|
mForceBreakContentOffset == aOffset;
|
|
|
|
}
|
|
|
|
/**
|
2012-09-27 18:56:40 -07:00
|
|
|
* Like NotifyOptionalBreakPosition, but here it's OK for mNeedBackup
|
2007-03-22 10:30:00 -07:00
|
|
|
* to be set, because the caller is merely pruning some saved break position(s)
|
|
|
|
* that are actually not feasible.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
void RestoreSavedBreakPosition(nsIContent* aContent, int32_t aOffset,
|
2008-07-24 00:16:18 -07:00
|
|
|
gfxBreakPriority aPriority) {
|
2007-03-22 10:30:00 -07:00
|
|
|
mLastOptionalBreakContent = aContent;
|
|
|
|
mLastOptionalBreakContentOffset = aOffset;
|
2008-07-24 00:16:18 -07:00
|
|
|
mLastOptionalBreakPriority = aPriority;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Signal that no backing up will be required after all.
|
|
|
|
*/
|
|
|
|
void ClearOptionalBreakPosition() {
|
2012-09-27 18:56:40 -07:00
|
|
|
mNeedBackup = false;
|
2012-07-30 07:20:58 -07:00
|
|
|
mLastOptionalBreakContent = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
mLastOptionalBreakContentOffset = -1;
|
2014-01-23 10:26:39 -08:00
|
|
|
mLastOptionalBreakPriority = gfxBreakPriority::eNoBreak;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
// Retrieve last set optional break position. When this returns null, no
|
|
|
|
// optional break has been recorded (which means that the line can't break yet).
|
2012-08-22 08:56:38 -07:00
|
|
|
nsIContent* GetLastOptionalBreakPosition(int32_t* aOffset,
|
2008-07-24 00:16:18 -07:00
|
|
|
gfxBreakPriority* aPriority) {
|
2007-03-22 10:30:00 -07:00
|
|
|
*aOffset = mLastOptionalBreakContentOffset;
|
2008-07-24 00:16:18 -07:00
|
|
|
*aPriority = mLastOptionalBreakPriority;
|
2007-03-22 10:30:00 -07:00
|
|
|
return mLastOptionalBreakContent;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check whether frames overflowed the available width and CanPlaceFrame
|
|
|
|
* requested backing up to a saved break position.
|
|
|
|
*/
|
2012-09-27 18:56:40 -07:00
|
|
|
bool NeedsBackup() { return mNeedBackup; }
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Line layout may place too much content on a line, overflowing its available
|
|
|
|
// width. When that happens, if SetLastOptionalBreakPosition has been
|
|
|
|
// used to record an optional break that wasn't taken, we can reflow the line
|
|
|
|
// again and force the break to happen at that point (i.e., backtracking
|
|
|
|
// to the last choice point).
|
|
|
|
|
|
|
|
// Record that we want to break at the given content+offset (which
|
|
|
|
// should have been previously returned by GetLastOptionalBreakPosition
|
|
|
|
// from another nsLineLayout).
|
2012-08-22 08:56:38 -07:00
|
|
|
void ForceBreakAtPosition(nsIContent* aContent, int32_t aOffset) {
|
2007-03-22 10:30:00 -07:00
|
|
|
mForceBreakContent = aContent;
|
|
|
|
mForceBreakContentOffset = aOffset;
|
|
|
|
}
|
2012-07-30 07:20:58 -07:00
|
|
|
bool HaveForcedBreakPosition() { return mForceBreakContent != nullptr; }
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t GetForcedBreakPosition(nsIContent* aContent) {
|
2007-03-22 10:30:00 -07:00
|
|
|
return mForceBreakContent == aContent ? mForceBreakContentOffset : -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This can't be null. It usually returns a block frame but may return
|
|
|
|
* some other kind of frame when inline frames are reflowed in a non-block
|
2008-07-29 22:11:26 -07:00
|
|
|
* context (e.g. MathML or floating first-letter).
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2013-04-22 18:45:26 -07:00
|
|
|
nsIFrame* LineContainerFrame() const { return mBlockReflowState->frame; }
|
|
|
|
const nsHTMLReflowState* LineContainerRS() const { return mBlockReflowState; }
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsLineList::iterator* GetLine() const {
|
2012-09-27 18:56:40 -07:00
|
|
|
return mGotLineBox ? &mLineBox : nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2010-08-05 21:59:20 -07:00
|
|
|
nsLineList::iterator* GetLine() {
|
2012-09-27 18:56:40 -07:00
|
|
|
return mGotLineBox ? &mLineBox : nullptr;
|
2010-08-05 21:59:20 -07:00
|
|
|
}
|
2007-05-20 20:44:26 -07:00
|
|
|
|
|
|
|
/**
|
2008-06-19 21:39:56 -07:00
|
|
|
* Returns the accumulated advance width of frames before the current frame
|
|
|
|
* on the line, plus the line container's left border+padding.
|
|
|
|
* This is always positive, the advance width is measured from
|
2007-05-20 20:44:26 -07:00
|
|
|
* the right edge for RTL blocks and from the left edge for LTR blocks.
|
2008-06-19 21:39:56 -07:00
|
|
|
* In other words, the current frame's distance from the line container's
|
|
|
|
* start content edge is:
|
2014-03-11 13:23:50 -07:00
|
|
|
* <code>GetCurrentFrameInlineDistanceFromBlock() - lineContainer->GetUsedBorderAndPadding().left</code>
|
2008-06-19 21:39:56 -07:00
|
|
|
* Note the use of <code>.left</code> for both LTR and RTL line containers.
|
2007-05-20 20:44:26 -07:00
|
|
|
*/
|
2014-03-11 13:23:50 -07:00
|
|
|
nscoord GetCurrentFrameInlineDistanceFromBlock();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
protected:
|
|
|
|
// This state is constant for a given block frame doing line layout
|
2009-01-04 16:39:54 -08:00
|
|
|
nsFloatManager* mFloatManager;
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsStyleText* mStyleText; // for the block
|
|
|
|
const nsHTMLReflowState* mBlockReflowState;
|
|
|
|
|
|
|
|
nsIContent* mLastOptionalBreakContent;
|
|
|
|
nsIContent* mForceBreakContent;
|
|
|
|
|
|
|
|
// XXX remove this when landing bug 154892 (splitting absolute positioned frames)
|
|
|
|
friend class nsInlineFrame;
|
|
|
|
|
|
|
|
nsBlockReflowState* mBlockRS;/* XXX hack! */
|
|
|
|
|
|
|
|
nsLineList::iterator mLineBox;
|
|
|
|
|
|
|
|
// Per-frame data recorded by the line-layout reflow logic. This
|
|
|
|
// state is the state needed to post-process the line after reflow
|
2014-03-11 13:23:50 -07:00
|
|
|
// has completed (block-direction alignment, inline-direction alignment,
|
2007-03-22 10:30:00 -07:00
|
|
|
// justification and relative positioning).
|
|
|
|
|
|
|
|
struct PerSpanData;
|
|
|
|
struct PerFrameData;
|
|
|
|
friend struct PerSpanData;
|
|
|
|
friend struct PerFrameData;
|
2014-03-11 13:23:50 -07:00
|
|
|
struct PerFrameData
|
|
|
|
{
|
|
|
|
PerFrameData(mozilla::WritingMode aWritingMode)
|
|
|
|
: mBounds(aWritingMode)
|
|
|
|
, mMargin(aWritingMode)
|
|
|
|
, mBorderPadding(aWritingMode)
|
|
|
|
, mOffsets(aWritingMode)
|
|
|
|
{}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// link to next/prev frame in same span
|
|
|
|
PerFrameData* mNext;
|
|
|
|
PerFrameData* mPrev;
|
|
|
|
|
|
|
|
// pointer to child span data if this is an inline container frame
|
|
|
|
PerSpanData* mSpan;
|
|
|
|
|
2009-02-19 13:55:48 -08:00
|
|
|
// The frame
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIFrame* mFrame;
|
|
|
|
|
|
|
|
// From metrics
|
|
|
|
nscoord mAscent;
|
2014-03-11 13:23:50 -07:00
|
|
|
// note that mBounds is a logical rect in the *line*'s writing mode.
|
|
|
|
// When setting frame coordinates, we have to convert to the frame's
|
|
|
|
// writing mode
|
|
|
|
mozilla::LogicalRect mBounds;
|
2010-10-06 21:25:45 -07:00
|
|
|
nsOverflowAreas mOverflowAreas;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// From reflow-state
|
2014-03-11 13:23:50 -07:00
|
|
|
mozilla::LogicalMargin mMargin;
|
|
|
|
mozilla::LogicalMargin mBorderPadding;
|
|
|
|
mozilla::LogicalMargin mOffsets;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// state for text justification
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t mJustificationNumSpaces;
|
|
|
|
int32_t mJustificationNumLetters;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Other state we use
|
2014-03-11 13:23:50 -07:00
|
|
|
uint8_t mBlockDirAlign;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// PerFrameData flags
|
|
|
|
#define PFD_RELATIVEPOS 0x00000001
|
|
|
|
#define PFD_ISTEXTFRAME 0x00000002
|
|
|
|
#define PFD_ISNONEMPTYTEXTFRAME 0x00000004
|
|
|
|
#define PFD_ISNONWHITESPACETEXTFRAME 0x00000008
|
|
|
|
#define PFD_ISLETTERFRAME 0x00000010
|
2007-09-23 19:19:14 -07:00
|
|
|
#define PFD_RECOMPUTEOVERFLOW 0x00000020
|
2007-03-22 10:30:00 -07:00
|
|
|
#define PFD_ISBULLET 0x00000040
|
|
|
|
#define PFD_SKIPWHENTRIMMINGWHITESPACE 0x00000080
|
|
|
|
#define PFD_LASTFLAG PFD_SKIPWHENTRIMMINGWHITESPACE
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t mFlags;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
void SetFlag(uint32_t aFlag, bool aValue)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
NS_ASSERTION(aFlag<=PFD_LASTFLAG, "bad flag");
|
2012-09-27 23:57:33 -07:00
|
|
|
NS_ASSERTION(aFlag<=UINT8_MAX, "bad flag");
|
2007-03-22 10:30:00 -07:00
|
|
|
if (aValue) { // set flag
|
|
|
|
mFlags |= aFlag;
|
|
|
|
}
|
|
|
|
else { // unset flag
|
|
|
|
mFlags &= ~aFlag;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
bool GetFlag(uint32_t aFlag) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
NS_ASSERTION(aFlag<=PFD_LASTFLAG, "bad flag");
|
2007-10-09 17:00:05 -07:00
|
|
|
return !!(mFlags & aFlag);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PerFrameData* Last() {
|
|
|
|
PerFrameData* pfd = this;
|
|
|
|
while (pfd->mNext) {
|
|
|
|
pfd = pfd->mNext;
|
|
|
|
}
|
|
|
|
return pfd;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
PerFrameData* mFrameFreeList;
|
|
|
|
|
|
|
|
struct PerSpanData {
|
|
|
|
union {
|
|
|
|
PerSpanData* mParent;
|
|
|
|
PerSpanData* mNextFreeSpan;
|
|
|
|
};
|
|
|
|
PerFrameData* mFrame;
|
|
|
|
PerFrameData* mFirstFrame;
|
|
|
|
PerFrameData* mLastFrame;
|
|
|
|
|
|
|
|
const nsHTMLReflowState* mReflowState;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mNoWrap;
|
2014-03-11 13:23:50 -07:00
|
|
|
mozilla::WritingMode mWritingMode;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mZeroEffectiveSpanBox;
|
|
|
|
bool mContainsFloat;
|
|
|
|
bool mHasNonemptyContent;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-03-11 13:23:50 -07:00
|
|
|
nscoord mIStart;
|
|
|
|
nscoord mICoord;
|
|
|
|
nscoord mIEnd;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-03-11 13:23:50 -07:00
|
|
|
nscoord mBStartLeading, mBEndLeading;
|
|
|
|
nscoord mLogicalBSize;
|
|
|
|
nscoord mMinBCoord, mMaxBCoord;
|
2011-08-03 11:30:58 -07:00
|
|
|
nscoord* mBaseline;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
void AppendFrame(PerFrameData* pfd) {
|
2012-07-30 07:20:58 -07:00
|
|
|
if (nullptr == mLastFrame) {
|
2007-03-22 10:30:00 -07:00
|
|
|
mFirstFrame = pfd;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mLastFrame->mNext = pfd;
|
|
|
|
pfd->mPrev = mLastFrame;
|
|
|
|
}
|
|
|
|
mLastFrame = pfd;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
PerSpanData* mSpanFreeList;
|
|
|
|
PerSpanData* mRootSpan;
|
|
|
|
PerSpanData* mCurrentSpan;
|
2009-05-12 01:53:06 -07:00
|
|
|
|
|
|
|
gfxBreakPriority mLastOptionalBreakPriority;
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t mLastOptionalBreakContentOffset;
|
|
|
|
int32_t mForceBreakContentOffset;
|
2009-05-12 01:53:06 -07:00
|
|
|
|
2014-03-11 13:23:50 -07:00
|
|
|
nscoord mMinLineBSize;
|
2009-05-12 01:53:06 -07:00
|
|
|
|
|
|
|
// The amount of text indent that we applied to this line, needed for
|
|
|
|
// max-element-size calculation.
|
|
|
|
nscoord mTextIndent;
|
|
|
|
|
|
|
|
// This state varies during the reflow of a line but is line
|
|
|
|
// "global" state not span "local" state.
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t mLineNumber;
|
|
|
|
int32_t mTextJustificationNumSpaces;
|
|
|
|
int32_t mTextJustificationNumLetters;
|
2009-05-12 01:53:06 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t mTotalPlacedFrames;
|
2009-05-12 01:53:06 -07:00
|
|
|
|
2014-03-11 13:23:50 -07:00
|
|
|
nscoord mBStartEdge;
|
|
|
|
nscoord mMaxStartBoxBSize;
|
|
|
|
nscoord mMaxEndBoxBSize;
|
2009-05-12 01:53:06 -07:00
|
|
|
|
2011-11-23 18:48:23 -08:00
|
|
|
nscoord mInflationMinFontSize;
|
|
|
|
|
2014-03-11 13:23:50 -07:00
|
|
|
// Final computed line-bSize value after BlockDirAlignFrames for
|
2009-05-12 01:53:06 -07:00
|
|
|
// the block has been called.
|
2014-03-11 13:23:50 -07:00
|
|
|
nscoord mFinalLineBSize;
|
2009-05-12 01:53:06 -07:00
|
|
|
|
|
|
|
// Amount of trimmable whitespace width for the trailing text frame, if any
|
|
|
|
nscoord mTrimmableWidth;
|
|
|
|
|
2014-03-11 13:23:50 -07:00
|
|
|
nscoord mContainerWidth;
|
|
|
|
|
2012-09-27 18:56:40 -07:00
|
|
|
bool mFirstLetterStyleOK : 1;
|
|
|
|
bool mIsTopOfPage : 1;
|
|
|
|
bool mImpactedByFloats : 1;
|
|
|
|
bool mLastFloatWasLetterFrame : 1;
|
|
|
|
bool mLineIsEmpty : 1;
|
|
|
|
bool mLineEndsInBR : 1;
|
|
|
|
bool mNeedBackup : 1;
|
|
|
|
bool mInFirstLine : 1;
|
|
|
|
bool mGotLineBox : 1;
|
|
|
|
bool mInFirstLetter : 1;
|
|
|
|
bool mHasBullet : 1;
|
|
|
|
bool mDirtyNextLine : 1;
|
|
|
|
bool mLineAtStart : 1;
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t mSpanDepth;
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef DEBUG
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t mSpansAllocated, mSpansFreed;
|
|
|
|
int32_t mFramesAllocated, mFramesFreed;
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
2009-05-12 01:53:06 -07:00
|
|
|
PLArenaPool mArena; // Per span and per frame data, 4 byte aligned
|
|
|
|
|
2013-02-23 02:38:15 -08:00
|
|
|
/**
|
|
|
|
* Allocate a PerFrameData from the mArena pool. The allocation is infallible.
|
|
|
|
*/
|
2014-03-11 13:23:50 -07:00
|
|
|
PerFrameData* NewPerFrameData(nsIFrame* aFrame);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-02-23 02:38:15 -08:00
|
|
|
/**
|
|
|
|
* Allocate a PerSpanData from the mArena pool. The allocation is infallible.
|
|
|
|
*/
|
|
|
|
PerSpanData* NewPerSpanData();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
void FreeSpan(PerSpanData* psd);
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool InBlockContext() const {
|
2007-03-22 10:30:00 -07:00
|
|
|
return mSpanDepth == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PushFrame(nsIFrame* aFrame);
|
|
|
|
|
2014-05-20 07:04:54 -07:00
|
|
|
void AllowForStartMargin(PerFrameData* pfd,
|
|
|
|
nsHTMLReflowState& aReflowState);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool CanPlaceFrame(PerFrameData* pfd,
|
|
|
|
bool aNotSafeToBreak,
|
|
|
|
bool aFrameCanContinueTextRun,
|
|
|
|
bool aCanRollBackBeforeFrame,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
2007-12-07 01:17:19 -08:00
|
|
|
nsReflowStatus& aStatus,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool* aOptionalBreakAfterFits);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
void PlaceFrame(PerFrameData* pfd,
|
|
|
|
nsHTMLReflowMetrics& aMetrics);
|
|
|
|
|
2014-03-11 13:23:50 -07:00
|
|
|
void BlockDirAlignFrames(PerSpanData* psd);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-03-11 13:23:50 -07:00
|
|
|
void PlaceStartEndFrames(PerSpanData* psd,
|
|
|
|
nscoord aDistanceFromStart,
|
|
|
|
nscoord aLineBSize);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-10-06 21:25:45 -07:00
|
|
|
void RelativePositionFrames(PerSpanData* psd, nsOverflowAreas& aOverflowAreas);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-03-11 13:23:50 -07:00
|
|
|
bool TrimTrailingWhiteSpaceIn(PerSpanData* psd, nscoord* aDeltaISize);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
void ComputeJustificationWeights(PerSpanData* psd, int32_t* numSpaces, int32_t* numLetters);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
struct FrameJustificationState {
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t mTotalNumSpaces;
|
|
|
|
int32_t mTotalNumLetters;
|
2007-03-22 10:30:00 -07:00
|
|
|
nscoord mTotalWidthForSpaces;
|
|
|
|
nscoord mTotalWidthForLetters;
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t mNumSpacesProcessed;
|
|
|
|
int32_t mNumLettersProcessed;
|
2007-03-22 10:30:00 -07:00
|
|
|
nscoord mWidthForSpacesProcessed;
|
|
|
|
nscoord mWidthForLettersProcessed;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Apply justification. The return value is the amount by which the width of
|
|
|
|
// the span corresponding to aPSD got increased due to justification.
|
|
|
|
nscoord ApplyFrameJustification(PerSpanData* aPSD,
|
|
|
|
FrameJustificationState* aState);
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2012-08-22 08:56:38 -07:00
|
|
|
void DumpPerSpanData(PerSpanData* psd, int32_t aIndent);
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsLineLayout_h___ */
|