#include "config.h"
#include "RenderIFrame.h"
#include "Frame.h"
#include "FrameView.h"
#include "HTMLIFrameElement.h"
#include "HTMLNames.h"
#include "RenderView.h"
#include "Settings.h"
#include <wtf/StackStats.h>
namespace WebCore {
WTF_MAKE_ISO_ALLOCATED_IMPL(RenderIFrame);
using namespace HTMLNames;
RenderIFrame::RenderIFrame(HTMLIFrameElement& element, RenderStyle&& style)
: RenderFrameBase(element, WTFMove(style))
{
}
HTMLIFrameElement& RenderIFrame::iframeElement() const
{
return downcast<HTMLIFrameElement>(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::isFullScreenIFrame() const
{
return style().hasOutOfFlowPosition() && style().hasViewportUnits();
}
bool RenderIFrame::flattenFrame() const
{
if (view().frameView().effectiveFrameFlattening() == FrameFlattening::Disabled)
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;
if (view().frameView().effectiveFrameFlattening() <= FrameFlattening::EnabledForNonFullScreenIFrames && isFullScreenIFrame())
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();
}
}