2 * Copyright (C) 2010 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 #if ENABLE(FULLSCREEN_API)
29 #include "RenderFullScreen.h"
31 #include "RenderLayer.h"
33 #if USE(ACCELERATED_COMPOSITING)
34 #include "RenderLayerCompositor.h"
37 using namespace WebCore;
39 class RenderFullScreenPlaceholder : public RenderBlock {
41 RenderFullScreenPlaceholder(RenderFullScreen* owner)
42 : RenderBlock(owner->document())
47 virtual bool isRenderFullScreenPlaceholder() const { return true; }
48 virtual void willBeDestroyed();
49 RenderFullScreen* m_owner;
52 void RenderFullScreenPlaceholder::willBeDestroyed()
54 m_owner->setPlaceholder(0);
55 RenderBlock::willBeDestroyed();
58 RenderFullScreen::RenderFullScreen(Node* node)
59 : RenderDeprecatedFlexibleBox(node)
65 void RenderFullScreen::willBeDestroyed()
69 if (!m_placeholder->beingDestroyed())
70 m_placeholder->destroy();
71 ASSERT(!m_placeholder);
74 // RenderObjects are unretained, so notify the document (which holds a pointer to a RenderFullScreen)
75 // if it's RenderFullScreen is destroyed.
76 if (document() && document()->fullScreenRenderer() == this)
77 document()->fullScreenRendererDestroyed();
79 RenderDeprecatedFlexibleBox::willBeDestroyed();
82 PassRefPtr<RenderStyle> RenderFullScreen::createFullScreenStyle()
84 RefPtr<RenderStyle> fullscreenStyle = RenderStyle::createDefaultStyle();
86 // Create a stacking context:
87 fullscreenStyle->setZIndex(INT_MAX);
89 fullscreenStyle->setFontDescription(FontDescription());
90 fullscreenStyle->font().update(0);
92 fullscreenStyle->setDisplay(BOX);
93 fullscreenStyle->setBoxPack(BCENTER);
94 fullscreenStyle->setBoxAlign(BCENTER);
95 fullscreenStyle->setBoxOrient(VERTICAL);
97 fullscreenStyle->setPosition(FixedPosition);
98 fullscreenStyle->setWidth(Length(100.0, Percent));
99 fullscreenStyle->setHeight(Length(100.0, Percent));
100 fullscreenStyle->setLeft(Length(0, Fixed));
101 fullscreenStyle->setTop(Length(0, Fixed));
103 fullscreenStyle->setBackgroundColor(Color::black);
105 return fullscreenStyle.release();
108 void RenderFullScreen::setPlaceholder(RenderBlock* placeholder)
110 m_placeholder = placeholder;
113 void RenderFullScreen::createPlaceholder(PassRefPtr<RenderStyle> style, const IntRect& frameRect)
115 if (style->width().isAuto())
116 style->setWidth(Length(frameRect.width(), Fixed));
117 if (style->height().isAuto())
118 style->setHeight(Length(frameRect.height(), Fixed));
120 if (!m_placeholder) {
121 m_placeholder = new (document()->renderArena()) RenderFullScreenPlaceholder(this);
122 m_placeholder->setStyle(style);
124 parent()->addChild(m_placeholder, this);
127 m_placeholder->addChild(this);
129 m_placeholder->setStyle(style);