#include "config.h"
#include "RenderPart.h"
#include "RenderView.h"
#include "Frame.h"
#include "FrameView.h"
#include "HTMLFrameElementBase.h"
namespace WebCore {
RenderPart::RenderPart(Element* node)
: RenderWidget(node)
, m_hasFallbackContent(false)
{
setInline(false);
}
RenderPart::~RenderPart()
{
clearWidget();
}
void RenderPart::setWidget(PassRefPtr<Widget> widget)
{
if (widget == this->widget())
return;
RenderWidget::setWidget(widget);
viewCleared();
}
void RenderPart::layoutWithFlattening(bool fixedWidth, bool fixedHeight)
{
FrameView* childFrameView = static_cast<FrameView*>(widget());
RenderView* childRoot = childFrameView ? static_cast<RenderView*>(childFrameView->frame()->contentRenderer()) : 0;
if (!width() || !height() || !childRoot) {
updateWidgetPosition();
if (childFrameView)
childFrameView->layout();
setNeedsLayout(false);
return;
}
updateWidgetPosition();
if (childRoot->prefWidthsDirty())
childRoot->calcPrefWidths();
HTMLFrameElementBase* element = static_cast<HTMLFrameElementBase*>(node());
bool isScrollable = element->scrollingMode() != ScrollbarAlwaysOff;
int hBorder = borderLeft() + borderRight();
int vBorder = borderTop() + borderBottom();
if (isScrollable || !fixedWidth) {
setWidth(max(width(), childRoot->minPrefWidth() + hBorder));
updateWidgetPosition();
childFrameView->layout();
}
if (isScrollable || !fixedHeight || childRoot->isFrameSet())
setHeight(max(height(), childFrameView->contentsHeight() + vBorder));
if (isScrollable || !fixedWidth || childRoot->isFrameSet())
setWidth(max(width(), childFrameView->contentsWidth() + hBorder));
updateWidgetPosition();
ASSERT(!childFrameView->layoutPending());
ASSERT(!childRoot->needsLayout());
ASSERT(!childRoot->firstChild() || !childRoot->firstChild()->firstChild() || !childRoot->firstChild()->firstChild()->needsLayout());
setNeedsLayout(false);
}
void RenderPart::viewCleared()
{
}
}