textrendering/textformatting/tagma/TMINTERP.CPP
changeset 44 601ab138ba0b
parent 32 8b9155204a54
child 49 4d76f1414957
equal deleted inserted replaced
37:6be019398652 44:601ab138ba0b
    21 #include "TMSTD.H"
    21 #include "TMSTD.H"
    22 #include "TMINTERP.H"
    22 #include "TMINTERP.H"
    23 #include "TmHighlightSource.h"
    23 #include "TmHighlightSource.h"
    24 #include <s32mem.h>
    24 #include <s32mem.h>
    25 #include <frmtlay.h>
    25 #include <frmtlay.h>
       
    26 #include "OstTraceDefinitions.h"
       
    27 #ifdef OST_TRACE_COMPILER_IN_USE
       
    28 #include "TMINTERPTraces.h"
       
    29 #endif
       
    30 
    26 
    31 
    27 TTmInterpreterParam::TTmInterpreterParam(const CTmTextLayout& aTextLayout):
    32 TTmInterpreterParam::TTmInterpreterParam(const CTmTextLayout& aTextLayout):
    28 	iByteCode(&aTextLayout.Code()),
    33 	iByteCode(&aTextLayout.Code()),
    29 	iCodeStart(0),
    34 	iCodeStart(0),
    30 	iCodeEnd(aTextLayout.Code().Size()),
    35 	iCodeEnd(aTextLayout.Code().Size()),
   319 	iTmTextDrawExt = reinterpret_cast <MTmTextDrawExt*> (Source().GetExtendedInterface(KTmTextDrawExtId));
   324 	iTmTextDrawExt = reinterpret_cast <MTmTextDrawExt*> (Source().GetExtendedInterface(KTmTextDrawExtId));
   320 	if(!iTmTextDrawExt)
   325 	if(!iTmTextDrawExt)
   321 		{
   326 		{
   322 		iTmTextDrawExt = &iTmTextDrawExtDefault;
   327 		iTmTextDrawExt = &iTmTextDrawExtDefault;
   323 		}
   328 		}
   324 	__ASSERT_ALWAYS(iTmTextDrawExt != NULL, Panic(ENotImplemented));
   329 	if(!iTmTextDrawExt)
       
   330 	    {
       
   331         OstTrace0( TRACE_FATAL, RTMGENERALINTERPRETER_RTMGENERALINTERPRETER, "ENotImplemented" );
       
   332         __ASSERT_ALWAYS(0, Panic(ENotImplemented));
       
   333 	    }
   325 	}
   334 	}
   326 
   335 
   327 /**
   336 /**
   328  * Get source text starting at aPos and not more than (aEndChar - aPos)
   337  * Get source text starting at aPos and not more than (aEndChar - aPos)
   329  * characters.
   338  * characters.
   369  */
   378  */
   370 TInt TTmInterpreter::Lines()
   379 TInt TTmInterpreter::Lines()
   371 	{
   380 	{
   372 	while (Next())
   381 	while (Next())
   373 		{
   382 		{
       
   383 		if (Op() != EOpLine)
       
   384 		    {
       
   385 		    OstTrace0( TRACE_FATAL, TTMINTERPRETER_LINES, "ECorrupt" );
       
   386 		    }
   374 		__ASSERT_ALWAYS(Op() == EOpLine, Panic(ECorrupt));
   387 		__ASSERT_ALWAYS(Op() == EOpLine, Panic(ECorrupt));
   375 		Skip();
   388 		Skip();
   376 		}
   389 		}
   377 	return iLineInfo.iLineNumber + 1;
   390 	return iLineInfo.iLineNumber + 1;
   378 	}
   391 	}
   384  */
   397  */
   385 TInt TTmInterpreter::Paragraphs()
   398 TInt TTmInterpreter::Paragraphs()
   386 	{
   399 	{
   387 	while (Next())
   400 	while (Next())
   388 		{
   401 		{
       
   402 		if (Op() != EOpLine)
       
   403 		    {
       
   404 		    OstTrace0( TRACE_FATAL, TTMINTERPRETER_PARAGRAPHS, "ECorrupt" );
       
   405 		    }
   389 		__ASSERT_ALWAYS(Op() == EOpLine, Panic(ECorrupt));
   406 		__ASSERT_ALWAYS(Op() == EOpLine, Panic(ECorrupt));
   390 		Skip();
   407 		Skip();
   391 		}
   408 		}
   392 	return iLineInfo.iParNumber + 1;
   409 	return iLineInfo.iParNumber + 1;
   393 	}
   410 	}
   408 	*/
   425 	*/
   409 	TTmDocPos doc_pos(aDocPos.iPos,aDocPos.iType == TTmDocPosSpec::ELeading);
   426 	TTmDocPos doc_pos(aDocPos.iPos,aDocPos.iType == TTmDocPosSpec::ELeading);
   410 
   427 
   411 	if (!Next())
   428 	if (!Next())
   412 		return EFalse;
   429 		return EFalse;
       
   430 	if (Op() != EOpLine)
       
   431 	    {
       
   432 	    OstTrace0( TRACE_FATAL, TTMINTERPRETER_DOCPOSTOLINE, "ECorrupt" );
       
   433 	    }
   413 	__ASSERT_ALWAYS(Op() == EOpLine, Panic(ECorrupt));
   434 	__ASSERT_ALWAYS(Op() == EOpLine, Panic(ECorrupt));
   414 	while  (!PosIsInLine(doc_pos))
   435 	while  (!PosIsInLine(doc_pos))
   415 		{
   436 		{
   416 		Skip();
   437 		Skip();
   417 		if (!Next())
   438 		if (!Next())
   418 			return EFalse;
   439 			return EFalse;
       
   440 		if (Op() != EOpLine)
       
   441 		    {
       
   442 		    OstTrace0( TRACE_FATAL, DUP1_TTMINTERPRETER_DOCPOSTOLINE, "ECorrupt" );
       
   443 		    }
   419 		__ASSERT_ALWAYS(Op() == EOpLine, Panic(ECorrupt));
   444 		__ASSERT_ALWAYS(Op() == EOpLine, Panic(ECorrupt));
   420 		}
   445 		}
   421 
   446 
   422 	/*
   447 	/*
   423 	If the position is at the end of the line and was sought by direction it might not be in the line;
   448 	If the position is at the end of the line and was sought by direction it might not be in the line;
   450  */
   475  */
   451 TBool TTmInterpreter::LineNumberToLine(TInt aLineNumber)
   476 TBool TTmInterpreter::LineNumberToLine(TInt aLineNumber)
   452 	{
   477 	{
   453 	while (Next())
   478 	while (Next())
   454 		{
   479 		{
       
   480 		if (Op() != EOpLine)
       
   481 		    {
       
   482 		    OstTrace0( TRACE_FATAL, TTMINTERPRETER_LINENUMBERTOLINE, "ECorrupt" );
       
   483 		    }
   455 		__ASSERT_ALWAYS(Op() == EOpLine, Panic(ECorrupt));
   484 		__ASSERT_ALWAYS(Op() == EOpLine, Panic(ECorrupt));
   456 		if (iLineInfo.iLineNumber == aLineNumber)
   485 		if (iLineInfo.iLineNumber == aLineNumber)
   457 			return TRUE;
   486 			return TRUE;
   458 		else
   487 		else
   459 			Skip();
   488 			Skip();
   475  */
   504  */
   476 TBool TTmInterpreter::ParNumberToLine(TInt aParNumber,TInt aLineInPar)
   505 TBool TTmInterpreter::ParNumberToLine(TInt aParNumber,TInt aLineInPar)
   477 	{
   506 	{
   478 	while (Next())
   507 	while (Next())
   479 		{
   508 		{
       
   509 		if (Op() != EOpLine)
       
   510 		    {
       
   511 		    OstTrace0( TRACE_FATAL, TTMINTERPRETER_PARNUMBERTOLINE, "ECorrupt" );
       
   512 		    }
   480 		__ASSERT_ALWAYS(Op() == EOpLine, Panic(ECorrupt));
   513 		__ASSERT_ALWAYS(Op() == EOpLine, Panic(ECorrupt));
   481 		if (iLineInfo.iParNumber == aParNumber)
   514 		if (iLineInfo.iParNumber == aParNumber)
   482 			{
   515 			{
   483 			if (iLineInfo.iLineInPar >= aLineInPar || ParEnd())
   516 			if (iLineInfo.iLineInPar >= aLineInPar || ParEnd())
   484 				return TRUE;
   517 				return TRUE;
   496  */
   529  */
   497 TBool TTmInterpreter::YPosToLine(TInt aYPos)
   530 TBool TTmInterpreter::YPosToLine(TInt aYPos)
   498 	{
   531 	{
   499 	while (Next())
   532 	while (Next())
   500 		{
   533 		{
       
   534 		if (Op() != EOpLine)
       
   535 		    {
       
   536 		    OstTrace0( TRACE_FATAL, TTMINTERPRETER_YPOSTOLINE, "ECorrupt" );
       
   537 		    }
   501 		__ASSERT_ALWAYS(Op() == EOpLine, Panic(ECorrupt));
   538 		__ASSERT_ALWAYS(Op() == EOpLine, Panic(ECorrupt));
   502 		if (iLineInfo.iOuterRect.iTl.iY <= aYPos && iLineInfo.iOuterRect.iBr.iY > aYPos)
   539 		if (iLineInfo.iOuterRect.iTl.iY <= aYPos && iLineInfo.iOuterRect.iBr.iY > aYPos)
   503 			return TRUE;
   540 			return TRUE;
   504 		else
   541 		else
   505 			Skip();
   542 			Skip();
   520 TInt TTmInterpreter::WidthOfWidestLine(TInt aTop,TInt aBottom)
   557 TInt TTmInterpreter::WidthOfWidestLine(TInt aTop,TInt aBottom)
   521 	{
   558 	{
   522 	int width = 0;
   559 	int width = 0;
   523 	while (Next())
   560 	while (Next())
   524 		{
   561 		{
       
   562 		if (Op() != EOpLine)
       
   563 		    {
       
   564 		    OstTrace0( TRACE_FATAL, TTMINTERPRETER_WIDTHOFWIDESTLINE, "ECorrupt" );
       
   565 		    }
   525 		__ASSERT_ALWAYS(Op() == EOpLine, Panic(ECorrupt));
   566 		__ASSERT_ALWAYS(Op() == EOpLine, Panic(ECorrupt));
   526 		// Quit if below the range.
   567 		// Quit if below the range.
   527 		if (iLineInfo.iOuterRect.iTl.iY >= aBottom)
   568 		if (iLineInfo.iOuterRect.iTl.iY >= aBottom)
   528 			break;
   569 			break;
   529 		// If the line overlaps the range check its width.
   570 		// If the line overlaps the range check its width.
   560 	aRight = KMinTInt;
   601 	aRight = KMinTInt;
   561 	if (!Next())
   602 	if (!Next())
   562 		return;
   603 		return;
   563 	while (iLineInfo.iOuterRect.iBr.iY < aTopY)
   604 	while (iLineInfo.iOuterRect.iBr.iY < aTopY)
   564 		{
   605 		{
       
   606 		if (Op() != EOpLine)
       
   607 		    {
       
   608 		    OstTrace0( TRACE_FATAL, TTMINTERPRETER_HORIZONTALEXTREMES, "ECorrupt" );
       
   609 		    }
   565 		__ASSERT_ALWAYS(Op() == EOpLine, Panic(ECorrupt));
   610 		__ASSERT_ALWAYS(Op() == EOpLine, Panic(ECorrupt));
   566 		Skip();
   611 		Skip();
   567 		if (!Next())
   612 		if (!Next())
   568 			return;
   613 			return;
   569 		}
   614 		}
   570 	while (iLineInfo.iOuterRect.iTl.iY <= aBottomY)
   615 	while (iLineInfo.iOuterRect.iTl.iY <= aBottomY)
   571 		{
   616 		{
       
   617 		if (Op() != EOpLine)
       
   618 		    {
       
   619 		    OstTrace0( TRACE_FATAL, DUP1_TTMINTERPRETER_HORIZONTALEXTREMES, "ECorrupt" );
       
   620 		    }
   572 		__ASSERT_ALWAYS(Op() == EOpLine, Panic(ECorrupt));
   621 		__ASSERT_ALWAYS(Op() == EOpLine, Panic(ECorrupt));
   573 		if (iLineInfo.iInnerRect.iTl.iX < aLeft)
   622 		if (iLineInfo.iInnerRect.iTl.iX < aLeft)
   574 			aLeft = iLineInfo.iInnerRect.iTl.iX;
   623 			aLeft = iLineInfo.iInnerRect.iTl.iX;
   575 		if (aRight < iLineInfo.iInnerRect.iBr.iX)
   624 		if (aRight < iLineInfo.iInnerRect.iBr.iX)
   576 			aRight = iLineInfo.iInnerRect.iBr.iX;
   625 			aRight = iLineInfo.iInnerRect.iBr.iX;
   714 		RTmTextCache::EVisualRightToLeft : RTmTextCache::ELeftToRight;
   763 		RTmTextCache::EVisualRightToLeft : RTmTextCache::ELeftToRight;
   715 	iIgnorePosition = -1;
   764 	iIgnorePosition = -1;
   716 	if (!aByteCodeIterator.VisualEndOfLineIsAmbiguous())
   765 	if (!aByteCodeIterator.VisualEndOfLineIsAmbiguous())
   717 		iIgnorePosition = aByteCodeIterator.LineInfo().iEnd;
   766 		iIgnorePosition = aByteCodeIterator.LineInfo().iEnd;
   718 
   767 
       
   768 	if (aByteCodeIterator.Op() != TTmInterpreter::EOpText)
       
   769 	    {
       
   770 	    OstTrace0( TRACE_DUMP, DUP1_RTMGRAPHEMEINTEXTCHUNKITERATOR_BEGIN, "EInvariant" );
       
   771 	    }
   719 	__ASSERT_DEBUG(aByteCodeIterator.Op() == TTmInterpreter::EOpText, TmPanic(EInvariant));
   772 	__ASSERT_DEBUG(aByteCodeIterator.Op() == TTmInterpreter::EOpText, TmPanic(EInvariant));
   720 
   773 
   721 	if (iFont)
   774 	if (iFont)
   722 		{
   775 		{
   723 		iFont->Close();
   776 		iFont->Close();
   786 @return
   839 @return
   787 	The number of characters found; 1 or 2.
   840 	The number of characters found; 1 or 2.
   788 */
   841 */
   789 TInt RTmGraphemeInTextChunkIterator::Next()
   842 TInt RTmGraphemeInTextChunkIterator::Next()
   790 	{
   843 	{
       
   844 	if (AtEnd())
       
   845 	    {
       
   846 	    OstTrace0( TRACE_DUMP, RTMGRAPHEMEINTEXTCHUNKITERATOR_NEXT, "EBadArg" );
       
   847 	    }
   791 	__ASSERT_DEBUG(!AtEnd(), TmPanic(EBadArg));
   848 	__ASSERT_DEBUG(!AtEnd(), TmPanic(EBadArg));
   792 	TInt previousPositionInBuffer = iPosition.iPosInText;
   849 	TInt previousPositionInBuffer = iPosition.iPosInText;
   793 	TInt previousPosition = iReverse?
   850 	TInt previousPosition = iReverse?
   794 		iEndChar - iPosition.iPosInText : iStartChar + iPosition.iPosInText;
   851 		iEndChar - iPosition.iPosInText : iStartChar + iPosition.iPosInText;
   795 	TPoint previousPen = iPosition.iPen;
   852 	TPoint previousPen = iPosition.iPen;
   804 	// DrawText() pushes text with left side-bearings to the right.
   861 	// DrawText() pushes text with left side-bearings to the right.
   805 	iPosition.iPen.iX += LeftSideBearing(iStartPenX, iPosition);
   862 	iPosition.iPen.iX += LeftSideBearing(iStartPenX, iPosition);
   806 	TInt numCodePoints = iPosition.iPosInText - previousPositionInBuffer;
   863 	TInt numCodePoints = iPosition.iPosInText - previousPositionInBuffer;
   807 	TInt currentPosition = iReverse?
   864 	TInt currentPosition = iReverse?
   808 		iEndChar - iPosition.iPosInText : iStartChar + iPosition.iPosInText;
   865 		iEndChar - iPosition.iPosInText : iStartChar + iPosition.iPosInText;
       
   866 	if (currentPosition == previousPosition)
       
   867 	    {
       
   868 	    OstTrace0( TRACE_DUMP, DUP1_RTMGRAPHEMEINTEXTCHUNKITERATOR_NEXT, "EInvariant" );
       
   869 	    }
   809 	__ASSERT_DEBUG(currentPosition != previousPosition, TmPanic(EInvariant));
   870 	__ASSERT_DEBUG(currentPosition != previousPosition, TmPanic(EInvariant));
   810 
   871 
   811 	TInt cachePos = 0;
   872 	TInt cachePos = 0;
   812 	// Report the left hand edge of the character.
   873 	// Report the left hand edge of the character.
   813 	if (iIgnorePosition != previousPosition)
   874 	if (iIgnorePosition != previousPosition)
   835 			if ((*iCache)[cachePos].iPos.iEdge.iX < iEndPenX)
   896 			if ((*iCache)[cachePos].iPos.iEdge.iX < iEndPenX)
   836 				(*iCache)[cachePos].iPos.iEdge.iX = iEndPenX;
   897 				(*iCache)[cachePos].iPos.iEdge.iX = iEndPenX;
   837 			}
   898 			}
   838 		++cachePos;
   899 		++cachePos;
   839 		}
   900 		}
       
   901 	if (0 >= cachePos)
       
   902 	    {
       
   903 	    OstTrace0( TRACE_DUMP, DUP2_RTMGRAPHEMEINTEXTCHUNKITERATOR_NEXT, "EInvariant" );
       
   904 	    }
   840 	__ASSERT_DEBUG(0 < cachePos, TmPanic(EInvariant));
   905 	__ASSERT_DEBUG(0 < cachePos, TmPanic(EInvariant));
   841 	return cachePos;
   906 	return cachePos;
   842 	}
   907 	}
   843 
   908 
   844 /**
   909 /**
   866 /**
   931 /**
   867 Advances the iteration to the next edge.
   932 Advances the iteration to the next edge.
   868 */
   933 */
   869 void RTmGraphemeInTextChunkIteratorNice::Next()
   934 void RTmGraphemeInTextChunkIteratorNice::Next()
   870 	{
   935 	{
       
   936 	if (AtEnd())
       
   937 	    {
       
   938 	    OstTrace0( TRACE_DUMP, RTMGRAPHEMEINTEXTCHUNKITERATORNICE_NEXT, "EBadArg" );
       
   939 	    }
   871 	__ASSERT_DEBUG(!AtEnd(), TmPanic(EBadArg));
   940 	__ASSERT_DEBUG(!AtEnd(), TmPanic(EBadArg));
   872 	// Return if we have not finished moving through the cache.
   941 	// Return if we have not finished moving through the cache.
   873 	if (++iCurrent != iEnd)
   942 	if (++iCurrent != iEnd)
   874 		return;
   943 		return;
   875 	// Return if there are no more characters.
   944 	// Return if there are no more characters.
   908 @param aDocPos
   977 @param aDocPos
   909 	Position to advance to.
   978 	Position to advance to.
   910 */
   979 */
   911 void RTmGraphemeInTextChunkIteratorNice::FindEdge(const TTmDocPos& aDocPos)
   980 void RTmGraphemeInTextChunkIteratorNice::FindEdge(const TTmDocPos& aDocPos)
   912 	{
   981 	{
       
   982 	if (AtEnd())
       
   983 	    {
       
   984 	    OstTrace0( TRACE_DUMP, RTMGRAPHEMEINTEXTCHUNKITERATORNICE_FINDEDGE, "EBadArg" );
       
   985 	    }
   913 	__ASSERT_DEBUG(!AtEnd(), TmPanic(EBadArg));
   986 	__ASSERT_DEBUG(!AtEnd(), TmPanic(EBadArg));
   914 	while (RTmGraphemeEdgeIterator::ETotalMatch !=
   987 	while (RTmGraphemeEdgeIterator::ETotalMatch !=
   915 		RTmGraphemeEdgeIterator::DocPosMatches(aDocPos, *Get()))
   988 		RTmGraphemeEdgeIterator::DocPosMatches(aDocPos, *Get()))
   916 		{
   989 		{
   917 		Next();
   990 		Next();
  1054 Begin must be called before this function can be used.
  1127 Begin must be called before this function can be used.
  1055 @see Begin
  1128 @see Begin
  1056 */
  1129 */
  1057 void RTmGraphemeEdgeIterator::Next()
  1130 void RTmGraphemeEdgeIterator::Next()
  1058 	{
  1131 	{
       
  1132 	if (AtEnd())
       
  1133 	    {
       
  1134 	    OstTrace0( TRACE_DUMP, RTMGRAPHEMEEDGEITERATOR_NEXT, "EBadArg" );
       
  1135 	    }
  1059 	__ASSERT_DEBUG(!AtEnd(), TmPanic(EBadArg));
  1136 	__ASSERT_DEBUG(!AtEnd(), TmPanic(EBadArg));
  1060 	--iCacheSize;
  1137 	--iCacheSize;
  1061 	if (0 != iCacheSize)
  1138 	if (0 != iCacheSize)
  1062 		{
  1139 		{
  1063 		++iCachePos;
  1140 		++iCachePos;
  1076 	// Get the next position in this line
  1153 	// Get the next position in this line
  1077 	while (iByteCodeIterator->CodePos() < iEndLineCodePos)
  1154 	while (iByteCodeIterator->CodePos() < iEndLineCodePos)
  1078 		{
  1155 		{
  1079 		// The WHILE loop assures that there is always sufficientByteCode avaliable.
  1156 		// The WHILE loop assures that there is always sufficientByteCode avaliable.
  1080 		TBool haveSufficientByteCode = iByteCodeIterator->Next();
  1157 		TBool haveSufficientByteCode = iByteCodeIterator->Next();
       
  1158 		if (!haveSufficientByteCode)
       
  1159 		    {
       
  1160 		    OstTrace0( TRACE_DUMP, DUP1_RTMGRAPHEMEEDGEITERATOR_NEXT, "EBadArg" );
       
  1161 		    }
  1081 		__ASSERT_DEBUG(haveSufficientByteCode, TmPanic(EBadArg));
  1162 		__ASSERT_DEBUG(haveSufficientByteCode, TmPanic(EBadArg));
  1082 
  1163 
  1083 		iByteCodeIterator->Skip();
  1164 		iByteCodeIterator->Skip();
  1084 		TInt op = iByteCodeIterator->Op();
  1165 		TInt op = iByteCodeIterator->Op();
  1085 		if (op == TTmInterpreter::EOpSpecialChar)
  1166 		if (op == TTmInterpreter::EOpSpecialChar)
  1617 					RightToLeft()?
  1698 					RightToLeft()?
  1618 						RTmTextCache::EVisualRightToLeft
  1699 						RTmTextCache::EVisualRightToLeft
  1619 						: RTmTextCache::ELeftToRight;
  1700 						: RTmTextCache::ELeftToRight;
  1620 				User::LeaveIfError(iTextCache.GetDisplayedText(StartChar(), EndChar(),
  1701 				User::LeaveIfError(iTextCache.GetDisplayedText(StartChar(), EndChar(),
  1621 					directionality, buffer,aContextChar, 0, &font));
  1702 					directionality, buffer,aContextChar, 0, &font));
       
  1703 				if (!font)
       
  1704 				    {
       
  1705 				    OstTrace0( TRACE_DUMP, RTMGENERALINTERPRETER_GETDISPLAYEDTEXTL, "EInvariant" );
       
  1706 				    }
  1622 				__ASSERT_DEBUG(font, TmPanic(EInvariant));
  1707 				__ASSERT_DEBUG(font, TmPanic(EInvariant));
  1623 				CFont::TPositionParam p;
  1708 				CFont::TPositionParam p;
  1624 				int length = EndChar() - StartChar() + 1;
  1709 				int length = EndChar() - StartChar() + 1;
  1625 				p.iText.Set(buffer, length + 1);
  1710 				p.iText.Set(buffer, length + 1);
  1626 				p.iPosInText = 1;
  1711 				p.iPosInText = 1;
  1964 	return EFalse;
  2049 	return EFalse;
  1965 	}
  2050 	}
  1966 
  2051 
  1967 TBool RTmDrawingInterpreter::GetAdjustedHighlightClipRegion(const TRect& aClipRect, RRegion& aHighlightRegion) const
  2052 TBool RTmDrawingInterpreter::GetAdjustedHighlightClipRegion(const TRect& aClipRect, RRegion& aHighlightRegion) const
  1968 	{
  2053 	{
       
  2054 	if (NULL == iHighlightExtensions)
       
  2055 	    {
       
  2056 	    OstTrace0( TRACE_DUMP, RTMDRAWINGINTERPRETER_GETADJUSTEDHIGHLIGHTCLIPREGION, "EInvariant" );
       
  2057 	    }
  1969 	__ASSERT_DEBUG(NULL != iHighlightExtensions, TmPanic(EInvariant));
  2058 	__ASSERT_DEBUG(NULL != iHighlightExtensions, TmPanic(EInvariant));
  1970 
  2059 
  1971 	aHighlightRegion.Clear();
  2060 	aHighlightRegion.Clear();
  1972 
  2061 
  1973 	if (iHighlightEndPos > iHighlightStartPos)
  2062 	if (iHighlightEndPos > iHighlightStartPos)
  2021 	}
  2110 	}
  2022 
  2111 
  2023 TBool RTmDrawingInterpreter::GetFirstAdjustedHighlightClipRect(RTmBoundingRectInterpreter& aInterpreter,
  2112 TBool RTmDrawingInterpreter::GetFirstAdjustedHighlightClipRect(RTmBoundingRectInterpreter& aInterpreter,
  2024 															   const TRect& aClipRect, TRect& aRect) const
  2113 															   const TRect& aClipRect, TRect& aRect) const
  2025 	{
  2114 	{
       
  2115 	if (NULL == iHighlightExtensions)
       
  2116 	    {
       
  2117 	    OstTrace0( TRACE_DUMP, RTMDRAWINGINTERPRETER_GETFIRSTADJUSTEDHIGHLIGHTCLIPRECT, "EInvariant" );
       
  2118 	    }
  2026 	__ASSERT_DEBUG(NULL != iHighlightExtensions, TmPanic(EInvariant));
  2119 	__ASSERT_DEBUG(NULL != iHighlightExtensions, TmPanic(EInvariant));
  2027 
  2120 
  2028 	if (iHighlightEndPos > iHighlightStartPos)
  2121 	if (iHighlightEndPos > iHighlightStartPos)
  2029 		{
  2122 		{
  2030 		TBool found = aInterpreter.FirstRect(iHighlightStartPos, iHighlightEndPos, aRect);
  2123 		TBool found = aInterpreter.FirstRect(iHighlightStartPos, iHighlightEndPos, aRect);
  2061 	}
  2154 	}
  2062 
  2155 
  2063 TBool RTmDrawingInterpreter::GetNextAdjustedHighlightClipRect(RTmBoundingRectInterpreter& aInterpreter,
  2156 TBool RTmDrawingInterpreter::GetNextAdjustedHighlightClipRect(RTmBoundingRectInterpreter& aInterpreter,
  2064 															  const TRect& aClipRect, TRect& aRect) const
  2157 															  const TRect& aClipRect, TRect& aRect) const
  2065 	{
  2158 	{
       
  2159 	if (NULL == iHighlightExtensions)
       
  2160 	    {
       
  2161 	    OstTrace0( TRACE_DUMP, RTMDRAWINGINTERPRETER_GETNEXTADJUSTEDHIGHLIGHTCLIPRECT, "EInvariant" );
       
  2162 	    }
  2066 	__ASSERT_DEBUG(NULL != iHighlightExtensions, TmPanic(EInvariant));
  2163 	__ASSERT_DEBUG(NULL != iHighlightExtensions, TmPanic(EInvariant));
       
  2164 	if (iHighlightEndPos <= iHighlightStartPos)
       
  2165 	    {
       
  2166 	    OstTrace0( TRACE_DUMP, DUP1_RTMDRAWINGINTERPRETER_GETNEXTADJUSTEDHIGHLIGHTCLIPRECT, "EInvariant" );
       
  2167 	    }
  2067 	__ASSERT_DEBUG(iHighlightEndPos > iHighlightStartPos, TmPanic(EInvariant));
  2168 	__ASSERT_DEBUG(iHighlightEndPos > iHighlightStartPos, TmPanic(EInvariant));
  2068 
  2169 
  2069 	TBool found = aInterpreter.NextRect(aRect);
  2170 	TBool found = aInterpreter.NextRect(aRect);
  2070 	while (found)
  2171 	while (found)
  2071 		{
  2172 		{
  3143 iEndBdState if both pointers are non-null.
  3244 iEndBdState if both pointers are non-null.
  3144 */
  3245 */
  3145 TBool TTmByteCodeFinder::FindByteCode(TBool aToParStart,TBool aToParEnd,TInt aMaxExtraLines,TInfo& aInfo,
  3246 TBool TTmByteCodeFinder::FindByteCode(TBool aToParStart,TBool aToParEnd,TInt aMaxExtraLines,TInfo& aInfo,
  3146 									  TBidirectionalContext* aStartBdState,TBidirectionalContext* aEndBdState)
  3247 									  TBidirectionalContext* aStartBdState,TBidirectionalContext* aEndBdState)
  3147 	{
  3248 	{
       
  3249 	if (!((aStartBdState && aEndBdState)
       
  3250 	        || (!aStartBdState && !aEndBdState)))
       
  3251 	    {
       
  3252 	    OstTrace0( TRACE_DUMP, TTMBYTECODEFINDER_FINDBYTECODE, "EBadArg" );
       
  3253 	    }
  3148 	__ASSERT_DEBUG((aStartBdState && aEndBdState)
  3254 	__ASSERT_DEBUG((aStartBdState && aEndBdState)
  3149 		|| (!aStartBdState && !aEndBdState), TmPanic(EBadArg));
  3255 		|| (!aStartBdState && !aEndBdState), TmPanic(EBadArg));
  3150 	if (aStartBdState)
  3256 	if (aStartBdState)
  3151 		{
  3257 		{
  3152 		aStartBdState->Reset();
  3258 		aStartBdState->Reset();
  3161 	// Find iStartDocPos.
  3267 	// Find iStartDocPos.
  3162 	TBool foundStart = EFalse;
  3268 	TBool foundStart = EFalse;
  3163 	TBool get_info = EFalse;
  3269 	TBool get_info = EFalse;
  3164 	while (Next())
  3270 	while (Next())
  3165 		{
  3271 		{
       
  3272 		if (Op() != EOpLine)
       
  3273 		    {
       
  3274 		    OstTrace0( TRACE_DUMP, DUP1_TTMBYTECODEFINDER_FINDBYTECODE, "ECorrupt" );
       
  3275 		    }
  3166 		__ASSERT_ALWAYS(Op() == EOpLine, Panic(ECorrupt));
  3276 		__ASSERT_ALWAYS(Op() == EOpLine, Panic(ECorrupt));
  3167 		contextChar = LineContextCharChar();
  3277 		contextChar = LineContextCharChar();
  3168 		foundStart = iStartDocPos >= StartChar() && iStartDocPos < EndChar();
  3278 		foundStart = iStartDocPos >= StartChar() && iStartDocPos < EndChar();
  3169 		get_info = LineInfo().iLineNumber == 0 || ParStart();
  3279 		get_info = LineInfo().iLineNumber == 0 || ParStart();
  3170 		if (!aToParStart)
  3280 		if (!aToParStart)
  3194 	TBool foundEnd = EFalse;
  3304 	TBool foundEnd = EFalse;
  3195 	TInt extra_lines = 0;
  3305 	TInt extra_lines = 0;
  3196 	do
  3306 	do
  3197 		{
  3307 		{
  3198 		// Operators must all be EOpLine because we're skipping from line to line
  3308 		// Operators must all be EOpLine because we're skipping from line to line
       
  3309 		if (Op() != EOpLine)
       
  3310 		    {
       
  3311 		    OstTrace0( TRACE_FATAL, DUP3_TTMBYTECODEFINDER_FINDBYTECODE, "ECorrupt" );
       
  3312 		    }
  3199 		__ASSERT_ALWAYS(Op() == EOpLine, Panic(ECorrupt));
  3313 		__ASSERT_ALWAYS(Op() == EOpLine, Panic(ECorrupt));
  3200 		aInfo.iBounds.iBr = LineInfo().iOuterRect.iBr;
  3314 		aInfo.iBounds.iBr = LineInfo().iOuterRect.iBr;
  3201 		aInfo.iEndCodePos = EndCodePos();
  3315 		aInfo.iEndCodePos = EndCodePos();
  3202 		aInfo.iEndInfo = LineInfo();
  3316 		aInfo.iEndInfo = LineInfo();
  3203 		if (foundEnd)
  3317 		if (foundEnd)
  3231 	TBidirectionalContext* aStartBdState,TBidirectionalContext* aEndBdState)
  3345 	TBidirectionalContext* aStartBdState,TBidirectionalContext* aEndBdState)
  3232 	{
  3346 	{
  3233 	TInt heightToSkip = aTotalHeight - aMaxHeight;
  3347 	TInt heightToSkip = aTotalHeight - aMaxHeight;
  3234 	TInt cumulativeHeight = 0;
  3348 	TInt cumulativeHeight = 0;
  3235 	
  3349 	
       
  3350 	if (!((aStartBdState && aEndBdState) || (!aStartBdState && !aEndBdState)))
       
  3351 	    {
       
  3352 	    OstTrace0( TRACE_DUMP, TTMBYTECODEFINDER_FINDBYTECODEATEND, "EBadArg" );
       
  3353 	    }
  3236 	__ASSERT_DEBUG((aStartBdState && aEndBdState) || (!aStartBdState && !aEndBdState), TmPanic(EBadArg));
  3354 	__ASSERT_DEBUG((aStartBdState && aEndBdState) || (!aStartBdState && !aEndBdState), TmPanic(EBadArg));
  3237 	if (aStartBdState)
  3355 	if (aStartBdState)
  3238 		{
  3356 		{
  3239 		aStartBdState->Reset();
  3357 		aStartBdState->Reset();
  3240 		aEndBdState->Reset();
  3358 		aEndBdState->Reset();
  3244 	SetBdStatePtr(aEndBdState);
  3362 	SetBdStatePtr(aEndBdState);
  3245 	// Find iStartDocPos.
  3363 	// Find iStartDocPos.
  3246 	TBool foundStart = EFalse;
  3364 	TBool foundStart = EFalse;
  3247 	while (Next())
  3365 	while (Next())
  3248 		{
  3366 		{
       
  3367 		if (Op() != EOpLine)
       
  3368 		    {
       
  3369 		    OstTrace0( TRACE_FATAL, DUP1_TTMBYTECODEFINDER_FINDBYTECODEATEND, "ECorrupt" );
       
  3370 		    }
  3249 		__ASSERT_ALWAYS(Op() == EOpLine, Panic(ECorrupt));
  3371 		__ASSERT_ALWAYS(Op() == EOpLine, Panic(ECorrupt));
  3250 		if (cumulativeHeight > heightToSkip)
  3372 		if (cumulativeHeight > heightToSkip)
  3251 			{
  3373 			{
  3252 			foundStart = ETrue;
  3374 			foundStart = ETrue;
  3253 			aInfo.iBounds.iTl = LineInfo().iOuterRect.iTl;
  3375 			aInfo.iBounds.iTl = LineInfo().iOuterRect.iTl;
  3265 		}
  3387 		}
  3266 		
  3388 		
  3267 	TBool foundEnd = EFalse;	
  3389 	TBool foundEnd = EFalse;	
  3268 	while (Next())
  3390 	while (Next())
  3269 		{
  3391 		{
       
  3392 		if (Op() != EOpLine)
       
  3393 		    {
       
  3394 		    OstTrace0( TRACE_FATAL, DUP2_TTMBYTECODEFINDER_FINDBYTECODEATEND, "ECorrupt" );
       
  3395 		    }
  3270 		__ASSERT_ALWAYS(Op() == EOpLine, Panic(ECorrupt));
  3396 		__ASSERT_ALWAYS(Op() == EOpLine, Panic(ECorrupt));
  3271 		foundEnd = ETrue;
  3397 		foundEnd = ETrue;
  3272 		aInfo.iBounds.iBr = LineInfo().iOuterRect.iBr;
  3398 		aInfo.iBounds.iBr = LineInfo().iOuterRect.iBr;
  3273 		aInfo.iEndCodePos = EndCodePos();
  3399 		aInfo.iEndCodePos = EndCodePos();
  3274 		aInfo.iEndInfo = LineInfo();
  3400 		aInfo.iEndInfo = LineInfo();