--- a/layout/base/nsBidiPresUtils.cpp
+++ b/layout/base/nsBidiPresUtils.cpp
@@ -135,20 +135,27 @@ struct MOZ_STACK_CLASS BidiParagraphData
nsDataHashtable<nsISupportsHashKey, int32_t> mContentToFrameIndex;
// Cached presentation context for the frames we're processing.
nsPresContext* mPresContext;
bool mIsVisual;
nsBidiLevel mParaLevel;
nsIContent* mPrevContent;
nsBidi mBidiEngine;
nsIFrame* mPrevFrame;
+#ifdef DEBUG
+ // Only used for NOISY debug output.
+ nsBlockFrame* mCurrentBlock;
+#endif
void Init(nsBlockFrame* aBlockFrame)
{
mPrevContent = nullptr;
+#ifdef DEBUG
+ mCurrentBlock = aBlockFrame;
+#endif
mParaLevel = nsBidiPresUtils::BidiLevelFromStyle(aBlockFrame->StyleContext());
mPresContext = aBlockFrame->PresContext();
mIsVisual = mPresContext->IsVisualMode();
if (mIsVisual) {
/**
* Drill up in content to detect whether this is an element that needs to
@@ -340,17 +347,17 @@ struct MOZ_STACK_CLASS BidiParagraphData
{
// Advance aLine to the line containing aFrame
nsIFrame* child = aFrame;
nsIFrame* parent = nsLayoutUtils::GetParentOrPlaceholderFor(child);
while (parent && !nsLayoutUtils::GetAsBlock(parent)) {
child = parent;
parent = nsLayoutUtils::GetParentOrPlaceholderFor(child);
}
- NS_ASSERTION (parent, "aFrame is not a descendent of aBlockFrame");
+ NS_ASSERTION (parent, "aFrame is not a descendent of a block frame");
while (!IsFrameInCurrentLine(aLineIter, aPrevFrame, child)) {
#ifdef DEBUG
bool hasNext =
#endif
aLineIter->Next();
NS_ASSERTION(hasNext, "Can't find frame in lines!");
aPrevFrame = nullptr;
}
@@ -689,37 +696,39 @@ nsBidiPresUtils::Resolve(nsBlockFrame* a
// unicode-bidi:plaintext on a block element is handled by block frame
// via using nsIFrame::GetWritingMode(nsIFrame*).
char16_t ch = GetBidiOverride(aBlockFrame->StyleContext());
if (ch != 0) {
bpd.PushBidiControl(ch);
}
for (nsBlockFrame* block = aBlockFrame; block;
block = static_cast<nsBlockFrame*>(block->GetNextContinuation())) {
+#ifdef DEBUG
+ bpd.mCurrentBlock = block;
+#endif
block->RemoveStateBits(NS_BLOCK_NEEDS_BIDI_RESOLUTION);
nsBlockInFlowLineIterator lineIter(block, block->LinesBegin());
bpd.mPrevFrame = nullptr;
- TraverseFrames(aBlockFrame, &lineIter, block->PrincipalChildList().FirstChild(), &bpd);
+ TraverseFrames(&lineIter, block->PrincipalChildList().FirstChild(), &bpd);
nsBlockFrame::FrameLines* overflowLines = block->GetOverflowLines();
if (overflowLines) {
nsBlockInFlowLineIterator lineIter(block, overflowLines->mLines.begin(), true);
- TraverseFrames(aBlockFrame, &lineIter, block->PrincipalChildList().FirstChild(), &bpd);
+ TraverseFrames(&lineIter, block->PrincipalChildList().FirstChild(), &bpd);
}
}
if (ch != 0) {
bpd.PopBidiControl(ch);
}
- return ResolveParagraph(aBlockFrame, &bpd);
+ return ResolveParagraph(&bpd);
}
nsresult
-nsBidiPresUtils::ResolveParagraph(nsBlockFrame* aBlockFrame,
- BidiParagraphData* aBpd)
+nsBidiPresUtils::ResolveParagraph(BidiParagraphData* aBpd)
{
if (aBpd->BufferLength() < 1) {
return NS_OK;
}
aBpd->mBuffer.ReplaceChar(kSeparators, kSpace);
int32_t runCount;
@@ -743,21 +752,21 @@ nsBidiPresUtils::ResolveParagraph(nsBloc
nsIContent* content = nullptr;
int32_t contentTextLength = 0;
FramePropertyTable* propTable = aBpd->mPresContext->PropertyTable();
nsLineBox* currentLine = nullptr;
#ifdef DEBUG
#ifdef NOISY_BIDI
- printf("Before Resolve(), aBlockFrame=0x%p, mBuffer='%s', frameCount=%d, runCount=%d\n",
- (void*)aBlockFrame, NS_ConvertUTF16toUTF8(aBpd->mBuffer).get(), frameCount, runCount);
+ printf("Before Resolve(), mCurrentBlock=%p, mBuffer='%s', frameCount=%d, runCount=%d\n",
+ (void*)aBpd->mCurrentBlock, NS_ConvertUTF16toUTF8(aBpd->mBuffer).get(), frameCount, runCount);
#ifdef REALLY_NOISY_BIDI
printf(" block frame tree=:\n");
- aBlockFrame->List(stdout, 0);
+ aBpd->mCurrentBlock->List(stdout, 0);
#endif
#endif
#endif
if (runCount == 1 && frameCount == 1 &&
aBpd->GetDirection() == NSBIDI_LTR && aBpd->GetParaLevel() == 0) {
// We have a single left-to-right frame in a left-to-right paragraph,
// without bidi isolation from the surrounding text.
@@ -976,27 +985,26 @@ nsBidiPresUtils::ResolveParagraph(nsBloc
JoinInlineAncestors(frame);
}
}
} // for
#ifdef DEBUG
#ifdef REALLY_NOISY_BIDI
printf("---\nAfter Resolve(), frameTree =:\n");
- aBlockFrame->List(stdout, 0);
+ aBpd->mCurrentBlock->List(stdout, 0);
printf("===\n");
#endif
#endif
return rv;
}
void
-nsBidiPresUtils::TraverseFrames(nsBlockFrame* aBlockFrame,
- nsBlockInFlowLineIterator* aLineIter,
+nsBidiPresUtils::TraverseFrames(nsBlockInFlowLineIterator* aLineIter,
nsIFrame* aCurrentFrame,
BidiParagraphData* aBpd)
{
if (!aCurrentFrame)
return;
#ifdef DEBUG
nsBlockFrame* initialLineContainer = aLineIter->GetContainer();
@@ -1153,17 +1161,17 @@ nsBidiPresUtils::TraverseFrames(nsBlockF
if (!next) {
// If the frame has no next in flow, create one.
CreateContinuation(frame, &next, true);
createdContinuation = true;
}
// Mark the line before the newline as dirty.
aBpd->GetLineForFrameAt(aBpd->FrameCount() - 1)->MarkDirty();
}
- ResolveParagraphWithinBlock(aBlockFrame, aBpd);
+ ResolveParagraphWithinBlock(aBpd);
if (!nextSibling && !createdContinuation) {
break;
} else if (next) {
frame = next;
aBpd->AppendFrame(frame, aLineIter);
// Mark the line after the newline as dirty.
aBpd->GetLineForFrameAt(aBpd->FrameCount() - 1)->MarkDirty();
@@ -1178,37 +1186,37 @@ nsBidiPresUtils::TraverseFrames(nsBlockF
}
} while (next);
}
}
} else if (nsGkAtoms::brFrame == frameType) {
// break frame -- append line separator
aBpd->AppendUnichar(kLineSeparator);
- ResolveParagraphWithinBlock(aBlockFrame, aBpd);
+ ResolveParagraphWithinBlock(aBpd);
} else {
// other frame type -- see the Unicode Bidi Algorithm:
// "...inline objects (such as graphics) are treated as if they are ...
// U+FFFC"
// <wbr>, however, is treated as U+200B ZERO WIDTH SPACE. See
// http://dev.w3.org/html5/spec/Overview.html#phrasing-content-1
aBpd->AppendUnichar(content->IsHTMLElement(nsGkAtoms::wbr) ?
kZWSP : kObjectSubstitute);
if (!frame->IsInlineOutside()) {
// if it is not inline, end the paragraph
- ResolveParagraphWithinBlock(aBlockFrame, aBpd);
+ ResolveParagraphWithinBlock(aBpd);
}
}
} else {
// For a non-leaf frame, recurse into TraverseFrames
nsIFrame* kid = frame->PrincipalChildList().FirstChild();
MOZ_ASSERT(!frame->GetChildList(nsIFrame::kOverflowList).FirstChild(),
"should have drained the overflow list above");
if (kid) {
- TraverseFrames(aBlockFrame, aLineIter, kid, aBpd);
+ TraverseFrames(aLineIter, kid, aBpd);
}
}
// If the element is attributed by dir, indicate direction pop (add PDF frame)
if (isLastFrame) {
// Add a dummy frame pointer representing a bidi control code after the
// last frame of an element specifying embedding or override
if (overrideChar != 0) {
@@ -1220,21 +1228,20 @@ nsBidiPresUtils::TraverseFrames(nsBlockF
}
childFrame = nextSibling;
} while (childFrame);
MOZ_ASSERT(initialLineContainer == aLineIter->GetContainer());
}
void
-nsBidiPresUtils::ResolveParagraphWithinBlock(nsBlockFrame* aBlockFrame,
- BidiParagraphData* aBpd)
+nsBidiPresUtils::ResolveParagraphWithinBlock(BidiParagraphData* aBpd)
{
aBpd->ClearBidiControls();
- ResolveParagraph(aBlockFrame, aBpd);
+ ResolveParagraph(aBpd);
aBpd->ResetData();
}
/* static */ nscoord
nsBidiPresUtils::ReorderFrames(nsIFrame* aFirstFrameOnLine,
int32_t aNumFramesOnLine,
WritingMode aLineWM,
const nsSize& aContainerSize,
--- a/layout/base/nsBidiPresUtils.h
+++ b/layout/base/nsBidiPresUtils.h
@@ -149,20 +149,18 @@ public:
* Make Bidi engine calculate the embedding levels of the frames that are
* descendants of a given block frame.
*
* @param aBlockFrame The block frame
*
* @lina 06/18/2000
*/
static nsresult Resolve(nsBlockFrame* aBlockFrame);
- static nsresult ResolveParagraph(nsBlockFrame* aBlockFrame,
- BidiParagraphData* aBpd);
- static void ResolveParagraphWithinBlock(nsBlockFrame* aBlockFrame,
- BidiParagraphData* aBpd);
+ static nsresult ResolveParagraph(BidiParagraphData* aBpd);
+ static void ResolveParagraphWithinBlock(BidiParagraphData* aBpd);
/**
* Reorder this line using Bidi engine.
* Update frame array, following the new visual sequence.
*
* @return total inline size
*
* @lina 05/02/2000
@@ -392,18 +390,17 @@ private:
/**
* Traverse the child frames of the block element and:
* Set up an array of the frames in logical order
* Create a string containing the text content of all the frames
* If we encounter content that requires us to split the element into more
* than one paragraph for bidi resolution, resolve the paragraph up to that
* point.
*/
- static void TraverseFrames(nsBlockFrame* aBlockFrame,
- nsBlockInFlowLineIterator* aLineIter,
+ static void TraverseFrames(nsBlockInFlowLineIterator* aLineIter,
nsIFrame* aCurrentFrame,
BidiParagraphData* aBpd);
/**
* Position ruby content frames (ruby base/text frame).
* Called from RepositionRubyFrame.
*/
static void RepositionRubyContentFrame(