Diff
Modified: trunk/Source/WebCore/ChangeLog (226220 => 226221)
--- trunk/Source/WebCore/ChangeLog 2017-12-21 14:51:49 UTC (rev 226220)
+++ trunk/Source/WebCore/ChangeLog 2017-12-21 15:13:26 UTC (rev 226221)
@@ -1,3 +1,27 @@
+2017-12-21 Zalan Bujtas <za...@apple.com>
+
+ [RenderTreeBuilder] Move ruby mutation code to a dedicated class.
+ https://bugs.webkit.org/show_bug.cgi?id=181066
+ <rdar://problem/36167692>
+
+ Reviewed by Antti Koivisto.
+
+ This is in preparation for moving all ruby mutation code here.
+
+ No change in functionality.
+
+ * Sources.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * rendering/updating/RenderTreeBuilder.cpp:
+ (WebCore::RenderTreeBuilder::insertChild):
+ (WebCore::RenderTreeBuilder::rubyRunInsertChild): Deleted.
+ * rendering/updating/RenderTreeBuilder.h:
+ (WebCore::RenderTreeBuilder::rubyBuilder):
+ * rendering/updating/RenderTreeBuilderRuby.cpp: Added.
+ (WebCore::RenderTreeBuilder::Ruby::Ruby):
+ (WebCore::RenderTreeBuilder::Ruby::insertChild):
+ * rendering/updating/RenderTreeBuilderRuby.h: Copied from Source/WebCore/rendering/updating/RenderTreeBuilder.h.
+
2017-12-21 Ms2ger <ms2...@igalia.com>
Replace a FIXME comment in CanvasGradient::addColorStop().
Modified: trunk/Source/WebCore/Sources.txt (226220 => 226221)
--- trunk/Source/WebCore/Sources.txt 2017-12-21 14:51:49 UTC (rev 226220)
+++ trunk/Source/WebCore/Sources.txt 2017-12-21 15:13:26 UTC (rev 226221)
@@ -1983,6 +1983,7 @@
rendering/updating/RenderTreeBuilderFirstLetter.cpp
rendering/updating/RenderTreeBuilderList.cpp
rendering/updating/RenderTreeBuilderMultiColumn.cpp
+rendering/updating/RenderTreeBuilderRuby.cpp
rendering/updating/RenderTreeBuilderTable.cpp
rendering/updating/RenderTreePosition.cpp
rendering/updating/RenderTreeUpdater.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (226220 => 226221)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-12-21 14:51:49 UTC (rev 226220)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-12-21 15:13:26 UTC (rev 226221)
@@ -391,6 +391,7 @@
112B34D51E60B98300BB310A /* SimpleLineLayoutPagination.h in Headers */ = {isa = PBXBuildFile; fileRef = 112B34D41E60B98300BB310A /* SimpleLineLayoutPagination.h */; };
113D0B521F9FDD2B00F611BB /* LayoutContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 113D0B501F9FDD2B00F611BB /* LayoutContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
119340791FE8B92300935F1E /* RenderTreeBuilderTable.h in Headers */ = {isa = PBXBuildFile; fileRef = 119340771FE8B92300935F1E /* RenderTreeBuilderTable.h */; };
+ 1193408A1FEB355D00935F1E /* RenderTreeBuilderRuby.h in Headers */ = {isa = PBXBuildFile; fileRef = 119340881FEB355D00935F1E /* RenderTreeBuilderRuby.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, ); }; };
@@ -5567,6 +5568,8 @@
113D0B501F9FDD2B00F611BB /* LayoutContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LayoutContext.h; sourceTree = "<group>"; };
119340761FE8B92300935F1E /* RenderTreeBuilderTable.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTreeBuilderTable.cpp; sourceTree = "<group>"; };
119340771FE8B92300935F1E /* RenderTreeBuilderTable.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RenderTreeBuilderTable.h; sourceTree = "<group>"; };
+ 119340871FEB355D00935F1E /* RenderTreeBuilderRuby.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTreeBuilderRuby.cpp; sourceTree = "<group>"; };
+ 119340881FEB355D00935F1E /* RenderTreeBuilderRuby.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RenderTreeBuilderRuby.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>"; };
@@ -24505,6 +24508,8 @@
E47C39281FE6E0DD00BBBC6B /* RenderTreeBuilderList.h */,
E47C39231FE6E0DA00BBBC6B /* RenderTreeBuilderMultiColumn.cpp */,
E47C39271FE6E0DC00BBBC6B /* RenderTreeBuilderMultiColumn.h */,
+ 119340871FEB355D00935F1E /* RenderTreeBuilderRuby.cpp */,
+ 119340881FEB355D00935F1E /* RenderTreeBuilderRuby.h */,
119340761FE8B92300935F1E /* RenderTreeBuilderTable.cpp */,
119340771FE8B92300935F1E /* RenderTreeBuilderTable.h */,
E47C39291FE6E0DE00BBBC6B /* RenderTreePosition.cpp */,
@@ -27226,7 +27231,6 @@
977B3878122883E900B81FF8 /* HTMLTokenizer.h in Headers */,
0707568C142262D600414161 /* HTMLTrackElement.h in Headers */,
977B37261228721700B81FF8 /* HTMLTreeBuilder.h in Headers */,
- E47C39301FE6E0FD00BBBC6B /* RenderTreeBuilderFirstLetter.h in Headers */,
A8EA79F20A1916DF00A8EF5F /* HTMLUListElement.h in Headers */,
AD49914318F0815100BF0092 /* HTMLUnknownElement.h in Headers */,
E44613AB0CD6331000FADA75 /* HTMLVideoElement.h in Headers */,
@@ -28914,12 +28918,14 @@
BCEA4887097D93020094C9E4 /* RenderThemeMac.h in Headers */,
93F1998C08245E59001E9ABC /* RenderTreeAsText.h in Headers */,
E47C392D1FE6E0F300BBBC6B /* RenderTreeBuilder.h in Headers */,
+ E47C39301FE6E0FD00BBBC6B /* RenderTreeBuilderFirstLetter.h in Headers */,
+ E47C39321FE6E10500BBBC6B /* RenderTreeBuilderList.h in Headers */,
+ E47C39331FE6E10800BBBC6B /* RenderTreeBuilderMultiColumn.h in Headers */,
+ 1193408A1FEB355D00935F1E /* RenderTreeBuilderRuby.h in Headers */,
119340791FE8B92300935F1E /* RenderTreeBuilderTable.h in Headers */,
E47C392E1FE6E0F700BBBC6B /* RenderTreePosition.h in Headers */,
E47C392F1FE6E0F900BBBC6B /* RenderTreeUpdater.h in Headers */,
E47C39311FE6E10200BBBC6B /* RenderTreeUpdaterGeneratedContent.h in Headers */,
- E47C39321FE6E10500BBBC6B /* RenderTreeBuilderList.h in Headers */,
- E47C39331FE6E10800BBBC6B /* RenderTreeBuilderMultiColumn.h in Headers */,
E44614520CD68A3500FADA75 /* RenderVideo.h in Headers */,
BCEA4868097D93020094C9E4 /* RenderView.h in Headers */,
BE20507E18A458C20080647E /* RenderVTTCue.h in Headers */,
Modified: trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp (226220 => 226221)
--- trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp 2017-12-21 14:51:49 UTC (rev 226220)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp 2017-12-21 15:13:26 UTC (rev 226221)
@@ -35,6 +35,7 @@
#include "RenderTreeBuilderFirstLetter.h"
#include "RenderTreeBuilderList.h"
#include "RenderTreeBuilderMultiColumn.h"
+#include "RenderTreeBuilderRuby.h"
#include "RenderTreeBuilderTable.h"
namespace WebCore {
@@ -47,6 +48,7 @@
, m_listBuilder(std::make_unique<List>(*this))
, m_multiColumnBuilder(std::make_unique<MultiColumn>(*this))
, m_tableBuilder(std::make_unique<Table>(*this))
+ , m_rubyBuilder(std::make_unique<Ruby>(*this))
{
RELEASE_ASSERT(!s_current || &m_view != &s_current->m_view);
m_previous = s_current;
@@ -98,7 +100,7 @@
}
if (is<RenderRubyRun>(parent)) {
- rubyRunInsertChild(downcast<RenderRubyRun>(parent), WTFMove(child), beforeChild);
+ rubyBuilder().insertChild(downcast<RenderRubyRun>(parent), WTFMove(child), beforeChild);
return;
}
@@ -120,51 +122,4 @@
multiColumnBuilder().updateAfterDescendants(downcast<RenderBlockFlow>(renderer));
}
-void RenderTreeBuilder::rubyRunInsertChild(RenderRubyRun& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild)
-{
- if (child->isRubyText()) {
- if (!beforeChild) {
- // RenderRuby has already ascertained that we can add the child here.
- ASSERT(!parent.hasRubyText());
- // prepend ruby texts as first child
- parent.addChild(*this, WTFMove(child), parent.firstChild());
- return;
- }
- if (beforeChild->isRubyText()) {
- // New text is inserted just before another.
- // In this case the new text takes the place of the old one, and
- // the old text goes into a new run that is inserted as next sibling.
- ASSERT(beforeChild->parent() == &parent);
- RenderElement* ruby = parent.parent();
- ASSERT(isRuby(ruby));
- auto newRun = RenderRubyRun::staticCreateRubyRun(ruby);
- insertChild(*ruby, WTFMove(newRun), parent.nextSibling());
- // Add the new ruby text and move the old one to the new run
- // Note: Doing it in this order and not using RenderRubyRun's methods,
- // in order to avoid automatic removal of the ruby run in case there is no
- // other child besides the old ruby text.
- parent.addChild(*this, WTFMove(child), beforeChild);
- auto takenBeforeChild = parent.RenderBlockFlow::takeChild(*beforeChild);
- insertChild(*newRun, WTFMove(takenBeforeChild));
- return;
- }
- if (parent.hasRubyBase()) {
- // Insertion before a ruby base object.
- // In this case we need insert a new run before the current one and split the base.
- RenderElement* ruby = parent.parent();
- auto newRun = RenderRubyRun::staticCreateRubyRun(ruby);
- auto& run = *newRun;
- insertChild(*ruby, WTFMove(newRun), &parent);
- insertChild(run, WTFMove(child));
- parent.rubyBaseSafe()->moveChildren(run.rubyBaseSafe(), beforeChild);
- }
- return;
- }
- // child is not a text -> insert it into the base
- // (append it instead if beforeChild is the ruby text)
- if (beforeChild && beforeChild->isRubyText())
- beforeChild = nullptr;
- insertChild(*parent.rubyBaseSafe(), WTFMove(child), beforeChild);
}
-
-}
Modified: trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.h (226220 => 226221)
--- trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.h 2017-12-21 14:51:49 UTC (rev 226220)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.h 2017-12-21 15:13:26 UTC (rev 226221)
@@ -51,13 +51,13 @@
class List;
class MultiColumn;
class Table;
+ class Ruby;
- void rubyRunInsertChild(RenderRubyRun&, RenderPtr<RenderObject> child, RenderObject* beforeChild);
-
FirstLetter& firstLetterBuilder() { return *m_firstLetterBuilder; }
List& listBuilder() { return *m_listBuilder; }
MultiColumn& multiColumnBuilder() { return *m_multiColumnBuilder; }
Table& tableBuilder() { return *m_tableBuilder; }
+ Ruby& rubyBuilder() { return *m_rubyBuilder; }
RenderView& m_view;
@@ -68,6 +68,8 @@
std::unique_ptr<List> m_listBuilder;
std::unique_ptr<MultiColumn> m_multiColumnBuilder;
std::unique_ptr<Table> m_tableBuilder;
+ std::unique_ptr<Ruby> m_rubyBuilder;
};
}
+
Added: trunk/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.cpp (0 => 226221)
--- trunk/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.cpp (rev 0)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.cpp 2017-12-21 15:13:26 UTC (rev 226221)
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2017 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"
+#include "RenderTreeBuilderRuby.h"
+
+#include "RenderTreeBuilder.h"
+
+namespace WebCore {
+
+RenderTreeBuilder::Ruby::Ruby(RenderTreeBuilder& builder)
+ : m_builder(builder)
+{
+}
+
+void RenderTreeBuilder::Ruby::insertChild(RenderRubyRun& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild)
+{
+ if (child->isRubyText()) {
+ if (!beforeChild) {
+ // RenderRuby has already ascertained that we can add the child here.
+ ASSERT(!parent.hasRubyText());
+ // prepend ruby texts as first child
+ parent.addChild(m_builder, WTFMove(child), parent.firstChild());
+ return;
+ }
+ if (beforeChild->isRubyText()) {
+ // New text is inserted just before another.
+ // In this case the new text takes the place of the old one, and
+ // the old text goes into a new run that is inserted as next sibling.
+ ASSERT(beforeChild->parent() == &parent);
+ RenderElement* ruby = parent.parent();
+ ASSERT(isRuby(ruby));
+ auto newRun = RenderRubyRun::staticCreateRubyRun(ruby);
+ m_builder.insertChild(*ruby, WTFMove(newRun), parent.nextSibling());
+ // Add the new ruby text and move the old one to the new run
+ // Note: Doing it in this order and not using RenderRubyRun's methods,
+ // in order to avoid automatic removal of the ruby run in case there is no
+ // other child besides the old ruby text.
+ parent.addChild(m_builder, WTFMove(child), beforeChild);
+ auto takenBeforeChild = parent.RenderBlockFlow::takeChild(*beforeChild);
+ m_builder.insertChild(*newRun, WTFMove(takenBeforeChild));
+ return;
+ }
+ if (parent.hasRubyBase()) {
+ // Insertion before a ruby base object.
+ // In this case we need insert a new run before the current one and split the base.
+ RenderElement* ruby = parent.parent();
+ auto newRun = RenderRubyRun::staticCreateRubyRun(ruby);
+ auto& run = *newRun;
+ m_builder.insertChild(*ruby, WTFMove(newRun), &parent);
+ m_builder.insertChild(run, WTFMove(child));
+ parent.rubyBaseSafe()->moveChildren(run.rubyBaseSafe(), beforeChild);
+ }
+ return;
+ }
+ // child is not a text -> insert it into the base
+ // (append it instead if beforeChild is the ruby text)
+ if (beforeChild && beforeChild->isRubyText())
+ beforeChild = nullptr;
+ m_builder.insertChild(*parent.rubyBaseSafe(), WTFMove(child), beforeChild);
+}
+
+}
+
Copied: trunk/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.h (from rev 226220, trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.h) (0 => 226221)
--- trunk/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.h (rev 0)
+++ trunk/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.h 2017-12-21 15:13:26 UTC (rev 226221)
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2017 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
+
+#include "RenderTreeUpdater.h"
+
+namespace WebCore {
+
+class RenderObject;
+class RenderRubyRun;
+class RenderTreeBuilder;
+
+class RenderTreeBuilder::Ruby {
+public:
+ Ruby(RenderTreeBuilder&);
+
+ void insertChild(RenderRubyRun& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild);
+
+private:
+ RenderTreeBuilder& m_builder;
+};
+
+}
+