Bug 1164693 - Part 2: Frames in a non-bidi paragraph with newline shouldn't be marked as bidi. r=smontagu

This commit is contained in:
Ted Clancy 2015-06-05 21:46:49 -04:00
parent 100cf0c0b0
commit b54e64860d

View File

@ -734,31 +734,44 @@ nsBidiPresUtils::ResolveParagraph(nsBlockFrame* aBlockFrame,
#endif
#endif
if (runCount == 1 && frameCount == 1 &&
bool isNonBidi = false;
nsIFrame* frame0 = frameCount > 0 ? aBpd->FrameAt(0) : nullptr;
nsIFrame* frame1 = frameCount > 1 ? aBpd->FrameAt(1) : nullptr;
// Non-bidi frames
if (runCount == 1 && (frameCount == 1 || frameCount == 2) &&
aBpd->mParagraphDepth == 0 && aBpd->GetDirection() == NSBIDI_LTR &&
aBpd->GetParaLevel() == 0) {
// We have a single left-to-right frame in a left-to-right paragraph,
aBpd->GetParaLevel() == 0 &&
frame0 != NS_BIDI_CONTROL_FRAME &&
!frame0->Properties().Get(nsIFrame::EmbeddingLevelProperty()) &&
!frame0->Properties().Get(nsIFrame::BaseLevelProperty())) {
// We have a left-to-right frame in a left-to-right paragraph,
// without bidi isolation from the surrounding text.
// Make sure that the embedding level and base level frame properties aren't
// The embedding level and base level frame properties aren't
// set (because if they are this frame used to have some other direction,
// so we can't do this optimization), and we're done.
nsIFrame* frame = aBpd->FrameAt(0);
if (frame != NS_BIDI_CONTROL_FRAME &&
!frame->Properties().Get(nsIFrame::EmbeddingLevelProperty()) &&
!frame->Properties().Get(nsIFrame::BaseLevelProperty())) {
// so we can't do this optimization)
// As long as this is the only frame, or it's followed by a linebreak,
// this is a non-bidi paragraph.
if (!frame1 || (frame1 != NS_BIDI_CONTROL_FRAME &&
frame1->GetType() == nsGkAtoms::brFrame)) {
isNonBidi = true;
}
}
if (isNonBidi) {
#ifdef DEBUG
#ifdef NOISY_BIDI
printf("early return for single direction frame %p\n", (void*)frame);
printf("early return for single direction frame %p\n", (void*)frame);
#endif
#endif
frame->AddStateBits(NS_FRAME_IS_BIDI);
return NS_OK;
}
return NS_OK;
}
nsIFrame* firstFrame = nullptr;
nsIFrame* lastFrame = nullptr;
// Bidi frames
for (; ;) {
if (fragmentLength <= 0) {
// Get the next frame from mLogicalFrames