RenderFrameBase.cpp [plain text]
#include "config.h"
#include "RenderFrameBase.h"
#include "Frame.h"
#include "FrameView.h"
#include "HTMLFrameElementBase.h"
#include "RenderView.h"
namespace WebCore {
RenderFrameBase::RenderFrameBase(Element* element)
: RenderPart(element)
{
}
inline bool shouldExpandFrame(LayoutUnit width, LayoutUnit height, bool hasFixedWidth, bool hasFixedHeight)
{
if (!width || !height)
return false;
static unsigned smallestUsefullyScrollableDimension = 8;
if (hasFixedWidth && width < LayoutUnit(smallestUsefullyScrollableDimension))
return false;
if (hasFixedHeight && height < LayoutUnit(smallestUsefullyScrollableDimension))
return false;
return true;
}
void RenderFrameBase::layoutWithFlattening(bool hasFixedWidth, bool hasFixedHeight)
{
FrameView* childFrameView = toFrameView(widget());
RenderView* childRoot = childFrameView ? childFrameView->frame()->contentRenderer() : 0;
if (!childRoot || !shouldExpandFrame(width(), height(), hasFixedWidth, hasFixedHeight)) {
updateWidgetPosition();
if (childFrameView)
childFrameView->layout();
setNeedsLayout(false);
return;
}
updateWidgetPosition();
HTMLFrameElementBase* element = static_cast<HTMLFrameElementBase*>(node());
bool isScrollable = element->scrollingMode() != ScrollbarAlwaysOff;
int hBorder = borderLeft() + borderRight();
int vBorder = borderTop() + borderBottom();
if (isScrollable || !hasFixedWidth) {
setWidth(max(width(), childRoot->minPreferredLogicalWidth() + hBorder));
updateWidgetPosition();
childFrameView->layout();
}
if (isScrollable || !hasFixedHeight || childRoot->isFrameSet())
setHeight(max<LayoutUnit>(height(), childFrameView->contentsHeight() + vBorder));
if (isScrollable || !hasFixedWidth || childRoot->isFrameSet())
setWidth(max<LayoutUnit>(width(), childFrameView->contentsWidth() + hBorder));
updateWidgetPosition();
ASSERT(!childFrameView->layoutPending());
ASSERT(!childRoot->needsLayout());
ASSERT(!childRoot->firstChild() || !childRoot->firstChild()->firstChild() || !childRoot->firstChild()->firstChild()->needsLayout());
setNeedsLayout(false);
}
}