summaryrefslogtreecommitdiffstats
path: root/WebCore/rendering/RenderRubyRun.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/rendering/RenderRubyRun.cpp')
-rw-r--r--WebCore/rendering/RenderRubyRun.cpp66
1 files changed, 57 insertions, 9 deletions
diff --git a/WebCore/rendering/RenderRubyRun.cpp b/WebCore/rendering/RenderRubyRun.cpp
index a83a3e2..5c92c04 100644
--- a/WebCore/rendering/RenderRubyRun.cpp
+++ b/WebCore/rendering/RenderRubyRun.cpp
@@ -220,17 +220,65 @@ RenderRubyRun* RenderRubyRun::staticCreateRubyRun(const RenderObject* parentRuby
RefPtr<RenderStyle> newStyle = RenderStyle::create();
newStyle->inheritFrom(parentRuby->style());
newStyle->setDisplay(INLINE_BLOCK);
- if (parentRuby->style()->isFlippedLinesWritingMode()) {
- // Ruby text is always in the line direction, so invert our block flow relative to the parent to
- // ensure that the Ruby ends up on the correct side.
- if (parentRuby->style()->isHorizontalWritingMode())
- newStyle->setWritingMode(TopToBottomWritingMode);
- else
- newStyle->setWritingMode(RightToLeftWritingMode);
- }
-
rr->setStyle(newStyle.release());
return rr;
}
+RenderObject* RenderRubyRun::layoutSpecialExcludedChild(bool relayoutChildren)
+{
+ // Don't bother positioning the RenderRubyRun yet.
+ RenderRubyText* rt = rubyText();
+ if (!rt)
+ return 0;
+ if (relayoutChildren)
+ rt->setChildNeedsLayout(true, false);
+ rt->layoutIfNeeded();
+ return rt;
+}
+
+void RenderRubyRun::layout()
+{
+ RenderBlock::layout();
+
+ // Place the RenderRubyText such that its bottom is flush with the lineTop of the first line of the RenderRubyBase.
+ RenderRubyText* rt = rubyText();
+ if (!rt)
+ return;
+
+ int lastLineRubyTextBottom = rt->logicalHeight();
+ int firstLineRubyTextTop = 0;
+ RootInlineBox* rootBox = rt->lastRootBox();
+ if (rootBox) {
+ // In order to align, we have to ignore negative leading.
+ firstLineRubyTextTop = rt->firstRootBox()->logicalTopLayoutOverflow();
+ lastLineRubyTextBottom = rootBox->logicalBottomLayoutOverflow();
+ }
+
+ if (!style()->isFlippedLinesWritingMode()) {
+ int firstLineTop = 0;
+ if (RenderRubyBase* rb = rubyBase()) {
+ RootInlineBox* rootBox = rb->firstRootBox();
+ if (rootBox)
+ firstLineTop = rootBox->logicalTopLayoutOverflow();
+ firstLineTop += rb->logicalTop();
+ }
+
+ rt->setLogicalTop(-lastLineRubyTextBottom + firstLineTop);
+ } else {
+ int lastLineBottom = logicalHeight();
+ if (RenderRubyBase* rb = rubyBase()) {
+ RootInlineBox* rootBox = rb->lastRootBox();
+ if (rootBox)
+ lastLineBottom = rootBox->logicalBottomLayoutOverflow();
+ lastLineBottom += rb->logicalTop();
+ }
+
+ rt->setLogicalTop(-firstLineRubyTextTop + lastLineBottom);
+ }
+
+ // Update our overflow to account for the new RenderRubyText position.
+ m_overflow.clear();
+ addOverflowFromBlockChildren();
+}
+
} // namespace WebCore