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)
{
FrameView* childFrameView = childView();
RenderView* childRoot = childFrameView ? childFrameView->frame().contentRenderer() : 0;
if (!childRoot || !shouldExpandFrame(width(), height(), hasFixedWidth, hasFixedHeight)) {
updateWidgetPosition();
if (childFrameView)
childFrameView->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();
childFrameView->layout();
}
if (isScrollable || !hasFixedHeight || childRoot->isFrameSet())
setHeight(std::max<LayoutUnit>(height(), childFrameView->contentsHeight() + vBorder));
if (isScrollable || !hasFixedWidth || childRoot->isFrameSet())
setWidth(std::max<LayoutUnit>(width(), childFrameView->contentsWidth() + hBorder));
updateWidgetPosition();
ASSERT(!childFrameView->layoutPending());
ASSERT(!childRoot->needsLayout());
ASSERT(!childRoot->firstChild() || !childRoot->firstChild()->firstChildSlow() || !childRoot->firstChild()->firstChildSlow()->needsLayout());
clearNeedsLayout();
}
}