@@ -59,6 +59,10 @@ public class LineRenderer : AbstractRenderer {
5959
6060 protected internal float maxDescent ;
6161
62+ protected internal byte [ ] levels ;
63+
64+ private const float MIN_MAX_WIDTH_CORRECTION_EPS = 0.001f ;
65+
6266 private float maxTextAscent ;
6367
6468 private float maxTextDescent ;
@@ -67,9 +71,8 @@ public class LineRenderer : AbstractRenderer {
6771
6872 private float maxBlockDescent ;
6973
70- protected internal byte [ ] levels ;
71-
7274 // bidi levels
75+ // AbstractRenderer.EPS is not enough here
7376 public override LayoutResult Layout ( LayoutContext layoutContext ) {
7477 Rectangle layoutBox = layoutContext . GetArea ( ) . GetBBox ( ) . Clone ( ) ;
7578 IList < Rectangle > floatRendererAreas = layoutContext . GetFloatRendererAreas ( ) ;
@@ -236,9 +239,7 @@ public override LayoutResult Layout(LayoutContext layoutContext) {
236239 if ( isInlineBlockChild && childRenderer is AbstractRenderer ) {
237240 childBlockMinMaxWidth = ( ( AbstractRenderer ) childRenderer ) . GetMinMaxWidth ( layoutContext . GetArea ( ) . GetBBox ( )
238241 . GetWidth ( ) ) ;
239- // TODO fix eps?
240- float eps = 0.001f ;
241- float childMaxWidth = childBlockMinMaxWidth . GetMaxWidth ( ) + eps ;
242+ float childMaxWidth = childBlockMinMaxWidth . GetMaxWidth ( ) + MIN_MAX_WIDTH_CORRECTION_EPS ;
242243 // Decrease the calculated width by margins, paddings and borders so that even for 100% width the content definitely fits
243244 // TODO DEVSIX-1174 fix depending on box-sizing
244245 if ( childBlockMinMaxWidth != null ) {
@@ -310,7 +311,6 @@ public override LayoutResult Layout(LayoutContext layoutContext) {
310311 }
311312 }
312313 maxAscent = Math . Max ( maxAscent , childAscent ) ;
313- // TODO treat images as blocks
314314 if ( childRenderer is TextRenderer ) {
315315 maxTextAscent = Math . Max ( maxTextAscent , childAscent ) ;
316316 }
@@ -320,7 +320,6 @@ public override LayoutResult Layout(LayoutContext layoutContext) {
320320 }
321321 }
322322 maxDescent = Math . Min ( maxDescent , childDescent ) ;
323- // TODO treat images as blocks
324323 if ( childRenderer is TextRenderer ) {
325324 maxTextDescent = Math . Min ( maxTextDescent , childDescent ) ;
326325 }
@@ -467,7 +466,6 @@ public override LayoutResult Layout(LayoutContext layoutContext) {
467466 }
468467 }
469468 if ( baseDirection != null && baseDirection != BaseDirection . NO_BIDI ) {
470- // TODO what about float inlines?
471469 IList < IRenderer > children = null ;
472470 if ( result . GetStatus ( ) == LayoutResult . PARTIAL ) {
473471 children = result . GetSplitRenderer ( ) . GetChildRenderers ( ) ;
@@ -481,7 +479,7 @@ public override LayoutResult Layout(LayoutContext layoutContext) {
481479 bool newLineFound = false ;
482480 IList < LineRenderer . RendererGlyph > lineGlyphs = new List < LineRenderer . RendererGlyph > ( ) ;
483481 // We shouldn't forget about images, float, inline-blocks that has to be inserted somewhere.
484- // TODO determine correct place to insert this content
482+ // TODO determine correct place to insert this content. Probably consider inline floats separately.
485483 IDictionary < TextRenderer , IRenderer > insertAfter = new Dictionary < TextRenderer , IRenderer > ( ) ;
486484 IList < IRenderer > starterNonTextRenderers = new List < IRenderer > ( ) ;
487485 TextRenderer lastTextRenderer = null ;
@@ -814,7 +812,10 @@ internal virtual float GetTopLeadingIndent(Leading leading) {
814812
815813 case Leading . MULTIPLIED : {
816814 float fontSize = ( float ) this . GetPropertyAsFloat ( Property . FONT_SIZE , 0f ) ;
817- // TODO contains image to be removed
815+ // In HTML, depending on whether <!DOCTYPE html> is present or not, and if present then depending on the version,
816+ // the behavior id different. In one case, bottom leading indent is added for images, in the other it is not added.
817+ // This is why !containsImage() is present below. Depending on the presence of this !containsImage() condition, the behavior changes
818+ // between the two possible scenarios in HTML.
818819 float textAscent = maxTextAscent == 0 && maxTextDescent == 0 && Math . Abs ( maxAscent ) + Math . Abs ( maxDescent )
819820 != 0 && ! ContainsImage ( ) ? fontSize * 0.8f : maxTextAscent ;
820821 float textDescent = maxTextAscent == 0 && maxTextDescent == 0 && Math . Abs ( maxAscent ) + Math . Abs ( maxDescent
@@ -838,7 +839,10 @@ internal virtual float GetBottomLeadingIndent(Leading leading) {
838839
839840 case Leading . MULTIPLIED : {
840841 float fontSize = ( float ) this . GetPropertyAsFloat ( Property . FONT_SIZE , 0f ) ;
841- // TODO contains image to be removed
842+ // In HTML, depending on whether <!DOCTYPE html> is present or not, and if present then depending on the version,
843+ // the behavior id different. In one case, bottom leading indent is added for images, in the other it is not added.
844+ // This is why !containsImage() is present below. Depending on the presence of this !containsImage() condition, the behavior changes
845+ // between the two possible scenarios in HTML.
842846 float textAscent = maxTextAscent == 0 && maxTextDescent == 0 && ! ContainsImage ( ) ? fontSize * 0.8f : maxTextAscent ;
843847 float textDescent = maxTextAscent == 0 && maxTextDescent == 0 && ! ContainsImage ( ) ? - fontSize * 0.2f : maxTextDescent ;
844848 return Math . Max ( - textDescent + ( ( textAscent - textDescent ) * ( leading . GetValue ( ) - 1 ) ) / 2 , - maxBlockDescent
0 commit comments