This source file includes following definitions.
- m_owner
- isRenderFullScreenPlaceholder
- willBeDestroyed
- m_placeholder
- createAnonymous
- willBeDestroyed
- createFullScreenStyle
- wrapRenderer
- unwrapRenderer
- setPlaceholder
- createPlaceholder
#include "config.h"
#include "core/rendering/RenderFullScreen.h"
#include "core/dom/FullscreenElementStack.h"
#include "core/rendering/RenderBlockFlow.h"
using namespace WebCore;
class RenderFullScreenPlaceholder FINAL : public RenderBlockFlow {
public:
RenderFullScreenPlaceholder(RenderFullScreen* owner)
: RenderBlockFlow(0)
, m_owner(owner)
{
setDocumentForAnonymous(&owner->document());
}
private:
virtual bool isRenderFullScreenPlaceholder() const OVERRIDE { return true; }
virtual void willBeDestroyed() OVERRIDE;
RenderFullScreen* m_owner;
};
void RenderFullScreenPlaceholder::willBeDestroyed()
{
m_owner->setPlaceholder(0);
RenderBlock::willBeDestroyed();
}
RenderFullScreen::RenderFullScreen()
: RenderFlexibleBox(0)
, m_placeholder(0)
{
setReplaced(false);
}
RenderFullScreen* RenderFullScreen::createAnonymous(Document* document)
{
RenderFullScreen* renderer = new RenderFullScreen();
renderer->setDocumentForAnonymous(document);
return renderer;
}
void RenderFullScreen::willBeDestroyed()
{
if (m_placeholder) {
remove();
if (!m_placeholder->beingDestroyed())
m_placeholder->destroy();
ASSERT(!m_placeholder);
}
FullscreenElementStack& controller = FullscreenElementStack::from(document());
if (controller.fullScreenRenderer() == this)
controller.fullScreenRendererDestroyed();
RenderFlexibleBox::willBeDestroyed();
}
static PassRefPtr<RenderStyle> createFullScreenStyle()
{
RefPtr<RenderStyle> fullscreenStyle = RenderStyle::createDefaultStyle();
fullscreenStyle->setZIndex(INT_MAX);
fullscreenStyle->setFontDescription(FontDescription());
fullscreenStyle->font().update(nullptr);
fullscreenStyle->setDisplay(FLEX);
fullscreenStyle->setJustifyContent(JustifyCenter);
fullscreenStyle->setAlignItems(ItemPositionCenter);
fullscreenStyle->setFlexDirection(FlowColumn);
fullscreenStyle->setPosition(FixedPosition);
fullscreenStyle->setWidth(Length(100.0, Percent));
fullscreenStyle->setHeight(Length(100.0, Percent));
fullscreenStyle->setLeft(Length(0, WebCore::Fixed));
fullscreenStyle->setTop(Length(0, WebCore::Fixed));
fullscreenStyle->setBackgroundColor(StyleColor(Color::black));
return fullscreenStyle.release();
}
RenderObject* RenderFullScreen::wrapRenderer(RenderObject* object, RenderObject* parent, Document* document)
{
RenderFullScreen* fullscreenRenderer = RenderFullScreen::createAnonymous(document);
fullscreenRenderer->setStyle(createFullScreenStyle());
if (parent && !parent->isChildAllowed(fullscreenRenderer, fullscreenRenderer->style())) {
fullscreenRenderer->destroy();
return 0;
}
if (object) {
if (RenderObject* parent = object->parent()) {
RenderBlock* containingBlock = object->containingBlock();
ASSERT(containingBlock);
containingBlock->deleteLineBoxTree();
parent->addChild(fullscreenRenderer, object);
object->remove();
parent->setNeedsLayoutAndPrefWidthsRecalc();
containingBlock->setNeedsLayoutAndPrefWidthsRecalc();
}
fullscreenRenderer->addChild(object);
fullscreenRenderer->setNeedsLayoutAndPrefWidthsRecalc();
}
ASSERT(document);
FullscreenElementStack::from(*document).setFullScreenRenderer(fullscreenRenderer);
return fullscreenRenderer;
}
void RenderFullScreen::unwrapRenderer()
{
if (parent()) {
RenderObject* child;
while ((child = firstChild())) {
if (child->isBox())
toRenderBox(child)->clearOverrideSize();
child->remove();
parent()->addChild(child, this);
parent()->setNeedsLayoutAndPrefWidthsRecalc();
}
}
if (placeholder())
placeholder()->remove();
remove();
FullscreenElementStack::from(document()).setFullScreenRenderer(0);
}
void RenderFullScreen::setPlaceholder(RenderBlock* placeholder)
{
m_placeholder = placeholder;
}
void RenderFullScreen::createPlaceholder(PassRefPtr<RenderStyle> style, const LayoutRect& frameRect)
{
if (style->width().isAuto())
style->setWidth(Length(frameRect.width(), Fixed));
if (style->height().isAuto())
style->setHeight(Length(frameRect.height(), Fixed));
if (!m_placeholder) {
m_placeholder = new RenderFullScreenPlaceholder(this);
m_placeholder->setStyle(style);
if (parent()) {
parent()->addChild(m_placeholder, this);
parent()->setNeedsLayoutAndPrefWidthsRecalc();
}
} else
m_placeholder->setStyle(style);
}