Backed out changeset aeff4052ef00 (bug 789096)

This commit is contained in:
Carsten "Tomcat" Book 2014-03-11 09:22:52 +01:00
Родитель ea10325852
Коммит b99f5df532
13 изменённых файлов: 763 добавлений и 843 удалений

Просмотреть файл

@ -1228,10 +1228,8 @@ nsBidiPresUtils::ResolveParagraphWithinBlock(nsBlockFrame* aBlockFrame,
}
void
nsBidiPresUtils::ReorderFrames(nsIFrame* aFirstFrameOnLine,
int32_t aNumFramesOnLine,
WritingMode aLineWM,
nscoord& aLineWidth)
nsBidiPresUtils::ReorderFrames(nsIFrame* aFirstFrameOnLine,
int32_t aNumFramesOnLine)
{
// If this line consists of a line frame, reorder the line frame's children.
if (aFirstFrameOnLine->GetType() == nsGkAtoms::lineFrame) {
@ -1244,7 +1242,7 @@ nsBidiPresUtils::ReorderFrames(nsIFrame* aFirstFrameOnLine,
}
BidiLineData bld(aFirstFrameOnLine, aNumFramesOnLine);
RepositionInlineFrames(&bld, aFirstFrameOnLine, aLineWM, aLineWidth);
RepositionInlineFrames(&bld, aFirstFrameOnLine);
}
nsIFrame*
@ -1284,20 +1282,22 @@ nsBidiPresUtils::GetFrameBaseLevel(nsIFrame* aFrame)
}
void
nsBidiPresUtils::IsFirstOrLast(nsIFrame* aFrame,
nsContinuationStates* aContinuationStates,
bool& aIsFirst /* out */,
bool& aIsLast /* out */)
nsBidiPresUtils::IsLeftOrRightMost(nsIFrame* aFrame,
nsContinuationStates* aContinuationStates,
bool& aIsLeftMost /* out */,
bool& aIsRightMost /* out */)
{
const nsStyleVisibility* vis = aFrame->StyleVisibility();
bool isLTR = (NS_STYLE_DIRECTION_LTR == vis->mDirection);
/*
* Since we lay out frames in the line's direction, visiting a frame with
* 'mFirstVisualFrame == nullptr', means it's the first appearance of one
* of its continuation chain frames on the line.
* To determine if it's the last visual frame of its continuation chain on
* the line or not, we count the number of frames of the chain on the line,
* and then reduce it when we lay out a frame of the chain. If this value
* becomes 1 it means that it's the last visual frame of its continuation
* chain on this line.
* Since we lay out frames from left to right (in both LTR and RTL), visiting a
* frame with 'mFirstVisualFrame == nullptr', means it's the first appearance of
* one of its continuation chain frames on the line.
* To determine if it's the last visual frame of its continuation chain on the line
* or not, we count the number of frames of the chain on the line, and then reduce
* it when we lay out a frame of the chain. If this value becomes 1 it means
* that it's the last visual frame of its continuation chain on this line.
*/
nsFrameContinuationState* frameState = aContinuationStates->GetEntry(aFrame);
@ -1334,18 +1334,20 @@ nsBidiPresUtils::IsFirstOrLast(nsIFrame* aFrame,
}
frameState->mHasContOnNextLines = (frame != nullptr);
aIsFirst = !frameState->mHasContOnPrevLines;
aIsLeftMost = isLTR ? !frameState->mHasContOnPrevLines
: !frameState->mHasContOnNextLines;
firstFrameState = frameState;
} else {
// aFrame is not the first visual frame of its continuation chain
aIsFirst = false;
aIsLeftMost = false;
firstFrameState = aContinuationStates->GetEntry(frameState->mFirstVisualFrame);
}
aIsLast = (firstFrameState->mFrameCount == 1 &&
!firstFrameState->mHasContOnNextLines);
aIsRightMost = (firstFrameState->mFrameCount == 1) &&
(isLTR ? !firstFrameState->mHasContOnNextLines
: !firstFrameState->mHasContOnPrevLines);
if ((aIsFirst || aIsLast) &&
if ((aIsLeftMost || aIsRightMost) &&
(aFrame->GetStateBits() & NS_FRAME_PART_OF_IBSPLIT)) {
// For ib splits, don't treat anything except the last part as
// endmost or anything except the first part as startmost.
@ -1353,11 +1355,19 @@ nsBidiPresUtils::IsFirstOrLast(nsIFrame* aFrame,
nsIFrame* firstContinuation = aFrame->FirstContinuation();
if (firstContinuation->FrameIsNonLastInIBSplit()) {
// We are not endmost
aIsLast = false;
if (isLTR) {
aIsRightMost = false;
} else {
aIsLeftMost = false;
}
}
if (firstContinuation->FrameIsNonFirstInIBSplit()) {
// We are not startmost
aIsFirst = false;
if (isLTR) {
aIsLeftMost = false;
} else {
aIsRightMost = false;
}
}
}
@ -1366,39 +1376,29 @@ nsBidiPresUtils::IsFirstOrLast(nsIFrame* aFrame,
}
void
nsBidiPresUtils::RepositionFrame(nsIFrame* aFrame,
bool aIsEvenLevel,
nscoord& aStart,
nsContinuationStates* aContinuationStates,
WritingMode aLineWM,
nscoord& aLineWidth)
nsBidiPresUtils::RepositionFrame(nsIFrame* aFrame,
bool aIsOddLevel,
nscoord& aLeft,
nsContinuationStates* aContinuationStates)
{
if (!aFrame)
return;
bool isFirst, isLast;
IsFirstOrLast(aFrame,
aContinuationStates,
isFirst /* out */,
isLast /* out */);
bool isLeftMost, isRightMost;
IsLeftOrRightMost(aFrame,
aContinuationStates,
isLeftMost /* out */,
isRightMost /* out */);
WritingMode frameWM = aFrame->GetWritingMode();
nsInlineFrame* testFrame = do_QueryFrame(aFrame);
//XXX temporary until GetSkipSides is logicalized
bool isLeftMost = false, isRightMost = false;
if (testFrame) {
aFrame->AddStateBits(NS_INLINE_FRAME_BIDI_VISUAL_STATE_IS_SET);
isLeftMost = ((isFirst && frameWM.IsBidiLTR()) ||
(isLast && !frameWM.IsBidiLTR()));
if (isLeftMost)
aFrame->AddStateBits(NS_INLINE_FRAME_BIDI_VISUAL_IS_LEFT_MOST);
else
aFrame->RemoveStateBits(NS_INLINE_FRAME_BIDI_VISUAL_IS_LEFT_MOST);
isRightMost = ((isLast && frameWM.IsBidiLTR()) ||
(isFirst && !frameWM.IsBidiLTR()));
if (isRightMost)
aFrame->AddStateBits(NS_INLINE_FRAME_BIDI_VISUAL_IS_RIGHT_MOST);
else
@ -1407,30 +1407,26 @@ nsBidiPresUtils::RepositionFrame(nsIFrame* aFrame,
// This method is called from nsBlockFrame::PlaceLine via the call to
// bidiUtils->ReorderFrames, so this is guaranteed to be after the inlines
// have been reflowed, which is required for GetUsedMargin/Border/Padding
LogicalMargin margin(frameWM, aFrame->GetUsedMargin());
if (isFirst) {
aStart += margin.IStart(frameWM);
}
nsMargin margin = aFrame->GetUsedMargin();
if (isLeftMost)
aLeft += margin.left;
nscoord start = aStart;
nscoord frameWidth = aFrame->GetSize().width;
nscoord start = aLeft;
if (!IsBidiLeaf(aFrame))
{
nscoord iCoord = 0;
LogicalMargin borderPadding(frameWM, aFrame->GetUsedBorderAndPadding());
if (isFirst) {
iCoord += borderPadding.IStart(frameWM);
nscoord x = 0;
nsMargin borderPadding = aFrame->GetUsedBorderAndPadding();
if (isLeftMost) {
x += borderPadding.left;
}
// If the resolved direction of the container is different from the
// direction of the frame, we need to traverse the child list in reverse
// order, to make it O(n) we store the list locally and iterate the list
// in reverse
bool reverseOrder = aIsEvenLevel != frameWM.IsBidiLTR();
// If aIsOddLevel is true, so we need to traverse the child list
// in reverse order, to make it O(n) we store the list locally and
// iterate the list reversely
nsTArray<nsIFrame*> childList;
nsIFrame *frame = aFrame->GetFirstPrincipalChild();
if (frame && reverseOrder) {
if (frame && aIsOddLevel) {
childList.AppendElement((nsIFrame*)nullptr);
while (frame) {
childList.AppendElement(frame);
@ -1443,33 +1439,27 @@ nsBidiPresUtils::RepositionFrame(nsIFrame* aFrame,
int32_t index = 0;
while (frame) {
RepositionFrame(frame,
aIsEvenLevel,
iCoord,
aContinuationStates,
frameWM,
frameWidth);
aIsOddLevel,
x,
aContinuationStates);
index++;
frame = reverseOrder ?
frame = aIsOddLevel ?
childList[childList.Length() - index - 1] :
frame->GetNextSibling();
}
if (isLast) {
iCoord += borderPadding.IEnd(frameWM);
if (isRightMost) {
x += borderPadding.right;
}
aStart += iCoord;
aLeft += x;
} else {
aStart += frameWidth;
aLeft += aFrame->GetSize().width;
}
nsRect rect = aFrame->GetRect();
aFrame->SetRect(nsRect(start, rect.y, aLeft - start, rect.height));
LogicalRect logicalRect(aLineWM, aFrame->GetRect(), aLineWidth);
logicalRect.IStart(aLineWM) = start;
logicalRect.ISize(aLineWM) = aStart - start;
aFrame->SetRect(aLineWM, logicalRect, aLineWidth);
if (isLast) {
aStart += margin.IEnd(frameWM);
}
if (isRightMost)
aLeft += margin.right;
}
void
@ -1494,23 +1484,21 @@ nsBidiPresUtils::InitContinuationStates(nsIFrame* aFrame,
void
nsBidiPresUtils::RepositionInlineFrames(BidiLineData *aBld,
nsIFrame* aFirstChild,
WritingMode aLineWM,
nscoord& aLineWidth)
nsIFrame* aFirstChild)
{
nscoord startSpace = 0;
const nsStyleVisibility* vis = aFirstChild->StyleVisibility();
bool isLTR = (NS_STYLE_DIRECTION_LTR == vis->mDirection);
nscoord leftSpace = 0;
// This method is called from nsBlockFrame::PlaceLine via the call to
// bidiUtils->ReorderFrames, so this is guaranteed to be after the inlines
// have been reflowed, which is required for GetUsedMargin/Border/Padding
WritingMode frameWM = aFirstChild->GetWritingMode();
LogicalMargin margin(frameWM, aFirstChild->GetUsedMargin());
nsMargin margin = aFirstChild->GetUsedMargin();
if (!aFirstChild->GetPrevContinuation() &&
!aFirstChild->FrameIsNonFirstInIBSplit())
startSpace = margin.IStart(frameWM);
leftSpace = isLTR ? margin.left : margin.right;
nscoord start = LogicalRect(aLineWM, aFirstChild->GetRect(),
aLineWidth).IStart(aLineWM) - startSpace;
nscoord left = aFirstChild->GetPosition().x - leftSpace;
nsIFrame* frame;
int32_t count = aBld->mVisualFrames.Length();
int32_t index;
@ -1523,25 +1511,13 @@ nsBidiPresUtils::RepositionInlineFrames(BidiLineData *aBld,
}
// Reposition frames in visual order
int32_t step, limit;
if (aLineWM.IsBidiLTR()) {
index = 0;
step = 1;
limit = count;
} else {
index = count - 1;
step = -1;
limit = -1;
}
for (; index != limit; index += step) {
for (index = 0; index < count; index++) {
frame = aBld->VisualFrameAt(index);
RepositionFrame(frame,
!(aBld->mLevels[aBld->mIndexMap[index]] & 1),
start,
&continuationStates,
aLineWM,
aLineWidth);
}
(aBld->mLevels[aBld->mIndexMap[index]] & 1),
left,
&continuationStates);
} // for
}
bool

Просмотреть файл

@ -27,7 +27,6 @@ class nsRenderingContext;
class nsBlockInFlowLineIterator;
class nsStyleContext;
template<class T> class nsTHashtable;
namespace mozilla { class WritingMode; }
/**
* A structure representing some continuation state for each frame on the line,
@ -160,9 +159,7 @@ public:
* @lina 05/02/2000
*/
static void ReorderFrames(nsIFrame* aFirstFrameOnLine,
int32_t aNumFramesOnLine,
mozilla::WritingMode aLineWM,
nscoord& aLineWidth);
int32_t aNumFramesOnLine);
/**
* Format Unicode text, taking into account bidi capabilities
@ -382,25 +379,22 @@ private:
BidiParagraphData* aBpd);
/*
* Position aFrame and its descendants to their visual places. Also if aFrame
* is not leaf, resize it to embrace its children.
* Position aFrame and it's descendants to their visual places. Also if aFrame
* is not leaf, resize it to embrace it's children.
*
* @param aFrame The frame which itself and its children are
* going to be repositioned
* @param aIsEvenLevel TRUE means the embedding level of this frame
* is even (LTR)
* @param[in,out] aStart IN value is the starting position of aFrame
* (without considering its inline-start margin)
* OUT value will be the ending position of aFrame
* (after adding its inline-end margin)
* @param aFrame The frame which itself and its children are going
* to be repositioned
* @param aIsOddLevel TRUE means the embedding level of this frame is odd
* @param[in,out] aLeft IN value is the starting position of aFrame(without
* considering its left margin)
* OUT value will be the ending position of aFrame(after
* adding its right margin)
* @param aContinuationStates A map from nsIFrame* to nsFrameContinuationState
*/
static void RepositionFrame(nsIFrame* aFrame,
bool aIsEvenLevel,
nscoord& aStart,
nsContinuationStates* aContinuationStates,
mozilla::WritingMode aLineWM,
nscoord& aLineWidth);
bool aIsOddLevel,
nscoord& aLeft,
nsContinuationStates* aContinuationStates);
/*
* Initialize the continuation state(nsFrameContinuationState) to
@ -428,10 +422,10 @@ private:
* @param[out] aIsLeftMost TRUE means aFrame is leftmost frame or continuation
* @param[out] aIsRightMost TRUE means aFrame is rightmost frame or continuation
*/
static void IsFirstOrLast(nsIFrame* aFrame,
nsContinuationStates* aContinuationStates,
bool& aIsFirst /* out */,
bool& aIsLast /* out */);
static void IsLeftOrRightMost(nsIFrame* aFrame,
nsContinuationStates* aContinuationStates,
bool& aIsLeftMost /* out */,
bool& aIsRightMost /* out */);
/**
* Adjust frame positions following their visual order
@ -441,9 +435,7 @@ private:
* @lina 04/11/2000
*/
static void RepositionInlineFrames(BidiLineData* aBld,
nsIFrame* aFirstChild,
mozilla::WritingMode aLineWM,
nscoord& aLineWidth);
nsIFrame* aFirstChild);
/**
* Helper method for Resolve()

Просмотреть файл

@ -833,12 +833,6 @@ public:
*this : LogicalMargin(aToMode, GetPhysicalMargin(aFromMode));
}
bool IsEmpty() const
{
return (mMargin.left == 0 && mMargin.top == 0 &&
mMargin.right == 0 && mMargin.bottom == 0);
}
private:
friend class LogicalRect;
@ -1129,17 +1123,6 @@ public:
return aWritingMode.IsVertical() ? mRect.XMost() : mRect.YMost();
}
bool IsEmpty() const
{
return (mRect.x == 0 && mRect.y == 0 &&
mRect.width == 0 && mRect.height == 0);
}
bool IsZeroSize() const
{
return (mRect.width == 0 && mRect.height == 0);
}
/* XXX are these correct?
nscoord ILeft(WritingMode aWritingMode) const
{

Просмотреть файл

@ -1450,7 +1450,7 @@ nsBlockFrame::ComputeFinalSize(const nsHTMLReflowState& aReflowState,
*aBottomEdgeOfChildren = bottomEdgeOfChildren;
#ifdef DEBUG_blocks
if (CRAZY_SIZE(aMetrics.Width()) || CRAZY_SIZE(aMetrics.Height())) {
if (CRAZY_WIDTH(aMetrics.Width()) || CRAZY_HEIGHT(aMetrics.Height())) {
ListTag(stdout);
printf(": WARNING: desired:%d,%d\n", aMetrics.Width(), aMetrics.Height());
}
@ -3448,32 +3448,35 @@ nsBlockFrame::DoReflowInlineFrames(nsBlockReflowState& aState,
this, aFloatAvailableSpace.mHasFloats);
#endif
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;
nscoord x = aFloatAvailableSpace.mRect.x;
nscoord availWidth = aFloatAvailableSpace.mRect.width;
nscoord availHeight;
if (aState.GetFlag(BRS_UNCONSTRAINEDHEIGHT)) {
availBSize = NS_UNCONSTRAINEDSIZE;
availHeight = NS_UNCONSTRAINEDSIZE;
}
else {
/* XXX get the height right! */
availBSize = lineRect.BSize(wm);
availHeight = aFloatAvailableSpace.mRect.height;
}
// Make sure to enable resize optimization before we call BeginLineReflow
// because it might get disabled there
aLine->EnableResizeReflowOptimization();
aLineLayout.BeginLineReflow(iStart, aState.mY,
availISize, availBSize,
// For unicode-bidi: plaintext, we need to get the direction of the line from
// the resolved paragraph level of the first frame on the line, not the block
// frame, because the block frame could be split by hard line breaks into
// multiple paragraphs with different base direction
uint8_t direction =
(StyleTextReset()->mUnicodeBidi & NS_STYLE_UNICODE_BIDI_PLAINTEXT) ?
nsBidiPresUtils::GetFrameBaseLevel(aLine->mFirstChild) & 1 :
StyleVisibility()->mDirection;
aLineLayout.BeginLineReflow(x, aState.mY,
availWidth, availHeight,
aFloatAvailableSpace.mHasFloats,
false, /*XXX isTopOfPage*/
wm, lineWidth);
direction);
aState.SetFlag(BRS_LINE_LAYOUT_EMPTY, false);
@ -4049,7 +4052,7 @@ nsBlockFrame::PlaceLine(nsBlockReflowState& aState,
bool addedBullet = false;
if (HasOutsideBullet() &&
((aLine == mLines.front() &&
(!aLineLayout.IsZeroBSize() || (aLine == mLines.back()))) ||
(!aLineLayout.IsZeroHeight() || (aLine == mLines.back()))) ||
(mLines.front() != mLines.back() &&
0 == mLines.front()->mBounds.height &&
aLine == mLines.begin().next()))) {
@ -4061,7 +4064,7 @@ nsBlockFrame::PlaceLine(nsBlockReflowState& aState,
aLineLayout.AddBulletFrame(bullet, metrics);
addedBullet = true;
}
aLineLayout.BlockDirAlignLine();
aLineLayout.VerticalAlignLine();
// 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.
@ -4089,9 +4092,9 @@ nsBlockFrame::PlaceLine(nsBlockReflowState& aState,
#ifdef DEBUG
{
static nscoord lastHeight = 0;
if (CRAZY_SIZE(aLine->mBounds.y)) {
if (CRAZY_HEIGHT(aLine->mBounds.y)) {
lastHeight = aLine->mBounds.y;
if (abs(aLine->mBounds.y - lastHeight) > CRAZY_COORD/10) {
if (abs(aLine->mBounds.y - lastHeight) > CRAZY_H/10) {
nsFrame::ListTag(stdout);
printf(": line=%p y=%d line.bounds.height=%d\n",
static_cast<void*>(aLine.get()),
@ -4122,9 +4125,20 @@ nsBlockFrame::PlaceLine(nsBlockReflowState& aState,
NS_STYLE_TEXT_ALIGN_JUSTIFY == styleText->mTextAlign) &&
(aLineLayout.GetLineEndsInBR() ||
IsLastLine(aState, aLine)));
aLineLayout.InlineDirAlignFrames(aLine->mBounds, isLastLine,
aLine->GetChildCount());
aLineLayout.HorizontalAlignFrames(aLine->mBounds, isLastLine);
// XXX: not only bidi: right alignment can be broken after
// RelativePositionFrames!!!
// XXXldb Is something here considering relatively positioned frames at
// other than their original positions?
#ifdef IBMBIDI
// XXXldb Why don't we do this earlier?
if (aState.mPresContext->BidiEnabled()) {
if (!aState.mPresContext->IsVisualMode() ||
StyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL) {
nsBidiPresUtils::ReorderFrames(aLine->mFirstChild, aLine->GetChildCount());
} // not visual mode
} // bidi enabled
#endif // IBMBIDI
// From here on, pfd->mBounds rectangles are incorrect because bidi
// might have moved frames around!

Просмотреть файл

@ -262,7 +262,7 @@ nsBlockReflowContext::ReflowBlock(const nsRect& aSpace,
#ifdef DEBUG
if (!NS_INLINE_IS_BREAK_BEFORE(aFrameReflowStatus)) {
if (CRAZY_SIZE(mMetrics.Width()) || CRAZY_SIZE(mMetrics.Height())) {
if (CRAZY_WIDTH(mMetrics.Width()) || CRAZY_HEIGHT(mMetrics.Height())) {
printf("nsBlockReflowContext: ");
nsFrame::ListTag(stdout, mFrame);
printf(" metrics=%d,%d!\n", mMetrics.Width(), mMetrics.Height());

Просмотреть файл

@ -34,8 +34,11 @@ class FramePropertyTable;
// dependency on nsDeviceContext.h. It doesn't matter if it's a
// little off.
#ifdef DEBUG
#define CRAZY_COORD (1000000*60)
#define CRAZY_SIZE(_x) (((_x) < -CRAZY_COORD) || ((_x) > CRAZY_COORD))
#define CRAZY_W (1000000*60)
#define CRAZY_H CRAZY_W
#define CRAZY_WIDTH(_x) (((_x) < -CRAZY_W) || ((_x) > CRAZY_W))
#define CRAZY_HEIGHT(_y) (((_y) < -CRAZY_H) || ((_y) > CRAZY_H))
#endif
/**

Просмотреть файл

@ -188,10 +188,21 @@ nsFirstLetterFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowState rs(aPresContext, aReflowState, kid, availSize);
nsLineLayout ll(aPresContext, nullptr, &aReflowState, nullptr);
// For unicode-bidi: plaintext, we need to get the direction of the line
// from the resolved paragraph level of the child, not the block frame,
// because the block frame could be split by hard line breaks into
// multiple paragraphs with different base direction
uint8_t direction;
nsIFrame* containerFrame = ll.LineContainerFrame();
if (containerFrame->StyleTextReset()->mUnicodeBidi &
NS_STYLE_UNICODE_BIDI_PLAINTEXT) {
FramePropertyTable *propTable = aPresContext->PropertyTable();
direction = NS_PTR_TO_INT32(propTable->Get(kid, BaseLevelProperty())) & 1;
} else {
direction = containerFrame->StyleVisibility()->mDirection;
}
ll.BeginLineReflow(bp.left, bp.top, availSize.width, NS_UNCONSTRAINEDSIZE,
false, true,
ll.LineContainerFrame()->GetWritingMode(kid),
aReflowState.AvailableWidth());
false, true, direction);
rs.mLineLayout = &ll;
ll.SetInFirstLetter(true);
ll.SetFirstLetterStyleOK(true);

Просмотреть файл

@ -975,20 +975,6 @@ nsIFrame::GetPaddingRect() const
return GetPaddingRectRelativeToSelf() + GetPosition();
}
WritingMode
nsIFrame::GetWritingMode(nsIFrame* aSubFrame) const
{
WritingMode writingMode = GetWritingMode();
if (!writingMode.IsVertical() &&
(StyleTextReset()->mUnicodeBidi & NS_STYLE_UNICODE_BIDI_PLAINTEXT)) {
nsBidiLevel frameLevel = nsBidiPresUtils::GetFrameBaseLevel(aSubFrame);
writingMode.SetDirectionFromBidiLevel(frameLevel);
}
return writingMode;
}
nsRect
nsIFrame::GetMarginRectRelativeToSelf() const
{

Просмотреть файл

@ -672,15 +672,6 @@ public:
return mozilla::WritingMode(StyleVisibility());
}
/**
* Get the writing mode of this frame, but if it is styled with
* unicode-bidi: plaintext, reset the direction to the resolved paragraph
* level of the given subframe (typically the first frame on the line),
* not this frame's writing mode, because the container frame could be split
* by hard line breaks into multiple paragraphs with different base direction.
*/
mozilla::WritingMode GetWritingMode(nsIFrame* aSubFrame) const;
/**
* Bounding rect of the frame. The values are in app units, and the origin is
* relative to the upper-left of the geometric parent. The size includes the

Просмотреть файл

@ -487,21 +487,23 @@ nsInlineFrame::ReflowFrames(nsPresContext* aPresContext,
nsLineLayout* lineLayout = aReflowState.mLineLayout;
bool inFirstLine = aReflowState.mLineLayout->GetInFirstLine();
RestyleManager* restyleManager = aPresContext->RestyleManager();
WritingMode wm = aReflowState.GetWritingMode();
nscoord startEdge = 0;
bool ltr = (NS_STYLE_DIRECTION_LTR == aReflowState.mStyleVisibility->mDirection);
nscoord leftEdge = 0;
// Don't offset by our start borderpadding if we have a prev continuation or
// if we're in a part of an {ib} split other than the first one.
if (!GetPrevContinuation() && !FrameIsNonFirstInIBSplit()) {
startEdge = aReflowState.ComputedLogicalBorderPadding().IStart(wm);
leftEdge = ltr ? aReflowState.ComputedPhysicalBorderPadding().left
: aReflowState.ComputedPhysicalBorderPadding().right;
}
nscoord availableISize = aReflowState.AvailableISize();
NS_ASSERTION(availableISize != NS_UNCONSTRAINEDSIZE,
nscoord availableWidth = aReflowState.AvailableWidth();
NS_ASSERTION(availableWidth != NS_UNCONSTRAINEDSIZE,
"should no longer use available widths");
// Subtract off inline axis border+padding from availableISize
availableISize -= startEdge;
availableISize -= aReflowState.ComputedLogicalBorderPadding().IEnd(wm);
lineLayout->BeginSpan(this, &aReflowState, startEdge,
startEdge + availableISize, &mBaseline);
// Subtract off left and right border+padding from availableWidth
availableWidth -= leftEdge;
availableWidth -= ltr ? aReflowState.ComputedPhysicalBorderPadding().right
: aReflowState.ComputedPhysicalBorderPadding().left;
lineLayout->BeginSpan(this, &aReflowState, leftEdge,
leftEdge + availableWidth, &mBaseline);
// First reflow our principal children.
nsIFrame* frame = mFrames.FirstChild();
@ -644,7 +646,7 @@ nsInlineFrame::ReflowFrames(nsPresContext* aPresContext,
// line-height calculations. However, continuations of an inline
// that are empty we force to empty so that things like collapsed
// whitespace in an inline element don't affect the line-height.
aMetrics.ISize() = lineLayout->EndSpan(this);
aMetrics.Width() = lineLayout->EndSpan(this);
// Compute final width.
@ -652,7 +654,8 @@ nsInlineFrame::ReflowFrames(nsPresContext* aPresContext,
// continuation or if we're in a part of an {ib} split other than the first
// one.
if (!GetPrevContinuation() && !FrameIsNonFirstInIBSplit()) {
aMetrics.ISize() += aReflowState.ComputedLogicalBorderPadding().IStart(wm);
aMetrics.Width() += ltr ? aReflowState.ComputedPhysicalBorderPadding().left
: aReflowState.ComputedPhysicalBorderPadding().right;
}
/*
@ -665,7 +668,8 @@ nsInlineFrame::ReflowFrames(nsPresContext* aPresContext,
if (NS_FRAME_IS_COMPLETE(aStatus) &&
!LastInFlow()->GetNextContinuation() &&
!FrameIsNonLastInIBSplit()) {
aMetrics.Width() += aReflowState.ComputedLogicalBorderPadding().IEnd(wm);
aMetrics.Width() += ltr ? aReflowState.ComputedPhysicalBorderPadding().right
: aReflowState.ComputedPhysicalBorderPadding().left;
}
nsRefPtr<nsFontMetrics> fm;

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -21,7 +21,6 @@
#include "nsBlockReflowState.h"
#include "plarena.h"
#include "gfxTypes.h"
#include "WritingModes.h"
class nsFloatManager;
struct nsStyleText;
@ -34,10 +33,10 @@ public:
const nsLineList::iterator* aLine);
~nsLineLayout();
void Init(nsBlockReflowState* aState, nscoord aMinLineBSize,
void Init(nsBlockReflowState* aState, nscoord aMinLineHeight,
int32_t aLineNumber) {
mBlockRS = aState;
mMinLineBSize = aMinLineBSize;
mMinLineHeight = aMinLineHeight;
mLineNumber = aLineNumber;
}
@ -45,12 +44,11 @@ public:
return mLineNumber;
}
void BeginLineReflow(nscoord aICoord, nscoord aBCoord,
nscoord aISize, nscoord aBSize,
void BeginLineReflow(nscoord aX, nscoord aY,
nscoord aWidth, nscoord aHeight,
bool aImpactedByFloats,
bool aIsTopOfPage,
mozilla::WritingMode aWritingMode,
nscoord aContainerWidth);
uint8_t aDirection);
void EndLineReflow();
@ -75,7 +73,7 @@ public:
void SplitLineTo(int32_t aNewCount);
bool IsZeroBSize();
bool IsZeroHeight();
// Reflows the frame and returns the reflow status. aPushedFrame is true
// if the frame is pushed to the next line because it doesn't fit
@ -90,12 +88,11 @@ public:
PushFrame(aFrame);
}
void BlockDirAlignLine();
void VerticalAlignLine();
bool TrimTrailingWhiteSpace();
void InlineDirAlignFrames(nsRect& aLineBounds, bool aIsLastLine,
int32_t aFrameCount);
void HorizontalAlignFrames(nsRect& aLineBounds, bool aIsLastLine);
/**
* Handle all the relative positioning in the line, compute the
@ -306,10 +303,10 @@ public:
* the right edge for RTL blocks and from the left edge for LTR blocks.
* In other words, the current frame's distance from the line container's
* start content edge is:
* <code>GetCurrentFrameInlineDistanceFromBlock() - lineContainer->GetUsedBorderAndPadding().left</code>
* <code>GetCurrentFrameXDistanceFromBlock() - lineContainer->GetUsedBorderAndPadding().left</code>
* Note the use of <code>.left</code> for both LTR and RTL line containers.
*/
nscoord GetCurrentFrameInlineDistanceFromBlock();
nscoord GetCurrentFrameXDistanceFromBlock();
protected:
// This state is constant for a given block frame doing line layout
@ -329,22 +326,14 @@ protected:
// Per-frame data recorded by the line-layout reflow logic. This
// state is the state needed to post-process the line after reflow
// has completed (block-direction alignment, inline-direction alignment,
// has completed (vertical alignment, horizontal alignment,
// justification and relative positioning).
struct PerSpanData;
struct PerFrameData;
friend struct PerSpanData;
friend struct PerFrameData;
struct PerFrameData
{
PerFrameData(mozilla::WritingMode aWritingMode)
: mBounds(aWritingMode)
, mMargin(aWritingMode)
, mBorderPadding(aWritingMode)
, mOffsets(aWritingMode)
{}
struct PerFrameData {
// link to next/prev frame in same span
PerFrameData* mNext;
PerFrameData* mPrev;
@ -357,23 +346,20 @@ protected:
// From metrics
nscoord mAscent;
// 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;
nsRect mBounds;
nsOverflowAreas mOverflowAreas;
// From reflow-state
mozilla::LogicalMargin mMargin;
mozilla::LogicalMargin mBorderPadding;
mozilla::LogicalMargin mOffsets;
nsMargin mMargin;
nsMargin mBorderPadding;
nsMargin mOffsets;
// state for text justification
int32_t mJustificationNumSpaces;
int32_t mJustificationNumLetters;
// Other state we use
uint8_t mBlockDirAlign;
uint8_t mVerticalAlign;
// PerFrameData flags
#define PFD_RELATIVEPOS 0x00000001
@ -428,18 +414,19 @@ protected:
const nsHTMLReflowState* mReflowState;
bool mNoWrap;
mozilla::WritingMode mWritingMode;
uint8_t mDirection;
bool mChangedFrameDirection;
bool mZeroEffectiveSpanBox;
bool mContainsFloat;
bool mHasNonemptyContent;
nscoord mIStart;
nscoord mICoord;
nscoord mIEnd;
nscoord mLeftEdge;
nscoord mX;
nscoord mRightEdge;
nscoord mBStartLeading, mBEndLeading;
nscoord mLogicalBSize;
nscoord mMinBCoord, mMaxBCoord;
nscoord mTopLeading, mBottomLeading;
nscoord mLogicalHeight;
nscoord mMinY, mMaxY;
nscoord* mBaseline;
void AppendFrame(PerFrameData* pfd) {
@ -461,7 +448,7 @@ protected:
int32_t mLastOptionalBreakContentOffset;
int32_t mForceBreakContentOffset;
nscoord mMinLineBSize;
nscoord mMinLineHeight;
// The amount of text indent that we applied to this line, needed for
// max-element-size calculation.
@ -475,21 +462,19 @@ protected:
int32_t mTotalPlacedFrames;
nscoord mBStartEdge;
nscoord mMaxStartBoxBSize;
nscoord mMaxEndBoxBSize;
nscoord mTopEdge;
nscoord mMaxTopBoxHeight;
nscoord mMaxBottomBoxHeight;
nscoord mInflationMinFontSize;
// Final computed line-bSize value after BlockDirAlignFrames for
// Final computed line-height value after VerticalAlignFrames for
// the block has been called.
nscoord mFinalLineBSize;
nscoord mFinalLineHeight;
// Amount of trimmable whitespace width for the trailing text frame, if any
nscoord mTrimmableWidth;
nscoord mContainerWidth;
bool mFirstLetterStyleOK : 1;
bool mIsTopOfPage : 1;
bool mImpactedByFloats : 1;
@ -514,7 +499,7 @@ protected:
/**
* Allocate a PerFrameData from the mArena pool. The allocation is infallible.
*/
PerFrameData* NewPerFrameData(nsIFrame* aFrame);
PerFrameData* NewPerFrameData();
/**
* Allocate a PerSpanData from the mArena pool. The allocation is infallible.
@ -533,6 +518,7 @@ protected:
nsHTMLReflowState& aReflowState);
bool CanPlaceFrame(PerFrameData* pfd,
uint8_t aFrameDirection,
bool aNotSafeToBreak,
bool aFrameCanContinueTextRun,
bool aCanRollBackBeforeFrame,
@ -543,15 +529,15 @@ protected:
void PlaceFrame(PerFrameData* pfd,
nsHTMLReflowMetrics& aMetrics);
void BlockDirAlignFrames(PerSpanData* psd);
void VerticalAlignFrames(PerSpanData* psd);
void PlaceStartEndFrames(PerSpanData* psd,
nscoord aDistanceFromStart,
nscoord aLineBSize);
void PlaceTopBottomFrames(PerSpanData* psd,
nscoord aDistanceFromTop,
nscoord aLineHeight);
void RelativePositionFrames(PerSpanData* psd, nsOverflowAreas& aOverflowAreas);
bool TrimTrailingWhiteSpaceIn(PerSpanData* psd, nscoord* aDeltaISize);
bool TrimTrailingWhiteSpaceIn(PerSpanData* psd, nscoord* aDeltaWidth);
void ComputeJustificationWeights(PerSpanData* psd, int32_t* numSpaces, int32_t* numLetters);

Просмотреть файл

@ -7841,7 +7841,7 @@ nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth,
iter.SetOriginalOffset(offset);
nscoord xOffsetForTabs = (mTextRun->GetFlags() & nsTextFrameUtils::TEXT_HAS_TAB) ?
(aLineLayout.GetCurrentFrameInlineDistanceFromBlock() -
(aLineLayout.GetCurrentFrameXDistanceFromBlock() -
lineContainer->GetUsedBorderAndPadding().left)
: -1;
PropertyProvider provider(mTextRun, textStyle, frag, this, iter, length,