#include "config.h"
#include "RenderIFrame.h"
#include "Frame.h"
#include "FrameView.h"
#include "HTMLIFrameElement.h"
#include "HTMLNames.h"
#include "Page.h"
#include "RenderView.h"
#include "Settings.h"
#include <wtf/StackStats.h>
namespace WebCore {
using namespace HTMLNames;
RenderIFrame::RenderIFrame(HTMLIFrameElement& element, PassRef<RenderStyle> style)
: RenderFrameBase(element, WTF::move(style))
{
}
HTMLIFrameElement& RenderIFrame::iframeElement() const
{
return toHTMLIFrameElement(RenderFrameBase::frameOwnerElement());
}
bool RenderIFrame::shouldComputeSizeAsReplaced() const
{
return true;
}
bool RenderIFrame::isInlineBlockOrInlineTable() const
{
return isInline();
}
bool RenderIFrame::requiresLayer() const
{
return RenderFrameBase::requiresLayer() || style().resize() != RESIZE_NONE;
}
RenderView* RenderIFrame::contentRootRenderer() const
{
FrameView* childFrameView = childView();
return childFrameView ? childFrameView->frame().contentRenderer() : 0;
}
bool RenderIFrame::flattenFrame() const
{
Frame* frame = iframeElement().document().frame();
bool enabled = frame && frame->settings().frameFlatteningEnabled();
if (!enabled || !frame->page())
return false;
if (style().width().isFixed() && style().height().isFixed()) {
if (iframeElement().scrollingMode() == ScrollbarAlwaysOff)
return false;
if (style().width().value() <= 0 || style().height().value() <= 0)
return false;
}
IntRect boundingRect = absoluteBoundingBoxRectIgnoringTransforms();
return boundingRect.maxX() > 0 && boundingRect.maxY() > 0;
}
void RenderIFrame::layout()
{
StackStats::LayoutCheckPoint layoutCheckPoint;
ASSERT(needsLayout());
updateLogicalWidth();
updateLogicalHeight();
if (flattenFrame())
layoutWithFlattening(style().width().isFixed(), style().height().isFixed());
clearOverflow();
addVisualEffectOverflow();
updateLayerTransform();
clearNeedsLayout();
}
}