#include "config.h"
#include "RenderFrame.h"
#include "FrameView.h"
#include "HTMLFrameElement.h"
#include "Document.h"
#include "Frame.h"
#include "RenderView.h"
namespace WebCore {
RenderFrame::RenderFrame(HTMLFrameElement* frame)
: RenderPart(frame)
{
setInline(false);
}
FrameEdgeInfo RenderFrame::edgeInfo() const
{
HTMLFrameElement* element = static_cast<HTMLFrameElement*>(node());
return FrameEdgeInfo(element->noResize(), element->hasFrameBorder());
}
void RenderFrame::viewCleared()
{
HTMLFrameElement* element = static_cast<HTMLFrameElement*>(node());
if (!element || !widget() || !widget()->isFrameView())
return;
FrameView* view = static_cast<FrameView*>(widget());
int marginw = element->getMarginWidth();
int marginh = element->getMarginHeight();
if (marginw != -1)
view->setMarginWidth(marginw);
if (marginh != -1)
view->setMarginHeight(marginh);
}
void RenderFrame::layoutWithFlattening(bool flexibleWidth, bool flexibleHeight)
{
FrameView* childFrameView = static_cast<FrameView*>(widget());
RenderView* childRoot = childFrameView ? childFrameView->frame()->contentRenderer() : 0;
if (!width() || !height() || !childRoot) {
updateWidgetPosition();
if (childFrameView)
while (childFrameView->layoutPending())
childFrameView->layout();
setNeedsLayout(false);
return;
}
updateWidgetPosition();
if (childRoot->prefWidthsDirty())
childRoot->calcPrefWidths();
bool scrolling = static_cast<HTMLFrameElement*>(node())->scrollingMode() != ScrollbarAlwaysOff;
if (scrolling || flexibleWidth || childFrameView->frame()->document()->isFrameSet())
setWidth(max(width(), childRoot->minPrefWidth()));
updateWidgetPosition();
do
childFrameView->layout();
while (childFrameView->layoutPending() || childRoot->needsLayout());
if (scrolling || flexibleHeight || childFrameView->frame()->document()->isFrameSet())
setHeight(max(height(), childFrameView->contentsHeight()));
if (scrolling || flexibleWidth || childFrameView->frame()->document()->isFrameSet())
setWidth(max(width(), childFrameView->contentsWidth()));
updateWidgetPosition();
ASSERT(!childFrameView->layoutPending());
ASSERT(!childRoot->needsLayout());
ASSERT(!childRoot->firstChild() || !childRoot->firstChild()->firstChild() || !childRoot->firstChild()->firstChild()->needsLayout());
setNeedsLayout(false);
}
}