Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / rendering / RenderFullScreen.cpp
index bca1d5b..41c5ece 100644 (file)
@@ -28,7 +28,7 @@
 #include "core/dom/FullscreenElementStack.h"
 #include "core/rendering/RenderBlockFlow.h"
 
-using namespace WebCore;
+using namespace blink;
 
 class RenderFullScreenPlaceholder FINAL : public RenderBlockFlow {
 public:
@@ -52,7 +52,7 @@ void RenderFullScreenPlaceholder::willBeDestroyed()
 
 RenderFullScreen::RenderFullScreen()
     : RenderFlexibleBox(0)
-    , m_placeholder(0)
+    , m_placeholder(nullptr)
 {
     setReplaced(false);
 }
@@ -64,6 +64,12 @@ RenderFullScreen* RenderFullScreen::createAnonymous(Document* document)
     return renderer;
 }
 
+void RenderFullScreen::trace(Visitor* visitor)
+{
+    visitor->trace(m_placeholder);
+    RenderFlexibleBox::trace(visitor);
+}
+
 void RenderFullScreen::willBeDestroyed()
 {
     if (m_placeholder) {
@@ -74,10 +80,10 @@ void RenderFullScreen::willBeDestroyed()
     }
 
     // RenderObjects are unretained, so notify the document (which holds a pointer to a RenderFullScreen)
-    // if it's RenderFullScreen is destroyed.
-    FullscreenElementStack& controller = FullscreenElementStack::from(document());
-    if (controller.fullScreenRenderer() == this)
-        controller.fullScreenRendererDestroyed();
+    // if its RenderFullScreen is destroyed.
+    FullscreenElementStack& fullscreen = FullscreenElementStack::from(document());
+    if (fullscreen.fullScreenRenderer() == this)
+        fullscreen.fullScreenRendererDestroyed();
 
     RenderFlexibleBox::willBeDestroyed();
 }
@@ -100,8 +106,8 @@ static PassRefPtr<RenderStyle> createFullScreenStyle()
     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->setLeft(Length(0, blink::Fixed));
+    fullscreenStyle->setTop(Length(0, blink::Fixed));
 
     fullscreenStyle->setBackgroundColor(StyleColor(Color::black));
 
@@ -110,6 +116,10 @@ static PassRefPtr<RenderStyle> createFullScreenStyle()
 
 RenderObject* RenderFullScreen::wrapRenderer(RenderObject* object, RenderObject* parent, Document* document)
 {
+    // FIXME: We should not modify the structure of the render tree during
+    // layout. crbug.com/370459
+    DeprecatedDisableModifyRenderTreeStructureAsserts disabler;
+
     RenderFullScreen* fullscreenRenderer = RenderFullScreen::createAnonymous(document);
     fullscreenRenderer->setStyle(createFullScreenStyle());
     if (parent && !parent->isChildAllowed(fullscreenRenderer, fullscreenRenderer->style())) {
@@ -132,11 +142,11 @@ RenderObject* RenderFullScreen::wrapRenderer(RenderObject* object, RenderObject*
             // Always just do a full layout to ensure that line boxes get deleted properly.
             // Because objects moved from |parent| to |fullscreenRenderer|, we want to
             // make new line boxes instead of leaving the old ones around.
-            parent->setNeedsLayoutAndPrefWidthsRecalc();
-            containingBlock->setNeedsLayoutAndPrefWidthsRecalc();
+            parent->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation();
+            containingBlock->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation();
         }
         fullscreenRenderer->addChild(object);
-        fullscreenRenderer->setNeedsLayoutAndPrefWidthsRecalc();
+        fullscreenRenderer->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation();
     }
 
     ASSERT(document);
@@ -146,9 +156,12 @@ RenderObject* RenderFullScreen::wrapRenderer(RenderObject* object, RenderObject*
 
 void RenderFullScreen::unwrapRenderer()
 {
+    // FIXME: We should not modify the structure of the render tree during
+    // layout. crbug.com/370459
+    DeprecatedDisableModifyRenderTreeStructureAsserts disabler;
+
     if (parent()) {
-        RenderObject* child;
-        while ((child = firstChild())) {
+        for (RenderObject* child = firstChild(); child; child = firstChild()) {
             // 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.
@@ -156,13 +169,13 @@ void RenderFullScreen::unwrapRenderer()
                 toRenderBox(child)->clearOverrideSize();
             child->remove();
             parent()->addChild(child, this);
-            parent()->setNeedsLayoutAndPrefWidthsRecalc();
+            parent()->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation();
         }
     }
     if (placeholder())
         placeholder()->remove();
     remove();
-    FullscreenElementStack::from(document()).setFullScreenRenderer(0);
+    destroy();
 }
 
 void RenderFullScreen::setPlaceholder(RenderBlock* placeholder)
@@ -182,7 +195,7 @@ void RenderFullScreen::createPlaceholder(PassRefPtr<RenderStyle> style, const La
         m_placeholder->setStyle(style);
         if (parent()) {
             parent()->addChild(m_placeholder, this);
-            parent()->setNeedsLayoutAndPrefWidthsRecalc();
+            parent()->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation();
         }
     } else
         m_placeholder->setStyle(style);