Optimize bidi resolution on blocks without mixed-direction text. Bug 646359, r=roc

This commit is contained in:
Simon Montagu 2013-11-04 07:14:02 +02:00
Родитель 07e1ec2854
Коммит 3d75218e58
1 изменённых файлов: 28 добавлений и 0 удалений

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

@ -168,6 +168,13 @@ struct BidiParagraphData {
return paraLevel; return paraLevel;
} }
nsBidiDirection GetDirection()
{
nsBidiDirection dir;
mBidiEngine->GetDirection(&dir);
return dir;
}
nsresult CountRuns(int32_t *runCount){ return mBidiEngine->CountRuns(runCount); } nsresult CountRuns(int32_t *runCount){ return mBidiEngine->CountRuns(runCount); }
nsresult GetLogicalRun(int32_t aLogicalStart, nsresult GetLogicalRun(int32_t aLogicalStart,
@ -673,6 +680,27 @@ nsBidiPresUtils::ResolveParagraph(nsBlockFrame* aBlockFrame,
#endif #endif
#endif #endif
if (runCount == 1 && frameCount == 1 &&
aBpd->mParagraphDepth == 0 && 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.
// Make sure that 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())) {
#ifdef DEBUG
#ifdef NOISY_BIDI
printf("early return for single direction frame %p\n", (void*)frame);
#endif
#endif
return NS_OK;
}
}
nsIFrame* firstFrame = nullptr; nsIFrame* firstFrame = nullptr;
nsIFrame* lastFrame = nullptr; nsIFrame* lastFrame = nullptr;