#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"
namespace WebCore {
using namespace HTMLNames;
RenderIFrame::RenderIFrame(Element* element)
: RenderFrameBase(element)
{
}
void RenderIFrame::computeLogicalHeight()
{
RenderPart::computeLogicalHeight();
if (!flattenFrame())
return;
HTMLIFrameElement* frame = static_cast<HTMLIFrameElement*>(node());
bool isScrollable = frame->scrollingMode() != ScrollbarAlwaysOff;
if (isScrollable || !style()->height().isFixed()) {
FrameView* view = static_cast<FrameView*>(widget());
if (!view)
return;
int border = borderTop() + borderBottom();
setHeight(max(height(), view->contentsHeight() + border));
}
}
void RenderIFrame::computeLogicalWidth()
{
RenderPart::computeLogicalWidth();
if (!flattenFrame())
return;
HTMLIFrameElement* frame = static_cast<HTMLIFrameElement*>(node());
bool isScrollable = frame->scrollingMode() != ScrollbarAlwaysOff;
if (isScrollable || !style()->width().isFixed()) {
FrameView* view = static_cast<FrameView*>(widget());
if (!view)
return;
int border = borderLeft() + borderRight();
setWidth(max(width(), view->contentsWidth() + border));
}
}
bool RenderIFrame::flattenFrame()
{
if (!node() || !node()->hasTagName(iframeTag))
return false;
HTMLIFrameElement* element = static_cast<HTMLIFrameElement*>(node());
bool isScrollable = element->scrollingMode() != ScrollbarAlwaysOff;
if (!isScrollable && style()->width().isFixed()
&& style()->height().isFixed())
return false;
Frame* frame = element->document()->frame();
bool enabled = frame && frame->settings()->frameFlatteningEnabled();
if (!enabled || !frame->page())
return false;
FrameView* view = frame->page()->mainFrame()->view();
if (!view)
return false;
return absoluteBoundingBoxRect().intersects(IntRect(IntPoint(0, 0), view->contentsSize()));
}
void RenderIFrame::layout()
{
ASSERT(needsLayout());
RenderPart::computeLogicalWidth();
RenderPart::computeLogicalHeight();
if (flattenFrame()) {
layoutWithFlattening(style()->width().isFixed(), style()->height().isFixed());
return;
}
RenderPart::layout();
m_overflow.clear();
addBoxShadowAndBorderOverflow();
updateLayerTransform();
setNeedsLayout(false);
}
}