/* (non-Javadoc)
 * @see com.itextpdf.layout.renderer.DocumentRenderer#updateCurrentArea(com.itextpdf.layout.layout.LayoutResult)
 */
 protected override LayoutArea UpdateCurrentArea(LayoutResult overflowResult) {
     AreaBreak areaBreak = overflowResult != null ? overflowResult.GetAreaBreak() : null;
     if (areaBreak is HtmlPageBreak) {
         HtmlPageBreakType htmlPageBreakType = ((HtmlPageBreak)areaBreak).GetBreakType();
         if (shouldTrimFirstBlankPagesCausedByBreakBeforeFirstElement && currentArea != null && overflowResult.GetStatus
             () == LayoutResult.NOTHING && currentArea.IsEmptyArea() && currentArea.GetPageNumber() == 1) {
             // Remove blank page that was added just to have area for elements to layout on.
             // Now we will add a page with dimensions and all the stuff that is requested by page-break-before
             document.GetPdfDocument().RemovePage(1);
             currentPageNumber = 0;
             overflowResult = null;
             currentArea = null;
             shouldTrimFirstBlankPagesCausedByBreakBeforeFirstElement = false;
             if (HtmlPageBreakType.LEFT.Equals(htmlPageBreakType) && !IsPageLeft(1) || HtmlPageBreakType.RIGHT.Equals(htmlPageBreakType
                 ) && !IsPageRight(1)) {
                 evenPagesAreLeft = !evenPagesAreLeft;
             }
         }
         // hack to change the "evenness" of the first page without adding an unnecessary blank page
         anythingAddedToCurrentArea = anythingAddedToCurrentArea || overflowResult != null && overflowResult.GetStatus
             () == LayoutResult.PARTIAL;
         if (HtmlPageBreakType.ALWAYS.Equals(htmlPageBreakType)) {
             LayoutArea nextArea = currentArea;
             if (anythingAddedToCurrentArea || currentArea == null) {
                 nextArea = base.UpdateCurrentArea(overflowResult);
             }
             anythingAddedToCurrentArea = false;
             return nextArea;
         }
         else {
             if (HtmlPageBreakType.LEFT.Equals(htmlPageBreakType)) {
                 LayoutArea nextArea = currentArea;
                 if (anythingAddedToCurrentArea || currentArea == null || !IsPageLeft(currentPageNumber)) {
                     do {
                         nextArea = base.UpdateCurrentArea(overflowResult);
                     }
                     while (!IsPageLeft(currentPageNumber));
                 }
                 anythingAddedToCurrentArea = false;
                 return nextArea;
             }
             else {
                 if (HtmlPageBreakType.RIGHT.Equals(htmlPageBreakType)) {
                     LayoutArea nextArea = currentArea;
                     if (anythingAddedToCurrentArea || currentArea == null || !IsPageRight(currentPageNumber)) {
                         do {
                             nextArea = base.UpdateCurrentArea(overflowResult);
                         }
                         while (!IsPageRight(currentPageNumber));
                     }
                     anythingAddedToCurrentArea = false;
                     return nextArea;
                 }
             }
         }
     }
     anythingAddedToCurrentArea = false;
     return base.UpdateCurrentArea(overflowResult);
 }
 /// <summary>Instantiates a new html page break.</summary>
 /// <param name="type">the page break type</param>
 public HtmlPageBreak(HtmlPageBreakType type)
 {
     this.breakType = type;
 }