@@ -237,24 +237,21 @@ public override LayoutResult Layout(LayoutContext layoutContext) {
237237 bool isInlineBlockChild = IsInlineBlockChild ( childRenderer ) ;
238238 if ( ! childWidthWasReplaced ) {
239239 if ( isInlineBlockChild && childRenderer is AbstractRenderer ) {
240- childBlockMinMaxWidth = ( ( AbstractRenderer ) childRenderer ) . GetMinMaxWidth ( layoutContext . GetArea ( ) . GetBBox ( )
241- . GetWidth ( ) ) ;
240+ childBlockMinMaxWidth = ( ( AbstractRenderer ) childRenderer ) . GetMinMaxWidth ( MinMaxWidthUtils . GetMax ( ) ) ;
242241 float childMaxWidth = childBlockMinMaxWidth . GetMaxWidth ( ) + MIN_MAX_WIDTH_CORRECTION_EPS ;
243242 // Decrease the calculated width by margins, paddings and borders so that even for 100% width the content definitely fits
244243 // TODO DEVSIX-1174 fix depending on box-sizing
245- if ( childBlockMinMaxWidth != null ) {
246- if ( childMaxWidth > bbox . GetWidth ( ) && bbox . GetWidth ( ) != layoutContext . GetArea ( ) . GetBBox ( ) . GetWidth ( ) ) {
247- childResult = new LineLayoutResult ( LayoutResult . NOTHING , null , null , childRenderer , childRenderer ) ;
248- }
249- else {
250- if ( bbox . GetWidth ( ) == layoutContext . GetArea ( ) . GetBBox ( ) . GetWidth ( ) && childBlockMinMaxWidth . GetMinWidth ( )
251- > layoutContext . GetArea ( ) . GetBBox ( ) . GetWidth ( ) ) {
252- LoggerFactory . GetLogger ( typeof ( LineRenderer ) ) . Warn ( iText . IO . LogMessageConstant . INLINE_BLOCK_ELEMENT_WILL_BE_CLIPPED
253- ) ;
254- childRenderer . SetProperty ( Property . FORCED_PLACEMENT , true ) ;
255- }
256- bbox . SetWidth ( childMaxWidth ) ;
244+ if ( childMaxWidth > bbox . GetWidth ( ) && bbox . GetWidth ( ) != layoutContext . GetArea ( ) . GetBBox ( ) . GetWidth ( ) ) {
245+ childResult = new LineLayoutResult ( LayoutResult . NOTHING , null , null , childRenderer , childRenderer ) ;
246+ }
247+ else {
248+ if ( bbox . GetWidth ( ) == layoutContext . GetArea ( ) . GetBBox ( ) . GetWidth ( ) && childBlockMinMaxWidth . GetMinWidth ( )
249+ > layoutContext . GetArea ( ) . GetBBox ( ) . GetWidth ( ) ) {
250+ LoggerFactory . GetLogger ( typeof ( LineRenderer ) ) . Warn ( iText . IO . LogMessageConstant . INLINE_BLOCK_ELEMENT_WILL_BE_CLIPPED
251+ ) ;
252+ childRenderer . SetProperty ( Property . FORCED_PLACEMENT , true ) ;
257253 }
254+ bbox . SetWidth ( Math . Min ( childMaxWidth , layoutContext . GetArea ( ) . GetBBox ( ) . GetWidth ( ) ) ) ;
258255 }
259256 }
260257 }
@@ -480,7 +477,7 @@ public override LayoutResult Layout(LayoutContext layoutContext) {
480477 IList < LineRenderer . RendererGlyph > lineGlyphs = new List < LineRenderer . RendererGlyph > ( ) ;
481478 // We shouldn't forget about images, float, inline-blocks that has to be inserted somewhere.
482479 // TODO determine correct place to insert this content. Probably consider inline floats separately.
483- IDictionary < TextRenderer , IRenderer > insertAfter = new Dictionary < TextRenderer , IRenderer > ( ) ;
480+ IDictionary < TextRenderer , IList < IRenderer > > insertAfter = new Dictionary < TextRenderer , IList < IRenderer > > ( ) ;
484481 IList < IRenderer > starterNonTextRenderers = new List < IRenderer > ( ) ;
485482 TextRenderer lastTextRenderer = null ;
486483 foreach ( IRenderer child in children ) {
@@ -500,7 +497,10 @@ public override LayoutResult Layout(LayoutContext layoutContext) {
500497 }
501498 else {
502499 if ( lastTextRenderer != null ) {
503- insertAfter . Put ( lastTextRenderer , child ) ;
500+ if ( ! insertAfter . ContainsKey ( lastTextRenderer ) ) {
501+ insertAfter . Put ( lastTextRenderer , new List < IRenderer > ( ) ) ;
502+ }
503+ insertAfter . Get ( lastTextRenderer ) . Add ( child ) ;
504504 }
505505 else {
506506 starterNonTextRenderers . Add ( child ) ;
@@ -528,7 +528,7 @@ public override LayoutResult Layout(LayoutContext layoutContext) {
528528 children . Add ( newRenderer ) ;
529529 // Insert non-text renderers
530530 if ( insertAfter . ContainsKey ( ( TextRenderer ) renderer ) ) {
531- children . Add ( insertAfter . Get ( ( TextRenderer ) renderer ) ) ;
531+ children . AddAll ( insertAfter . Get ( ( TextRenderer ) renderer ) ) ;
532532 insertAfter . JRemove ( ( TextRenderer ) renderer ) ;
533533 }
534534 newRenderer . line = new GlyphLine ( newRenderer . line ) ;
0 commit comments