Diff
Modified: branches/safari-605-branch/Source/WebCore/ChangeLog (226829 => 226830)
--- branches/safari-605-branch/Source/WebCore/ChangeLog 2018-01-12 01:50:35 UTC (rev 226829)
+++ branches/safari-605-branch/Source/WebCore/ChangeLog 2018-01-12 01:50:38 UTC (rev 226830)
@@ -1,5 +1,9 @@
2018-01-11 Jason Marcell <[email protected]>
+ Revert r226240. rdar://problem/36180916
+
+2018-01-11 Jason Marcell <[email protected]>
+
Revert r226246. rdar://problem/36184788
2018-01-11 Jason Marcell <[email protected]>
Modified: branches/safari-605-branch/Source/WebCore/rendering/RenderRuby.cpp (226829 => 226830)
--- branches/safari-605-branch/Source/WebCore/rendering/RenderRuby.cpp 2018-01-12 01:50:35 UTC (rev 226829)
+++ branches/safari-605-branch/Source/WebCore/rendering/RenderRuby.cpp 2018-01-12 01:50:38 UTC (rev 226830)
@@ -247,6 +247,74 @@
propagateStyleToAnonymousChildren(PropagateToAllChildren);
}
+void RenderRubyAsBlock::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
+ RenderBlockFlow::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();
+ RenderBlockFlow::addChild(builder, WTFMove(newBlock), firstChild());
+ }
+ builder.insertChild(*beforeBlock, WTFMove(child));
+ }
+ return;
+ }
+ if (child->isAfterContent()) {
+ if (child->isInline()) {
+ // Add generated inline content normally
+ RenderBlockFlow::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();
+ RenderBlockFlow::addChild(builder, WTFMove(newBlock));
+ }
+ builder.insertChild(*afterBlock, WTFMove(child));
+ }
+ return;
+ }
+
+ // If the child is a ruby run, just add it normally.
+ if (child->isRubyRun()) {
+ RenderBlockFlow::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();
+ RenderBlockFlow::addChild(builder, WTFMove(newRun), beforeChild);
+ }
+ builder.insertChild(*lastRun, WTFMove(child));
+}
+
RenderPtr<RenderObject> RenderRubyAsBlock::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 (226829 => 226830)
--- branches/safari-605-branch/Source/WebCore/rendering/RenderRuby.h 2018-01-12 01:50:35 UTC (rev 226829)
+++ branches/safari-605-branch/Source/WebCore/rendering/RenderRuby.h 2018-01-12 01:50:38 UTC (rev 226830)
@@ -77,6 +77,7 @@
Element& element() const { return downcast<Element>(nodeForNonAnonymous()); }
+ 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 (226829 => 226830)
--- branches/safari-605-branch/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp 2018-01-12 01:50:35 UTC (rev 226829)
+++ branches/safari-605-branch/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp 2018-01-12 01:50:38 UTC (rev 226830)
@@ -92,11 +92,6 @@
return;
}
- if (is<RenderRubyAsBlock>(parent)) {
- insertRecursiveIfNeeded(rubyBuilder().findOrCreateParentForChild(downcast<RenderRubyAsBlock>(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 (226829 => 226830)
--- branches/safari-605-branch/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.cpp 2018-01-12 01:50:35 UTC (rev 226829)
+++ branches/safari-605-branch/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.cpp 2018-01-12 01:50:38 UTC (rev 226830)
@@ -26,84 +26,10 @@
#include "config.h"
#include "RenderTreeBuilderRuby.h"
-#include "RenderRubyRun.h"
#include "RenderTreeBuilder.h"
namespace WebCore {
-static inline bool isAnonymousRubyInlineBlock(const RenderObject* object)
-{
- ASSERT(!object
- || !isRuby(object->parent())
- || is<RenderRubyRun>(*object)
- || (object->isInline() && (object->isBeforeContent() || object->isAfterContent()))
- || (object->isAnonymous() && is<RenderBlock>(*object) && object->style().display() == INLINE_BLOCK));
-
- return object
- && isRuby(object->parent())
- && is<RenderBlock>(*object)
- && !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)
-{
- return object.isRubyRun()
- || object.isBeforeContent()
- || object.isAfterContent()
- || object.isRenderMultiColumnFlow()
- || object.isRenderMultiColumnSet()
- || isAnonymousRubyInlineBlock(&object);
-}
-#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);
-}
-
RenderTreeBuilder::Ruby::Ruby(RenderTreeBuilder& builder)
: m_builder(builder)
{
@@ -156,68 +82,5 @@
m_builder.insertChild(*parent.rubyBaseSafe(), WTFMove(child), beforeChild);
}
-RenderElement& RenderTreeBuilder::Ruby::findOrCreateParentForChild(RenderRubyAsBlock& 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 in an anonymous inline-block.
- auto* beforeBlock = rubyBeforeBlock(&parent);
- if (!beforeBlock) {
- auto newBlock = createAnonymousRubyInlineBlock(parent);
- beforeBlock = newBlock.get();
- parent.RenderBlockFlow::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.RenderBlockFlow::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.RenderBlockFlow::addChild(m_builder, WTFMove(newRun), beforeChild);
- }
- beforeChild = nullptr;
- return *lastRun;
}
-
-}
-
Modified: branches/safari-605-branch/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.h (226829 => 226830)
--- branches/safari-605-branch/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.h 2018-01-12 01:50:35 UTC (rev 226829)
+++ branches/safari-605-branch/Source/WebCore/rendering/updating/RenderTreeBuilderRuby.h 2018-01-12 01:50:38 UTC (rev 226830)
@@ -29,9 +29,7 @@
namespace WebCore {
-class RenderElement;
class RenderObject;
-class RenderRubyAsBlock;
class RenderRubyRun;
class RenderTreeBuilder;
@@ -40,7 +38,6 @@
Ruby(RenderTreeBuilder&);
void insertChild(RenderRubyRun& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild);
- RenderElement& findOrCreateParentForChild(RenderRubyAsBlock& parent, const RenderObject& child, RenderObject*& beforeChild);
private:
RenderTreeBuilder& m_builder;