#include "config.h"
#include "RenderPart.h"
#include "Document.h"
#include "Frame.h"
#include "FrameTree.h"
#include "FrameView.h"
#include "HTMLFrameOwnerElement.h"
#include "HTMLNames.h"
#include "Page.h"
#include "Settings.h"
namespace WebCore {
using namespace HTMLNames;
RenderPart::RenderPart(Element* node)
: RenderWidget(node)
{
setInline(false);
}
RenderPart::~RenderPart()
{
Widget* widget = m_widget;
m_widget = 0;
if (widget && widget->isFrameView())
static_cast<FrameView*>(widget)->deref();
else
delete widget;
}
void RenderPart::setWidget(Widget* widget)
{
if (widget != m_widget) {
if (widget && widget->isFrameView())
static_cast<FrameView*>(widget)->ref();
RenderWidget::setWidget(widget);
viewCleared();
}
}
void RenderPart::viewCleared()
{
}
void RenderPart::deleteWidget()
{
if (m_widget && m_widget->isFrameView())
static_cast<FrameView*>(m_widget)->deref();
else
delete m_widget;
}
void RenderPart::updateWidgetPosition()
{
if (!m_widget)
return;
FloatPoint absPos = localToAbsolute();
absPos.move(borderLeft() + paddingLeft(), borderTop() + paddingTop());
int w = width() - borderLeft() - borderRight() - paddingLeft() - paddingRight();
int h = height() - borderTop() - borderBottom() - paddingTop() - paddingBottom();
IntRect newBounds(absPos.x(), absPos.y(), w, h);
bool boundsChanged = newBounds != m_widget->frameRect();
if (boundsChanged) {
RenderArena *arena = ref();
element()->ref();
m_widget->setFrameRect(newBounds);
element()->deref();
deref(arena);
}
if (m_widget && m_widget->isFrameView()) {
FrameView* frameView = static_cast<FrameView*>(m_widget);
if (frameView->frame() && frameView->frame()->settings() && !frameView->frame()->settings()->flatFrameSetLayoutEnabled())
frameView->layout();
}
}
}