Diff
Modified: branches/safari-605-branch/Source/WebCore/ChangeLog (226828 => 226829)
--- branches/safari-605-branch/Source/WebCore/ChangeLog 2018-01-12 01:50:33 UTC (rev 226828)
+++ branches/safari-605-branch/Source/WebCore/ChangeLog 2018-01-12 01:50:35 UTC (rev 226829)
@@ -1,5 +1,9 @@
2018-01-11 Jason Marcell <[email protected]>
+ Revert r226246. rdar://problem/36184788
+
+2018-01-11 Jason Marcell <[email protected]>
+
Revert r226265. rdar://problem/36188262
2018-01-11 Jason Marcell <[email protected]>
Modified: branches/safari-605-branch/Source/WebCore/rendering/RenderRuby.cpp (226828 => 226829)
--- branches/safari-605-branch/Source/WebCore/rendering/RenderRuby.cpp 2018-01-12 01:50:33 UTC (rev 226828)
+++ branches/safari-605-branch/Source/WebCore/rendering/RenderRuby.cpp 2018-01-12 01:50:35 UTC (rev 226829)
@@ -61,6 +61,22 @@
&& !is<RenderRubyRun>(*object);
}
+static inline bool isRubyBeforeBlock(const RenderObject* object)
+{
+ return isAnonymousRubyInlineBlock(object)
+ && !object->previousSibling()
+ && downcast<RenderBlock>(*object).firstChild()
+ && downcast<RenderBlock>(*object).firstChild()->style().styleType() == BEFORE;
+}
+
+static inline bool isRubyAfterBlock(const RenderObject* object)
+{
+ return isAnonymousRubyInlineBlock(object)
+ && !object->nextSibling()
+ && downcast<RenderBlock>(*object).firstChild()
+ && downcast<RenderBlock>(*object).firstChild()->style().styleType() == AFTER;
+}
+
#ifndef ASSERT_DISABLED
static inline bool isRubyChildForNormalRemoval(const RenderObject& object)
{
@@ -73,6 +89,37 @@
}
#endif
+static inline RenderBlock* rubyBeforeBlock(const RenderElement* ruby)
+{
+ RenderObject* child = ruby->firstChild();
+ return isRubyBeforeBlock(child) ? downcast<RenderBlock>(child) : nullptr;
+}
+
+static inline RenderBlock* rubyAfterBlock(const RenderElement* ruby)
+{
+ RenderObject* child = ruby->lastChild();
+ return isRubyAfterBlock(child) ? downcast<RenderBlock>(child) : nullptr;
+}
+
+static auto createAnonymousRubyInlineBlock(RenderObject& ruby)
+{
+ auto newBlock = createRenderer<RenderBlockFlow>(ruby.document(), RenderStyle::createAnonymousStyleWithDisplay(ruby.style(), INLINE_BLOCK));
+ newBlock->initializeStyle();
+ return newBlock;
+}
+
+static RenderRubyRun* lastRubyRun(const RenderElement* ruby)
+{
+ RenderObject* child = ruby->lastChild();
+ if (child && !is<RenderRubyRun>(*child))
+ child = child->previousSibling();
+ if (!is<RenderRubyRun>(child)) {
+ ASSERT(!child || child->isBeforeContent() || child == rubyBeforeBlock(ruby));
+ return nullptr;
+ }
+ return downcast<RenderRubyRun>(child);
+}
+
static inline RenderRubyRun& findRubyRunParent(RenderObject& child)
{
return *lineageOfType<RenderRubyRun>(child).first();
@@ -93,6 +140,74 @@
propagateStyleToAnonymousChildren(PropagateToAllChildren);
}
+void RenderRubyAsInline::addChild(RenderTreeBuilder& builder, RenderPtr<RenderObject> child, RenderObject* beforeChild)
+{
+ // Insert :before and :after content before/after the RenderRubyRun(s)
+ if (child->isBeforeContent()) {
+ if (child->isInline()) {
+ // Add generated inline content normally
+ RenderInline::addChild(builder, WTFMove(child), firstChild());
+ } else {
+ // Wrap non-inline content with an anonymous inline-block.
+ RenderBlock* beforeBlock = rubyBeforeBlock(this);
+ if (!beforeBlock) {
+ auto newBlock = createAnonymousRubyInlineBlock(*this);
+ beforeBlock = newBlock.get();
+ RenderInline::addChild(builder, WTFMove(newBlock), firstChild());
+ }
+ builder.insertChild(*beforeBlock, WTFMove(child));
+ }
+ return;
+ }
+ if (child->isAfterContent()) {
+ if (child->isInline()) {
+ // Add generated inline content normally
+ RenderInline::addChild(builder, WTFMove(child));
+ } else {
+ // Wrap non-inline content with an anonymous inline-block.
+ RenderBlock* afterBlock = rubyAfterBlock(this);
+ if (!afterBlock) {
+ auto newBlock = createAnonymousRubyInlineBlock(*this);
+ afterBlock = newBlock.get();
+ RenderInline::addChild(builder, WTFMove(newBlock));
+ }
+ builder.insertChild(*afterBlock, WTFMove(child));
+ }
+ return;
+ }
+
+ // If the child is a ruby run, just add it normally.
+ if (child->isRubyRun()) {
+ RenderInline::addChild(builder, WTFMove(child), beforeChild);
+ return;
+ }
+
+ if (beforeChild && !isAfterContent(beforeChild)) {
+ // insert child into run
+ ASSERT(!beforeChild->isRubyRun());
+ RenderElement* run = beforeChild->parent();
+ while (run && !run->isRubyRun())
+ run = run->parent();
+ if (run) {
+ builder.insertChild(*run, WTFMove(child), beforeChild);
+ return;
+ }
+ ASSERT_NOT_REACHED(); // beforeChild should always have a run as parent!
+ // Emergency fallback: fall through and just append.
+ }
+
+ // If the new child would be appended, try to add the child to the previous run
+ // if possible, or create a new run otherwise.
+ // (The RenderRubyRun object will handle the details)
+ RenderRubyRun* lastRun = lastRubyRun(this);
+ if (!lastRun || lastRun->hasRubyText()) {
+ auto newRun = RenderRubyRun::staticCreateRubyRun(this);
+ lastRun = newRun.get();
+ RenderInline::addChild(builder, WTFMove(newRun), beforeChild);
+ }
+ builder.insertChild(*lastRun, WTFMove(child));
+}
+
RenderPtr<RenderObject> RenderRubyAsInline::takeChild(RenderObject& child)
{
// If the child's parent is *this (must be a ruby run or generated content or anonymous block),
Modified: branches/safari-605-branch/Source/WebCore/rendering/RenderRuby.h (226828 => 226829)
--- branches/safari-605-branch/Source/WebCore/rendering/RenderRuby.h 2018-01-12 01:50:33 UTC (rev 226828)
+++ branches/safari-605-branch/Source/WebCore/rendering/RenderRuby.h 2018-01-12 01:50:35 UTC (rev 226829)
@@ -56,6 +56,7 @@
RenderRubyAsInline(Element&, RenderStyle&&);
virtual ~RenderRubyAsInline();
+ void addChild(RenderTreeBuilder&, RenderPtr<RenderObject> child, RenderObject* beforeChild = 0) override;
RenderPtr<RenderObject> takeChild(RenderObject& child) override;
protected:
Modified: branches/safari-605-branch/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp (226828 => 226829)
--- branches/safari-605-branch/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp 2018-01-12 01:50:33 UTC (rev 226828)
+++ branches/safari-605-branch/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp 2018-01-12 01:50:35 UTC (rev 226829)
@@ -97,11 +97,6 @@
return;
}
- if (is<RenderRubyAsInline>(parent)) {
- insertRecursiveIfNeeded(rubyBuilder().findOrCreateParentForChild(downcast<RenderRubyAsInline>(parent), *child, beforeChild));
- return;
- }
-
if (is<RenderRubyRun>(parent)) {
rubyBuilder().insertChild(downcast<RenderRubyRun>(parent), WTFMove(child), beforeChild);
return;
Modified: branches/safari-605-branch/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.cpp (226828 => 226829)
--- branches/safari-605-branch/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.cpp 2018-01-12 01:50:33 UTC (rev 226828)
+++ branches/safari-605-branch/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.cpp 2018-01-12 01:50:35 UTC (rev 226829)
@@ -218,66 +218,6 @@
return *lastRun;
}
-RenderElement& RenderTreeBuilder::Ruby::findOrCreateParentForChild(RenderRubyAsInline& parent, const RenderObject& child, RenderObject*& beforeChild)
-{
- // Insert :before and :after content before/after the RenderRubyRun(s)
- if (child.isBeforeContent()) {
- // Add generated inline content normally
- if (child.isInline())
- return parent;
- // Wrap non-inline content with an anonymous inline-block.
- auto* beforeBlock = rubyBeforeBlock(&parent);
- if (!beforeBlock) {
- auto newBlock = createAnonymousRubyInlineBlock(parent);
- beforeBlock = newBlock.get();
- parent.RenderInline::addChild(m_builder, WTFMove(newBlock), parent.firstChild());
- }
- beforeChild = nullptr;
- return *beforeBlock;
- }
- if (child.isAfterContent()) {
- // Add generated inline content normally
- if (child.isInline())
- return parent;
- // Wrap non-inline content with an anonymous inline-block.
- auto* afterBlock = rubyAfterBlock(&parent);
- if (!afterBlock) {
- auto newBlock = createAnonymousRubyInlineBlock(parent);
- afterBlock = newBlock.get();
- parent.RenderInline::addChild(m_builder, WTFMove(newBlock));
- }
- beforeChild = nullptr;
- return *afterBlock;
- }
-
- // If the child is a ruby run, just add it normally.
- if (child.isRubyRun())
- return parent;
-
- if (beforeChild && !parent.isAfterContent(beforeChild)) {
- // insert child into run
- ASSERT(!beforeChild->isRubyRun());
- auto* run = beforeChild->parent();
- while (run && !run->isRubyRun())
- run = run->parent();
- if (run)
- return *run;
- ASSERT_NOT_REACHED(); // beforeChild should always have a run as parent!
- // Emergency fallback: fall through and just append.
- }
-
- // If the new child would be appended, try to add the child to the previous run
- // if possible, or create a new run otherwise.
- // (The RenderRubyRun object will handle the details)
- auto* lastRun = lastRubyRun(&parent);
- if (!lastRun || lastRun->hasRubyText()) {
- auto newRun = RenderRubyRun::staticCreateRubyRun(&parent);
- lastRun = newRun.get();
- parent.RenderInline::addChild(m_builder, WTFMove(newRun), beforeChild);
- }
- beforeChild = nullptr;
- return *lastRun;
}
-}
Modified: branches/safari-605-branch/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.h (226828 => 226829)
--- branches/safari-605-branch/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.h 2018-01-12 01:50:33 UTC (rev 226828)
+++ branches/safari-605-branch/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.h 2018-01-12 01:50:35 UTC (rev 226829)
@@ -32,7 +32,6 @@
class RenderElement;
class RenderObject;
class RenderRubyAsBlock;
-class RenderRubyAsInline;
class RenderRubyRun;
class RenderTreeBuilder;
@@ -42,7 +41,6 @@
void insertChild(RenderRubyRun& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild);
RenderElement& findOrCreateParentForChild(RenderRubyAsBlock& parent, const RenderObject& child, RenderObject*& beforeChild);
- RenderElement& findOrCreateParentForChild(RenderRubyAsInline& parent, const RenderObject& child, RenderObject*& beforeChild);
private:
RenderTreeBuilder& m_builder;