[RenderTreeBuilder] Move RenderFullScreen::willBeRemoved() mutation logic to RenderTr...
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Feb 2018 08:25:39 +0000 (08:25 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Feb 2018 08:25:39 +0000 (08:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=182947
<rdar://problem/37690848>

Reviewed by Antti Koivisto.

No change in functionality.

* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* rendering/RenderFullScreen.cpp:
(WebCore::RenderFullScreen::willBeDestroyed):
* rendering/updating/RenderTreeBuilder.cpp:
(WebCore::RenderTreeBuilder::takeChild):
* rendering/updating/RenderTreeBuilder.h:
(WebCore::RenderTreeBuilder::fullScreenBuilder):
* rendering/updating/RenderTreeBuilderFullScreen.cpp: Added.
(WebCore::RenderTreeBuilder::FullScreen::FullScreen):
(WebCore::RenderTreeBuilder::FullScreen::cleanupOnRemoval):
* rendering/updating/RenderTreeBuilderFullScreen.h: Added.
* rendering/updating/RenderTreeBuilderMathML.cpp:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@228862 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/Sources.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/rendering/RenderFullScreen.cpp
Source/WebCore/rendering/RenderFullScreen.h
Source/WebCore/rendering/updating/RenderTreeBuilder.cpp
Source/WebCore/rendering/updating/RenderTreeBuilder.h
Source/WebCore/rendering/updating/RenderTreeBuilderFullScreen.cpp [new file with mode: 0644]
Source/WebCore/rendering/updating/RenderTreeBuilderFullScreen.h [new file with mode: 0644]
Source/WebCore/rendering/updating/RenderTreeBuilderMathML.cpp

index 791d271..a1fff89 100644 (file)
@@ -1,3 +1,27 @@
+2018-02-21  Zalan Bujtas  <zalan@apple.com>
+
+        [RenderTreeBuilder] Move RenderFullScreen::willBeRemoved() mutation logic to RenderTreeBuilder
+        https://bugs.webkit.org/show_bug.cgi?id=182947
+        <rdar://problem/37690848>
+
+        Reviewed by Antti Koivisto.
+
+        No change in functionality.
+
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * rendering/RenderFullScreen.cpp:
+        (WebCore::RenderFullScreen::willBeDestroyed):
+        * rendering/updating/RenderTreeBuilder.cpp:
+        (WebCore::RenderTreeBuilder::takeChild):
+        * rendering/updating/RenderTreeBuilder.h:
+        (WebCore::RenderTreeBuilder::fullScreenBuilder):
+        * rendering/updating/RenderTreeBuilderFullScreen.cpp: Added.
+        (WebCore::RenderTreeBuilder::FullScreen::FullScreen):
+        (WebCore::RenderTreeBuilder::FullScreen::cleanupOnRemoval):
+        * rendering/updating/RenderTreeBuilderFullScreen.h: Added.
+        * rendering/updating/RenderTreeBuilderMathML.cpp:
+
 2018-02-20  Zalan Bujtas  <zalan@apple.com>
 
         [RenderTreeBuilder] Move RenderListItem::willBeRemoved() mutation logic to RenderTreeBuilder
index 2383faa..8ce8025 100644 (file)
@@ -2015,6 +2015,7 @@ rendering/updating/RenderTreeBuilderBlock.cpp
 rendering/updating/RenderTreeBuilderBlockFlow.cpp
 rendering/updating/RenderTreeBuilderFirstLetter.cpp
 rendering/updating/RenderTreeBuilderFormControls.cpp
+rendering/updating/RenderTreeBuilderFullScreen.cpp
 rendering/updating/RenderTreeBuilderInline.cpp
 rendering/updating/RenderTreeBuilderList.cpp
 rendering/updating/RenderTreeBuilderMathML.cpp
index b1dc873..50a22b3 100644 (file)
                1193408A1FEB355D00935F1E /* RenderTreeBuilderRuby.h in Headers */ = {isa = PBXBuildFile; fileRef = 119340881FEB355D00935F1E /* RenderTreeBuilderRuby.h */; };
                119340971FED715500935F1E /* RenderTreeBuilderFormControls.h in Headers */ = {isa = PBXBuildFile; fileRef = 119340951FED715500935F1E /* RenderTreeBuilderFormControls.h */; };
                119340A31FEE024000935F1E /* RenderTreeBuilderBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = 119340A11FEE024000935F1E /* RenderTreeBuilderBlock.h */; };
+               11CB2789203BA570004A1DC9 /* RenderTreeBuilderFullScreen.h in Headers */ = {isa = PBXBuildFile; fileRef = 11CB2787203BA570004A1DC9 /* RenderTreeBuilderFullScreen.h */; };
                11E067EE1E6246E500162D16 /* SimpleLineLayoutCoverage.h in Headers */ = {isa = PBXBuildFile; fileRef = 11E067ED1E6246E500162D16 /* SimpleLineLayoutCoverage.h */; settings = {ATTRIBUTES = (Private, ); }; };
                1400D7A817136EA70077CE05 /* ScriptWrappableInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = 1400D7A717136EA70077CE05 /* ScriptWrappableInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
                1403B99709EB13AF00797C7F /* DOMWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = 1403B99509EB13AF00797C7F /* DOMWindow.h */; settings = {ATTRIBUTES = (Private, ); }; };
                11C5F12C2004231E0001AE60 /* RenderTreeBuilderSVG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTreeBuilderSVG.cpp; sourceTree = "<group>"; };
                11C5F132200527F80001AE60 /* RenderTreeBuilderMathML.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTreeBuilderMathML.cpp; sourceTree = "<group>"; };
                11C5F134200527F90001AE60 /* RenderTreeBuilderMathML.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderTreeBuilderMathML.h; sourceTree = "<group>"; };
+               11CB2786203BA570004A1DC9 /* RenderTreeBuilderFullScreen.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTreeBuilderFullScreen.cpp; sourceTree = "<group>"; };
+               11CB2787203BA570004A1DC9 /* RenderTreeBuilderFullScreen.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RenderTreeBuilderFullScreen.h; sourceTree = "<group>"; };
                11E067EB1E62461300162D16 /* SimpleLineLayoutCoverage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SimpleLineLayoutCoverage.cpp; sourceTree = "<group>"; };
                11E067ED1E6246E500162D16 /* SimpleLineLayoutCoverage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleLineLayoutCoverage.h; sourceTree = "<group>"; };
                1400D7A717136EA70077CE05 /* ScriptWrappableInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptWrappableInlines.h; sourceTree = "<group>"; };
                                E47C39261FE6E0DC00BBBC6B /* RenderTreeBuilderFirstLetter.h */,
                                119340941FED715500935F1E /* RenderTreeBuilderFormControls.cpp */,
                                119340951FED715500935F1E /* RenderTreeBuilderFormControls.h */,
+                               11CB2786203BA570004A1DC9 /* RenderTreeBuilderFullScreen.cpp */,
+                               11CB2787203BA570004A1DC9 /* RenderTreeBuilderFullScreen.h */,
                                11C5F1162003E7750001AE60 /* RenderTreeBuilderInline.cpp */,
                                11C5F1182003E7760001AE60 /* RenderTreeBuilderInline.h */,
                                E47C392B1FE6E0DF00BBBC6B /* RenderTreeBuilderList.cpp */,
                                119340A31FEE024000935F1E /* RenderTreeBuilderBlock.h in Headers */,
                                E47C39301FE6E0FD00BBBC6B /* RenderTreeBuilderFirstLetter.h in Headers */,
                                119340971FED715500935F1E /* RenderTreeBuilderFormControls.h in Headers */,
+                               11CB2789203BA570004A1DC9 /* RenderTreeBuilderFullScreen.h in Headers */,
                                E47C39321FE6E10500BBBC6B /* RenderTreeBuilderList.h in Headers */,
                                E47C39331FE6E10800BBBC6B /* RenderTreeBuilderMultiColumn.h in Headers */,
                                1193408A1FEB355D00935F1E /* RenderTreeBuilderRuby.h in Headers */,
index a3abb7e..5385fa8 100644 (file)
@@ -58,14 +58,9 @@ RenderFullScreen::RenderFullScreen(Document& document, RenderStyle&& style)
     setReplaced(false); 
 }
 
-void RenderFullScreen::willBeDestroyed(RenderTreeBuilder& builder)
+RenderFullScreen::~RenderFullScreen()
 {
-    if (m_placeholder) {
-        builder.removeAndDestroy(*m_placeholder);
-        ASSERT(!m_placeholder);
-    }
-
-    RenderFlexibleBox::willBeDestroyed(builder);
+    ASSERT(!m_placeholder);
 }
 
 static RenderStyle createFullScreenStyle()
index b36cfa4..3766974 100644 (file)
@@ -34,6 +34,7 @@ class RenderFullScreen final : public RenderFlexibleBox {
     WTF_MAKE_ISO_ALLOCATED(RenderFullScreen);
 public:
     RenderFullScreen(Document&, RenderStyle&&);
+    virtual ~RenderFullScreen();
 
     const char* renderName() const override { return "RenderFullScreen"; }
 
@@ -48,7 +49,6 @@ public:
     
 private:
     bool isRenderFullScreen() const override { return true; }
-    void willBeDestroyed(RenderTreeBuilder&) override;
     bool isFlexibleBoxImpl() const override { return true; }
 
 protected:
index b13dd5e..673b4bf 100644 (file)
@@ -32,6 +32,7 @@
 #include "RenderButton.h"
 #include "RenderCounter.h"
 #include "RenderElement.h"
+#include "RenderFullScreen.h"
 #include "RenderGrid.h"
 #include "RenderLineBreak.h"
 #include "RenderMathMLFenced.h"
@@ -51,6 +52,7 @@
 #include "RenderTreeBuilderBlockFlow.h"
 #include "RenderTreeBuilderFirstLetter.h"
 #include "RenderTreeBuilderFormControls.h"
+#include "RenderTreeBuilderFullScreen.h"
 #include "RenderTreeBuilderInline.h"
 #include "RenderTreeBuilderList.h"
 #include "RenderTreeBuilderMathML.h"
@@ -128,6 +130,9 @@ RenderTreeBuilder::RenderTreeBuilder(RenderView& view)
     , m_inlineBuilder(std::make_unique<Inline>(*this))
     , m_svgBuilder(std::make_unique<SVG>(*this))
     , m_mathMLBuilder(std::make_unique<MathML>(*this))
+#if ENABLE(FULLSCREEN_API)
+    , m_fullScreenBuilder(std::make_unique<FullScreen>(*this))
+#endif
 {
     RELEASE_ASSERT(!s_current || &m_view != &s_current->m_view);
     m_previous = s_current;
@@ -139,10 +144,16 @@ RenderTreeBuilder::~RenderTreeBuilder()
     s_current = m_previous;
 }
 
-void RenderTreeBuilder::removeAndDestroy(RenderObject& child)
+void RenderTreeBuilder::removeAndDestroy(RenderObject& renderer)
 {
-    ASSERT(child.parent());
-    auto toDestroy = takeChild(*child.parent(), child);
+    ASSERT(renderer.parent());
+    auto toDestroy = takeChild(*renderer.parent(), renderer);
+
+#if ENABLE(FULLSCREEN_API)
+    if (is<RenderFullScreen>(renderer))
+        fullScreenBuilder().cleanupOnDestroy(downcast<RenderFullScreen>(renderer));
+#endif
+
     // We need to detach the subtree first so that the descendants don't have
     // access to previous/next sublings at takeChild().
     // FIXME: webkit.org/b/182909.
index b8e4473..6bca18d 100644 (file)
@@ -91,6 +91,9 @@ private:
     class Inline;
     class SVG;
     class MathML;
+#if ENABLE(FULLSCREEN_API)
+    class FullScreen;
+#endif
 
     FirstLetter& firstLetterBuilder() { return *m_firstLetterBuilder; }
     List& listBuilder() { return *m_listBuilder; }
@@ -103,6 +106,9 @@ private:
     Inline& inlineBuilder() { return *m_inlineBuilder; }
     SVG& svgBuilder() { return *m_svgBuilder; }
     MathML& mathMLBuilder() { return *m_mathMLBuilder; }
+#if ENABLE(FULLSCREEN_API)
+    FullScreen& fullScreenBuilder() { return *m_fullScreenBuilder; }
+#endif
 
     RenderView& m_view;
     RenderTreeBuilder* m_previous { nullptr };
@@ -119,6 +125,9 @@ private:
     std::unique_ptr<Inline> m_inlineBuilder;
     std::unique_ptr<SVG> m_svgBuilder;
     std::unique_ptr<MathML> m_mathMLBuilder;
+#if ENABLE(FULLSCREEN_API)
+    std::unique_ptr<FullScreen> m_fullScreenBuilder;
+#endif
 };
 
 }
diff --git a/Source/WebCore/rendering/updating/RenderTreeBuilderFullScreen.cpp b/Source/WebCore/rendering/updating/RenderTreeBuilderFullScreen.cpp
new file mode 100644 (file)
index 0000000..cbc59ac
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(FULLSCREEN_API)
+#include "RenderTreeBuilderFullScreen.h"
+
+#include "RenderFullScreen.h"
+
+namespace WebCore {
+
+RenderTreeBuilder::FullScreen::FullScreen(RenderTreeBuilder& builder)
+    : m_builder(builder)
+{
+}
+
+void RenderTreeBuilder::FullScreen::cleanupOnDestroy(RenderFullScreen& fullScreenRenderer)
+{
+    if (!fullScreenRenderer.placeholder())
+        return;
+    m_builder.removeAndDestroy(*fullScreenRenderer.placeholder());
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/rendering/updating/RenderTreeBuilderFullScreen.h b/Source/WebCore/rendering/updating/RenderTreeBuilderFullScreen.h
new file mode 100644 (file)
index 0000000..f5c4acb
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(FULLSCREEN_API)
+
+#include "RenderTreeBuilder.h"
+
+namespace WebCore {
+
+class RenderElement;
+class RenderFullScreen;
+
+class RenderTreeBuilder::FullScreen {
+public:
+    FullScreen(RenderTreeBuilder&);
+
+    void cleanupOnDestroy(RenderFullScreen&);
+
+private:
+    RenderTreeBuilder& m_builder;
+};
+
+}
+
+#endif // ENABLE(FULLSCREEN_API)
index 1ca4e39..edd2be2 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "RenderMathMLFenced.h"
 #include "RenderMathMLFencedOperator.h"
+#include "RenderTreeBuilderBlock.h"
 
 namespace WebCore {