summaryrefslogtreecommitdiff
path: root/Source/WebCore/rendering/RenderFullScreen.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/rendering/RenderFullScreen.cpp
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/rendering/RenderFullScreen.cpp')
-rw-r--r--Source/WebCore/rendering/RenderFullScreen.cpp88
1 files changed, 53 insertions, 35 deletions
diff --git a/Source/WebCore/rendering/RenderFullScreen.cpp b/Source/WebCore/rendering/RenderFullScreen.cpp
index e26756bc5..afacfbc83 100644
--- a/Source/WebCore/rendering/RenderFullScreen.cpp
+++ b/Source/WebCore/rendering/RenderFullScreen.cpp
@@ -30,24 +30,21 @@
#include "RenderBlockFlow.h"
#include "RenderLayer.h"
-
-#if USE(ACCELERATED_COMPOSITING)
#include "RenderLayerCompositor.h"
-#endif
namespace WebCore {
class RenderFullScreenPlaceholder final : public RenderBlockFlow {
public:
- RenderFullScreenPlaceholder(RenderFullScreen& owner, PassRef<RenderStyle> style)
- : RenderBlockFlow(owner.document(), std::move(style))
+ RenderFullScreenPlaceholder(RenderFullScreen& owner, RenderStyle&& style)
+ : RenderBlockFlow(owner.document(), WTFMove(style))
, m_owner(owner)
{
}
private:
- virtual bool isRenderFullScreenPlaceholder() const { return true; }
- virtual void willBeDestroyed();
+ bool isRenderFullScreenPlaceholder() const override { return true; }
+ void willBeDestroyed() override;
RenderFullScreen& m_owner;
};
@@ -57,8 +54,8 @@ void RenderFullScreenPlaceholder::willBeDestroyed()
RenderBlockFlow::willBeDestroyed();
}
-RenderFullScreen::RenderFullScreen(Document& document, PassRef<RenderStyle> style)
- : RenderFlexibleBox(document, std::move(style))
+RenderFullScreen::RenderFullScreen(Document& document, RenderStyle&& style)
+ : RenderFlexibleBox(document, WTFMove(style))
, m_placeholder(0)
{
setReplaced(false);
@@ -81,28 +78,28 @@ void RenderFullScreen::willBeDestroyed()
RenderFlexibleBox::willBeDestroyed();
}
-static PassRef<RenderStyle> createFullScreenStyle()
+static RenderStyle createFullScreenStyle()
{
- auto fullscreenStyle = RenderStyle::createDefaultStyle();
+ auto fullscreenStyle = RenderStyle::create();
// Create a stacking context:
- fullscreenStyle.get().setZIndex(INT_MAX);
+ fullscreenStyle.setZIndex(INT_MAX);
- fullscreenStyle.get().setFontDescription(FontDescription());
- fullscreenStyle.get().font().update(0);
+ fullscreenStyle.setFontDescription({ });
+ fullscreenStyle.fontCascade().update(nullptr);
- fullscreenStyle.get().setDisplay(FLEX);
- fullscreenStyle.get().setJustifyContent(JustifyCenter);
- fullscreenStyle.get().setAlignItems(AlignCenter);
- fullscreenStyle.get().setFlexDirection(FlowColumn);
+ fullscreenStyle.setDisplay(FLEX);
+ fullscreenStyle.setJustifyContentPosition(ContentPositionCenter);
+ fullscreenStyle.setAlignItemsPosition(ItemPositionCenter);
+ fullscreenStyle.setFlexDirection(FlowColumn);
- fullscreenStyle.get().setPosition(FixedPosition);
- fullscreenStyle.get().setWidth(Length(100.0, Percent));
- fullscreenStyle.get().setHeight(Length(100.0, Percent));
- fullscreenStyle.get().setLeft(Length(0, WebCore::Fixed));
- fullscreenStyle.get().setTop(Length(0, WebCore::Fixed));
+ 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.get().setBackgroundColor(Color::black);
+ fullscreenStyle.setBackgroundColor(Color::black);
return fullscreenStyle;
}
@@ -141,16 +138,37 @@ RenderFullScreen* RenderFullScreen::wrapRenderer(RenderObject* object, RenderEle
return fullscreenRenderer;
}
-void RenderFullScreen::unwrapRenderer()
+void RenderFullScreen::unwrapRenderer(bool& requiresRenderTreeRebuild)
{
+ requiresRenderTreeRebuild = false;
if (parent()) {
- RenderObject* child;
+ auto* child = firstChild();
+ // Things can get very complicated with anonymous block generation.
+ // We can restore correctly without rebuild in simple cases only.
+ // FIXME: We should have a mechanism for removing a block without reconstructing the tree.
+ if (child != lastChild())
+ requiresRenderTreeRebuild = true;
+ else if (child && child->isAnonymousBlock()) {
+ auto& anonymousBlock = downcast<RenderBlock>(*child);
+ if (anonymousBlock.firstChild() != anonymousBlock.lastChild())
+ requiresRenderTreeRebuild = true;
+ }
+
while ((child = firstChild())) {
+ if (child->isAnonymousBlock() && !requiresRenderTreeRebuild) {
+ if (auto* nonAnonymousChild = downcast<RenderBlock>(*child).firstChild())
+ child = nonAnonymousChild;
+ else {
+ child->removeFromParent();
+ child->destroy();
+ continue;
+ }
+ }
// We have to clear the override size, because as a flexbox, we
// may have set one on the child, and we don't want to leave that
// lying around on the child.
- if (child->isBox())
- toRenderBox(child)->clearOverrideSize();
+ if (is<RenderBox>(*child))
+ downcast<RenderBox>(*child).clearOverrideSize();
child->removeFromParent();
parent()->addChild(child, this);
parent()->setNeedsLayoutAndPrefWidthsRecalc();
@@ -167,19 +185,19 @@ void RenderFullScreen::setPlaceholder(RenderBlock* placeholder)
m_placeholder = placeholder;
}
-void RenderFullScreen::createPlaceholder(PassRef<RenderStyle> style, const LayoutRect& frameRect)
+void RenderFullScreen::createPlaceholder(std::unique_ptr<RenderStyle> style, const LayoutRect& frameRect)
{
- if (style.get().width().isAuto())
- style.get().setWidth(Length(frameRect.width(), Fixed));
- if (style.get().height().isAuto())
- style.get().setHeight(Length(frameRect.height(), Fixed));
+ 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->setStyle(std::move(style));
+ m_placeholder->setStyle(WTFMove(*style));
return;
}
- m_placeholder = new RenderFullScreenPlaceholder(*this, std::move(style));
+ m_placeholder = new RenderFullScreenPlaceholder(*this, WTFMove(*style));
m_placeholder->initializeStyle();
if (parent()) {
parent()->addChild(m_placeholder, this);