/*---------------------------------------------------------------------------*/ void HTMLBodyDisplay::Format(void) { DisplayManager *manager = GetManager(); if (manager) { PresetWebRect rect(&manager->mViewRect); DISPLAY_INT viewportWidth = rect.Width(); DISPLAY_INT viewportHeight = rect.Height(); WEBC_DEBUG_LOG_TIME_HANDLE(TimeInside) WEBC_DEBUG_LOG_TIME_ENTER(TimeInside,"HTMLBodyDisplay::Format", " ") rect.MoveTo(0, 0); SetParentWidth(viewportWidth, viewportWidth); SetParentHeight(viewportHeight); #if (WEBC_SUPPORT_FRAMES) HTMLBody* bodyElement = (HTMLBody*) mpHtmlElement; HTMLFrameSet* framesetElement = (bodyElement)? bodyElement->GetFrameSet() : 0; mpFrameSet = (HTMLFrameSetDisplay*) ((framesetElement)? framesetElement->GetDisplayElement() : 0); if (mpFrameSet) { // remove all old children while (mpFirstChild) { Remove(mpFirstChild); } // add the frameset mpFrameSet->SetParentWidth(viewportWidth, viewportWidth); mpFrameSet->SetParentHeight(viewportHeight); mpFrameSet->SetXYPosition(0,0); mpFrameSet->SetParentDisplay(this, 0); miContentHeight = viewportHeight; miMaxWidth = viewportWidth; miMinWidth = viewportWidth; mFlowFlags &= ~(FD_FLAG_POS_CHILD_STYLE_MODIFIED| FD_FLAG_FLOW_CHILD_STYLE_MODIFIED| FD_FLAG_LOCAL_STYLE_MODIFIED| FD_FLAG_PARENT_STYLE_MODIFIED); } else #endif // WEBC_SUPPORT_FRAMES { DISPLAY_INT marginLeftValue = GetLeftMargin(); DISPLAY_INT marginRightValue = GetRightMargin(); DISPLAY_INT marginTopValue = GetTopMargin(); DISPLAY_INT paddingLeftValue = mBorder.GetPaddingWidth(CSS_LEFT); DISPLAY_INT paddingRightValue = mBorder.GetPaddingWidth(CSS_RIGHT); DISPLAY_INT paddingTopValue = mBorder.GetPaddingWidth(CSS_TOP); // check to see if we just need to update positioned child formatting if (mFlowFlags & (FD_FLAG_FLOW_CHILD_STYLE_MODIFIED| FD_FLAG_LOCAL_STYLE_MODIFIED| FD_FLAG_PARENT_STYLE_MODIFIED)) { DISPLAY_INT iContentWidth; MarginContext margin (marginLeftValue + paddingLeftValue, viewportWidth - (marginRightValue + paddingRightValue) - 1, this); // Format the flow content miContentHeight = FormatFlowContent (&margin, marginLeftValue + paddingLeftValue, marginTopValue + paddingTopValue, &iContentWidth); // update miContentHeight to include anything in the margins DISPLAY_INT topPad = marginTopValue + paddingTopValue; DISPLAY_INT clearedHeight = margin.ClearAll(topPad + miContentHeight) - topPad; if (clearedHeight > miContentHeight) { miContentHeight = clearedHeight; } // set this element's height UpdateHeight(0, 0); } // Format positioned elements FormatContextFactory childContextFactory; if (mPositionedChildFormatContext) { WebRect oldRect; mPositionedChildFormatContext->getContainingBlock(&oldRect); if (!oldRect.Equals(&rect) || miContentHeight != mPositionedChildFormatContext->getAutoIndentTop()) { mPositionedChildFormatContext->release(); mPositionedChildFormatContext = 0; } } WEBC_BOOL reformatPositionedChildren = (mFlowFlags & FD_FLAG_POS_CHILD_STYLE_MODIFIED) != 0; if (!mPositionedChildFormatContext) { mPositionedChildFormatContext = childContextFactory.newPositioned ( &rect, // containingBlock, WEBC_FALSE, // parentHeightIsAuto, TU_DIR_LTR, // textDirection, 0, // parentBorderLeft, 0, // parentBorderTop, 0, // parentBorderRight, 0, // parentBorderBottom, marginLeftValue, // autoIndentLeft, miContentHeight, // autoIndentTop, marginRightValue // autoIndentRight ); reformatPositionedChildren = (mPositionedChildFormatContext != WEBC_NULL); } if (reformatPositionedChildren) { HTMLFlowDisplayFormatContext formatCtx; BeginFormatPositionedChildren(&formatCtx); FormatPositionedChildren ( mPositionedChildFormatContext, mPositionedChildFormatContext, &childContextFactory ); EndFormatPositionedChildren(&formatCtx); } mFlowFlags &= ~(FD_FLAG_POS_CHILD_STYLE_MODIFIED| FD_FLAG_FLOW_CHILD_STYLE_MODIFIED| FD_FLAG_LOCAL_STYLE_MODIFIED| FD_FLAG_PARENT_STYLE_MODIFIED); } WEBC_ASSERT(!NeedsFormat()); // handles the case where HTMLDocument::ScrollToAnchor is called before the // document's content has been formatted. if (mpHtmlElement) { HTMLDocument* document = mpHtmlElement->GetDocument(); if (document) { document->ScrollToDefaultAnchor(); document->SetQueuedFocus(); } } WEBC_DEBUG_LOG_TIME_EXIT(TimeInside,"HTMLBodyDisplay::Format", " ") } }