Title: [228949] trunk/Source/WebCore
Revision
228949
Author
za...@apple.com
Date
2018-02-23 08:16:27 -0800 (Fri, 23 Feb 2018)

Log Message

[RenderTreeBuilder] Move RenderFullScreen::createPlaceholder to RenderTreeBuilder
https://bugs.webkit.org/show_bug.cgi?id=183027
<rdar://problem/37773058>

Reviewed by Antti Koivisto.

No change in functionality.

* dom/Document.cpp:
(WebCore::Document::setFullScreenRenderer):
* dom/Document.h:
* rendering/RenderFullScreen.cpp:
(WebCore::RenderFullScreenPlaceholder::RenderFullScreenPlaceholder):
(WebCore::RenderFullScreenPlaceholder::isRenderFullScreenPlaceholder const):
(WebCore::RenderFullScreen::wrapNewRenderer):
(WebCore::RenderFullScreen::wrapExistingRenderer):
(): Deleted.
(WebCore::RenderFullScreen::createPlaceholder): Deleted.
* rendering/RenderFullScreen.h:
* rendering/updating/RenderTreeBuilder.cpp:
(WebCore::RenderTreeBuilder::createPlaceholderForFullScreen):
* rendering/updating/RenderTreeBuilder.h:
* rendering/updating/RenderTreeBuilderFullScreen.cpp:
(WebCore::RenderTreeBuilder::FullScreen::createPlaceholder):
* rendering/updating/RenderTreeBuilderFullScreen.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (228948 => 228949)


--- trunk/Source/WebCore/ChangeLog	2018-02-23 14:52:45 UTC (rev 228948)
+++ trunk/Source/WebCore/ChangeLog	2018-02-23 16:16:27 UTC (rev 228949)
@@ -1,5 +1,33 @@
 2018-02-23  Zalan Bujtas  <za...@apple.com>
 
+        [RenderTreeBuilder] Move RenderFullScreen::createPlaceholder to RenderTreeBuilder
+        https://bugs.webkit.org/show_bug.cgi?id=183027
+        <rdar://problem/37773058>
+
+        Reviewed by Antti Koivisto.
+
+        No change in functionality.
+
+        * dom/Document.cpp:
+        (WebCore::Document::setFullScreenRenderer):
+        * dom/Document.h:
+        * rendering/RenderFullScreen.cpp:
+        (WebCore::RenderFullScreenPlaceholder::RenderFullScreenPlaceholder):
+        (WebCore::RenderFullScreenPlaceholder::isRenderFullScreenPlaceholder const):
+        (WebCore::RenderFullScreen::wrapNewRenderer):
+        (WebCore::RenderFullScreen::wrapExistingRenderer):
+        (): Deleted.
+        (WebCore::RenderFullScreen::createPlaceholder): Deleted.
+        * rendering/RenderFullScreen.h:
+        * rendering/updating/RenderTreeBuilder.cpp:
+        (WebCore::RenderTreeBuilder::createPlaceholderForFullScreen):
+        * rendering/updating/RenderTreeBuilder.h:
+        * rendering/updating/RenderTreeBuilderFullScreen.cpp:
+        (WebCore::RenderTreeBuilder::FullScreen::createPlaceholder):
+        * rendering/updating/RenderTreeBuilderFullScreen.h:
+
+2018-02-23  Zalan Bujtas  <za...@apple.com>
+
         [RenderTreeBuilder] Add WARN_UNUSED_RETURN to detach()
         https://bugs.webkit.org/show_bug.cgi?id=183073
         <rdar://problem/37814585>

Modified: trunk/Source/WebCore/dom/Document.cpp (228948 => 228949)


--- trunk/Source/WebCore/dom/Document.cpp	2018-02-23 14:52:45 UTC (rev 228948)
+++ trunk/Source/WebCore/dom/Document.cpp	2018-02-23 16:16:27 UTC (rev 228949)
@@ -6306,18 +6306,16 @@
     exitingDocument.m_fullScreenChangeDelayTimer.startOneShot(0_s);
 }
 
-void Document::setFullScreenRenderer(RenderTreeBuilder& builder, RenderFullScreen* renderer)
+void Document::setFullScreenRenderer(RenderTreeBuilder& builder, RenderFullScreen& renderer)
 {
-    if (renderer == m_fullScreenRenderer)
+    if (&renderer == m_fullScreenRenderer)
         return;
 
-    if (renderer) {
-        if (m_savedPlaceholderRenderStyle)
-            renderer->createPlaceholder(WTFMove(m_savedPlaceholderRenderStyle), m_savedPlaceholderFrameRect);
-        else if (m_fullScreenRenderer && m_fullScreenRenderer->placeholder()) {
-            auto* placeholder = m_fullScreenRenderer->placeholder();
-            renderer->createPlaceholder(RenderStyle::clonePtr(placeholder->style()), placeholder->frameRect());
-        }
+    if (m_savedPlaceholderRenderStyle)
+        builder.createPlaceholderForFullScreen(renderer, WTFMove(m_savedPlaceholderRenderStyle), m_savedPlaceholderFrameRect);
+    else if (m_fullScreenRenderer && m_fullScreenRenderer->placeholder()) {
+        auto* placeholder = m_fullScreenRenderer->placeholder();
+        builder.createPlaceholderForFullScreen(renderer, RenderStyle::clonePtr(placeholder->style()), placeholder->frameRect());
     }
 
     if (m_fullScreenRenderer)

Modified: trunk/Source/WebCore/dom/Document.h (228948 => 228949)


--- trunk/Source/WebCore/dom/Document.h	2018-02-23 14:52:45 UTC (rev 228948)
+++ trunk/Source/WebCore/dom/Document.h	2018-02-23 16:16:27 UTC (rev 228949)
@@ -1131,7 +1131,7 @@
     WEBCORE_EXPORT void webkitWillExitFullScreenForElement(Element*);
     WEBCORE_EXPORT void webkitDidExitFullScreenForElement(Element*);
     
-    void setFullScreenRenderer(RenderTreeBuilder&, RenderFullScreen*);
+    void setFullScreenRenderer(RenderTreeBuilder&, RenderFullScreen&);
     RenderFullScreen* fullScreenRenderer() const { return m_fullScreenRenderer.get(); }
 
     void fullScreenChangeDelayTimerFired();

Modified: trunk/Source/WebCore/rendering/RenderFullScreen.cpp (228948 => 228949)


--- trunk/Source/WebCore/rendering/RenderFullScreen.cpp	2018-02-23 14:52:45 UTC (rev 228948)
+++ trunk/Source/WebCore/rendering/RenderFullScreen.cpp	2018-02-23 16:16:27 UTC (rev 228949)
@@ -38,17 +38,15 @@
 
 WTF_MAKE_ISO_ALLOCATED_IMPL(RenderFullScreen);
 
-class RenderFullScreenPlaceholder final : public RenderBlockFlow {
-    WTF_MAKE_ISO_ALLOCATED(RenderFullScreenPlaceholder);
-public:
-    RenderFullScreenPlaceholder(Document& document, RenderStyle&& style)
-        : RenderBlockFlow(document, WTFMove(style))
-    {
-    }
+RenderFullScreenPlaceholder::RenderFullScreenPlaceholder(Document& document, RenderStyle&& style)
+    : RenderBlockFlow(document, WTFMove(style))
+{
+}
 
-private:
-    bool isRenderFullScreenPlaceholder() const override { return true; }
-};
+bool RenderFullScreenPlaceholder::isRenderFullScreenPlaceholder() const
+{
+    return true;
+}
 
 WTF_MAKE_ISO_ALLOCATED_IMPL(RenderFullScreenPlaceholder);
 
@@ -101,7 +99,7 @@
     builder.attach(fullscreenRenderer, WTFMove(renderer));
     fullscreenRenderer.setNeedsLayoutAndPrefWidthsRecalc();
 
-    document.setFullScreenRenderer(builder, &fullscreenRenderer);
+    document.setFullScreenRenderer(builder, fullscreenRenderer);
 
     return newFullscreenRenderer;
 }
@@ -138,7 +136,7 @@
     builder.attach(fullscreenRenderer, WTFMove(toMove));
     fullscreenRenderer.setNeedsLayoutAndPrefWidthsRecalc();
 
-    document.setFullScreenRenderer(builder, &fullscreenRenderer);
+    document.setFullScreenRenderer(builder, fullscreenRenderer);
 }
 
 void RenderFullScreen::unwrapRenderer(bool& requiresRenderTreeRebuild)
@@ -185,30 +183,6 @@
     builder.destroy(*this);
 }
 
-void RenderFullScreen::createPlaceholder(std::unique_ptr<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->setStyle(WTFMove(*style));
-        return;
-    }
-
-    if (!parent())
-        return;
-
-    auto newPlaceholder = createRenderer<RenderFullScreenPlaceholder>(document(), WTFMove(*style));
-    newPlaceholder->initializeStyle();
-
-    m_placeholder = makeWeakPtr(*newPlaceholder);
-
-    RenderTreeBuilder::current()->attach(*parent(), WTFMove(newPlaceholder), this);
-    parent()->setNeedsLayoutAndPrefWidthsRecalc();
 }
 
-}
-
 #endif

Modified: trunk/Source/WebCore/rendering/RenderFullScreen.h (228948 => 228949)


--- trunk/Source/WebCore/rendering/RenderFullScreen.h	2018-02-23 14:52:45 UTC (rev 228948)
+++ trunk/Source/WebCore/rendering/RenderFullScreen.h	2018-02-23 16:16:27 UTC (rev 228949)
@@ -26,6 +26,7 @@
 
 #if ENABLE(FULLSCREEN_API)
 
+#include "RenderBlockFlow.h"
 #include "RenderFlexibleBox.h"
 
 namespace WebCore {
@@ -39,7 +40,7 @@
     const char* renderName() const override { return "RenderFullScreen"; }
 
     RenderBlock* placeholder() { return m_placeholder.get(); }
-    void createPlaceholder(std::unique_ptr<RenderStyle>, const LayoutRect& frameRect);
+    void setPlaceholder(RenderBlock& placeholder) { m_placeholder = makeWeakPtr(placeholder); }
 
     static RenderPtr<RenderFullScreen> wrapNewRenderer(RenderTreeBuilder&, RenderPtr<RenderElement>, RenderElement& parent, Document&);
     static void wrapExistingRenderer(RenderElement&, Document&);
@@ -55,6 +56,15 @@
     WeakPtr<RenderBlock> m_placeholder;
 };
 
+class RenderFullScreenPlaceholder final : public RenderBlockFlow {
+    WTF_MAKE_ISO_ALLOCATED(RenderFullScreenPlaceholder);
+public:
+    RenderFullScreenPlaceholder(Document&, RenderStyle&&);
+
+private:
+    bool isRenderFullScreenPlaceholder() const override;
+};
+
 } // namespace WebCore
 
 SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderFullScreen, isRenderFullScreen())

Modified: trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp (228948 => 228949)


--- trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp	2018-02-23 14:52:45 UTC (rev 228948)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp	2018-02-23 16:16:27 UTC (rev 228949)
@@ -358,6 +358,13 @@
     attach(position.parent(), WTFMove(child), position.nextSibling());
 }
 
+#if ENABLE(FULLSCREEN_API)
+void RenderTreeBuilder::createPlaceholderForFullScreen(RenderFullScreen& renderer, std::unique_ptr<RenderStyle> style, const LayoutRect& frameRect)
+{
+    fullScreenBuilder().createPlaceholder(renderer, WTFMove(style), frameRect);
+}
+#endif
+
 void RenderTreeBuilder::attachToRenderElement(RenderElement& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild)
 {
     if (tableBuilder().childRequiresTable(parent, *child)) {

Modified: trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.h (228948 => 228949)


--- trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.h	2018-02-23 14:52:45 UTC (rev 228948)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.h	2018-02-23 16:16:27 UTC (rev 228949)
@@ -55,6 +55,10 @@
     void updateAfterDescendants(RenderElement&);
     void destroyAndCleanUpAnonymousWrappers(RenderObject& child);
 
+#if ENABLE(FULLSCREEN_API)
+    void createPlaceholderForFullScreen(RenderFullScreen&, std::unique_ptr<RenderStyle>, const LayoutRect&);
+#endif
+
     void childFlowStateChangesAndAffectsParentBlock(RenderElement& child);
     void childFlowStateChangesAndNoLongerAffectsParentBlock(RenderElement& child);
 

Modified: trunk/Source/WebCore/rendering/updating/RenderTreeBuilderFullScreen.cpp (228948 => 228949)


--- trunk/Source/WebCore/rendering/updating/RenderTreeBuilderFullScreen.cpp	2018-02-23 14:52:45 UTC (rev 228948)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeBuilderFullScreen.cpp	2018-02-23 16:16:27 UTC (rev 228949)
@@ -37,6 +37,30 @@
 {
 }
 
+void RenderTreeBuilder::FullScreen::createPlaceholder(RenderFullScreen& renderer, std::unique_ptr<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 (auto* placeHolder = renderer.placeholder()) {
+        placeHolder->setStyle(WTFMove(*style));
+        return;
+    }
+
+    if (!renderer.parent())
+        return;
+
+    auto newPlaceholder = createRenderer<RenderFullScreenPlaceholder>(renderer.document(), WTFMove(*style));
+    newPlaceholder->initializeStyle();
+
+    renderer.setPlaceholder(*newPlaceholder);
+
+    m_builder.attach(*renderer.parent(), WTFMove(newPlaceholder), &renderer);
+    renderer.parent()->setNeedsLayoutAndPrefWidthsRecalc();
+}
+
 void RenderTreeBuilder::FullScreen::cleanupOnDestroy(RenderFullScreen& fullScreenRenderer)
 {
     if (!fullScreenRenderer.placeholder())

Modified: trunk/Source/WebCore/rendering/updating/RenderTreeBuilderFullScreen.h (228948 => 228949)


--- trunk/Source/WebCore/rendering/updating/RenderTreeBuilderFullScreen.h	2018-02-23 14:52:45 UTC (rev 228948)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeBuilderFullScreen.h	2018-02-23 16:16:27 UTC (rev 228949)
@@ -38,6 +38,7 @@
 public:
     FullScreen(RenderTreeBuilder&);
 
+    void createPlaceholder(RenderFullScreen&, std::unique_ptr<RenderStyle>, const LayoutRect&);
     void cleanupOnDestroy(RenderFullScreen&);
 
 private:
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to