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(HTMLFrameElementBase& element, PassRef<RenderStyle> style)
: RenderWidget(element, WTF::move(style))
{
}
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)
{
view().protectRenderWidgetUntilLayoutIsDone(*this);
RenderView* childRoot = childView() ? childView()->frame().contentRenderer() : 0;
if (!childRoot || !shouldExpandFrame(width(), height(), hasFixedWidth, hasFixedHeight)) {
updateWidgetPosition();
if (childView())
childView()->layout();
clearNeedsLayout();
return;
}
updateWidgetPosition();
bool isScrollable = frameOwnerElement().scrollingMode() != ScrollbarAlwaysOff;
int hBorder = borderLeft() + borderRight();
int vBorder = borderTop() + borderBottom();
if (isScrollable || !hasFixedWidth) {
setWidth(std::max(width(), childRoot->minPreferredLogicalWidth() + hBorder));
updateWidgetPosition();
if (childView())
childView()->layout();
}
if (childView()) {
if (isScrollable || !hasFixedHeight || childRoot->isFrameSet())
setHeight(std::max<LayoutUnit>(height(), childView()->contentsHeight() + vBorder));
if (isScrollable || !hasFixedWidth || childRoot->isFrameSet())
setWidth(std::max<LayoutUnit>(width(), childView()->contentsWidth() + hBorder));
}
updateWidgetPosition();
ASSERT(!childView()->layoutPending());
ASSERT(!childRoot->needsLayout());
ASSERT(!childRoot->firstChild() || !childRoot->firstChild()->firstChildSlow() || !childRoot->firstChild()->firstChildSlow()->needsLayout());
clearNeedsLayout();
}
}