+ quad.x = lineRun->alignmentOffset + position.x - glyph.xBearing + mScrollPosition.x;
+ quad.y = selectionBoxInfo->lineOffset;
+ quad.z = quad.x + glyph.advance;
+ quad.w = quad.y + selectionBoxInfo->lineHeight;
+
+ // Store the min and max 'x' for each line.
+ selectionBoxInfo->minX = std::min( selectionBoxInfo->minX, quad.x );
+ selectionBoxInfo->maxX = std::max( selectionBoxInfo->maxX, quad.z );
+
+ mEventData->mDecorator->AddHighlight( actualNumberOfQuads,
+ quad );
+ ++actualNumberOfQuads;
+
+ // Whether to retrieve the next line.
+ if( index == lastGlyphOfLine )
+ {
+ // Retrieve the next line.
+ ++lineRun;
+
+ // Get the last glyph of the new line.
+ lastGlyphOfLine = lineRun->glyphRun.glyphIndex + lineRun->glyphRun.numberOfGlyphs - 1u;
+
+ ++lineIndex;
+ if( lineIndex < firstLineIndex + numberOfLines )
+ {
+ // Keep the offset and height of the current selection box.
+ const float currentLineOffset = selectionBoxInfo->lineOffset;
+ const float currentLineHeight = selectionBoxInfo->lineHeight;
+
+ // Get the selection box info for the next line.
+ ++selectionBoxInfo;
+
+ selectionBoxInfo->minX = MAX_FLOAT;
+ selectionBoxInfo->maxX = MIN_FLOAT;
+
+ // Update the line's vertical offset.
+ selectionBoxInfo->lineOffset = currentLineOffset + currentLineHeight;
+
+ // The line height is the addition of the line ascender and the line descender.
+ // However, the line descender has a negative value, hence the subtraction.
+ selectionBoxInfo->lineHeight = lineRun->ascender - lineRun->descender;
+ }
+ }
+ }
+
+ // Traverses all the lines and updates the min and max 'x' positions and the total height.
+ // The final width is calculated after 'boxifying' the selection.
+ for( Vector<SelectionBoxInfo>::ConstIterator it = selectionBoxLinesInfo.Begin(),
+ endIt = selectionBoxLinesInfo.End();
+ it != endIt;
+ ++it )
+ {
+ const SelectionBoxInfo& info = *it;
+
+ // Update the size of the highlighted text.
+ highLightSize.height += info.lineHeight;
+ minHighlightX = std::min( minHighlightX, info.minX );
+ maxHighlightX = std::max( maxHighlightX, info.maxX );
+ }
+
+ // Add extra geometry to 'boxify' the selection.
+
+ if( 1u < numberOfLines )
+ {
+ // Boxify the first line.
+ lineRun = mVisualModel->mLines.Begin() + firstLineIndex;
+ const SelectionBoxInfo& firstSelectionBoxLineInfo = *( selectionBoxLinesInfo.Begin() );
+
+ bool boxifyBegin = ( LTR != lineRun->direction ) && ( LTR != startDirection );
+ bool boxifyEnd = ( LTR == lineRun->direction ) && ( LTR == startDirection );
+
+ if( boxifyBegin )
+ {
+ quad.x = 0.f;
+ quad.y = firstSelectionBoxLineInfo.lineOffset;
+ quad.z = firstSelectionBoxLineInfo.minX;
+ quad.w = firstSelectionBoxLineInfo.lineOffset + firstSelectionBoxLineInfo.lineHeight;
+
+ // Boxify at the beginning of the line.
+ mEventData->mDecorator->AddHighlight( actualNumberOfQuads,
+ quad );
+ ++actualNumberOfQuads;
+
+ // Update the size of the highlighted text.
+ minHighlightX = 0.f;
+ }
+
+ if( boxifyEnd )
+ {
+ quad.x = firstSelectionBoxLineInfo.maxX;
+ quad.y = firstSelectionBoxLineInfo.lineOffset;
+ quad.z = mVisualModel->mControlSize.width;
+ quad.w = firstSelectionBoxLineInfo.lineOffset + firstSelectionBoxLineInfo.lineHeight;
+
+ // Boxify at the end of the line.
+ mEventData->mDecorator->AddHighlight( actualNumberOfQuads,
+ quad );
+ ++actualNumberOfQuads;
+
+ // Update the size of the highlighted text.
+ maxHighlightX = mVisualModel->mControlSize.width;
+ }
+
+ // Boxify the central lines.
+ if( 2u < numberOfLines )
+ {
+ for( Vector<SelectionBoxInfo>::ConstIterator it = selectionBoxLinesInfo.Begin() + 1u,
+ endIt = selectionBoxLinesInfo.End() - 1u;
+ it != endIt;
+ ++it )
+ {
+ const SelectionBoxInfo& info = *it;
+
+ quad.x = 0.f;
+ quad.y = info.lineOffset;
+ quad.z = info.minX;
+ quad.w = info.lineOffset + info.lineHeight;
+
+ mEventData->mDecorator->AddHighlight( actualNumberOfQuads,
+ quad );
+ ++actualNumberOfQuads;
+
+ quad.x = info.maxX;
+ quad.y = info.lineOffset;
+ quad.z = mVisualModel->mControlSize.width;
+ quad.w = info.lineOffset + info.lineHeight;
+
+ mEventData->mDecorator->AddHighlight( actualNumberOfQuads,
+ quad );
+ ++actualNumberOfQuads;
+ }
+
+ // Update the size of the highlighted text.
+ minHighlightX = 0.f;
+ maxHighlightX = mVisualModel->mControlSize.width;
+ }
+
+ // Boxify the last line.
+ lineRun = mVisualModel->mLines.Begin() + firstLineIndex + numberOfLines - 1u;
+ const SelectionBoxInfo& lastSelectionBoxLineInfo = *( selectionBoxLinesInfo.End() - 1u );
+
+ boxifyBegin = ( LTR == lineRun->direction ) && ( LTR == endDirection );
+ boxifyEnd = ( LTR != lineRun->direction ) && ( LTR != endDirection );
+
+ if( boxifyBegin )
+ {
+ quad.x = 0.f;
+ quad.y = lastSelectionBoxLineInfo.lineOffset;
+ quad.z = lastSelectionBoxLineInfo.minX;
+ quad.w = lastSelectionBoxLineInfo.lineOffset + lastSelectionBoxLineInfo.lineHeight;
+
+ // Boxify at the beginning of the line.
+ mEventData->mDecorator->AddHighlight( actualNumberOfQuads,
+ quad );
+ ++actualNumberOfQuads;
+
+ // Update the size of the highlighted text.
+ minHighlightX = 0.f;
+ }
+
+ if( boxifyEnd )
+ {
+ quad.x = lastSelectionBoxLineInfo.maxX;
+ quad.y = lastSelectionBoxLineInfo.lineOffset;
+ quad.z = mVisualModel->mControlSize.width;
+ quad.w = lastSelectionBoxLineInfo.lineOffset + lastSelectionBoxLineInfo.lineHeight;
+
+ // Boxify at the end of the line.
+ mEventData->mDecorator->AddHighlight( actualNumberOfQuads,
+ quad );
+ ++actualNumberOfQuads;
+
+ // Update the size of the highlighted text.
+ maxHighlightX = mVisualModel->mControlSize.width;
+ }