summaryrefslogtreecommitdiff
path: root/Source/WebCore/rendering/RenderRubyBase.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/rendering/RenderRubyBase.cpp
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/rendering/RenderRubyBase.cpp')
-rw-r--r--Source/WebCore/rendering/RenderRubyBase.cpp37
1 files changed, 28 insertions, 9 deletions
diff --git a/Source/WebCore/rendering/RenderRubyBase.cpp b/Source/WebCore/rendering/RenderRubyBase.cpp
index 67be72b56..d3ebe98b9 100644
--- a/Source/WebCore/rendering/RenderRubyBase.cpp
+++ b/Source/WebCore/rendering/RenderRubyBase.cpp
@@ -36,8 +36,10 @@
namespace WebCore {
-RenderRubyBase::RenderRubyBase(Document& document, PassRef<RenderStyle> style)
- : RenderBlockFlow(document, std::move(style))
+RenderRubyBase::RenderRubyBase(Document& document, RenderStyle&& style)
+ : RenderBlockFlow(document, WTFMove(style))
+ , m_initialOffset(0)
+ , m_isAfterExpansion(true)
{
setInline(false);
}
@@ -69,6 +71,12 @@ void RenderRubyBase::moveChildren(RenderRubyBase* toBase, RenderObject* beforeCh
toBase->setNeedsLayoutAndPrefWidthsRecalc();
}
+void RenderRubyBase::mergeChildrenWithBase(RenderRubyBase& toBlock)
+{
+ moveChildren(&toBlock);
+ addFloatsToNewParent(toBlock);
+}
+
void RenderRubyBase::moveInlineChildren(RenderRubyBase* toBase, RenderObject* beforeChild)
{
ASSERT(childrenInline());
@@ -86,7 +94,7 @@ void RenderRubyBase::moveInlineChildren(RenderRubyBase* toBase, RenderObject* be
// If toBase has a suitable block, we re-use it, otherwise create a new one.
RenderObject* lastChild = toBase->lastChild();
if (lastChild && lastChild->isAnonymousBlock() && lastChild->childrenInline())
- toBlock = toRenderBlock(lastChild);
+ toBlock = downcast<RenderBlock>(lastChild);
else {
toBlock = toBase->createAnonymousBlock();
toBase->insertChildInternal(toBlock, nullptr, NotifyChildren);
@@ -112,8 +120,8 @@ void RenderRubyBase::moveBlockChildren(RenderRubyBase* toBase, RenderObject* bef
RenderObject* lastChildThere = toBase->lastChild();
if (firstChildHere->isAnonymousBlock() && firstChildHere->childrenInline()
&& lastChildThere && lastChildThere->isAnonymousBlock() && lastChildThere->childrenInline()) {
- RenderBlock* anonBlockHere = toRenderBlock(firstChildHere);
- RenderBlock* anonBlockThere = toRenderBlock(lastChildThere);
+ RenderBlock* anonBlockHere = downcast<RenderBlock>(firstChildHere);
+ RenderBlock* anonBlockThere = downcast<RenderBlock>(lastChildThere);
anonBlockHere->moveAllChildrenTo(anonBlockThere, true);
anonBlockHere->deleteLines();
anonBlockHere->destroy();
@@ -125,9 +133,7 @@ void RenderRubyBase::moveBlockChildren(RenderRubyBase* toBase, RenderObject* bef
RenderRubyRun* RenderRubyBase::rubyRun() const
{
ASSERT(parent());
- ASSERT(parent()->isRubyRun());
-
- return &toRenderRubyRun(*parent());
+ return downcast<RenderRubyRun>(parent());
}
ETextAlign RenderRubyBase::textAlignmentForLine(bool /* endsWithSoftBreak */) const
@@ -137,7 +143,13 @@ ETextAlign RenderRubyBase::textAlignmentForLine(bool /* endsWithSoftBreak */) co
void RenderRubyBase::adjustInlineDirectionLineBounds(int expansionOpportunityCount, float& logicalLeft, float& logicalWidth) const
{
- int maxPreferredLogicalWidth = this->maxPreferredLogicalWidth();
+ if (rubyRun()->hasOverrideLogicalContentWidth() && firstRootBox() && !firstRootBox()->nextRootBox()) {
+ logicalLeft += m_initialOffset;
+ logicalWidth -= 2 * m_initialOffset;
+ return;
+ }
+
+ LayoutUnit maxPreferredLogicalWidth = rubyRun() && rubyRun()->hasOverrideLogicalContentWidth() ? rubyRun()->overrideLogicalContentWidth() : this->maxPreferredLogicalWidth();
if (maxPreferredLogicalWidth >= logicalWidth)
return;
@@ -148,4 +160,11 @@ void RenderRubyBase::adjustInlineDirectionLineBounds(int expansionOpportunityCou
logicalWidth -= inset;
}
+void RenderRubyBase::cachePriorCharactersIfNeeded(const LazyLineBreakIterator& lineBreakIterator)
+{
+ auto* run = rubyRun();
+ if (run)
+ run->setCachedPriorCharacters(lineBreakIterator.lastCharacter(), lineBreakIterator.secondToLastCharacter());
+}
+
} // namespace WebCore