diff options
author | Shimeng (Simon) Wang <swang@google.com> | 2010-12-07 17:22:45 -0800 |
---|---|---|
committer | Shimeng (Simon) Wang <swang@google.com> | 2010-12-22 14:15:40 -0800 |
commit | 4576aa36e9a9671459299c7963ac95aa94beaea9 (patch) | |
tree | 3863574e050f168c0126ecb47c83319fab0972d8 /WebCore/rendering/InlineFlowBox.cpp | |
parent | 55323ac613cc31553107b68603cb627264d22bb0 (diff) | |
download | external_webkit-4576aa36e9a9671459299c7963ac95aa94beaea9.zip external_webkit-4576aa36e9a9671459299c7963ac95aa94beaea9.tar.gz external_webkit-4576aa36e9a9671459299c7963ac95aa94beaea9.tar.bz2 |
Merge WebKit at r73109: Initial merge by git.
Change-Id: I61f1a66d9642e3d8405d3ac6ccab2a53421c75d8
Diffstat (limited to 'WebCore/rendering/InlineFlowBox.cpp')
-rw-r--r-- | WebCore/rendering/InlineFlowBox.cpp | 83 |
1 files changed, 76 insertions, 7 deletions
diff --git a/WebCore/rendering/InlineFlowBox.cpp b/WebCore/rendering/InlineFlowBox.cpp index e67c751..ee9fe9f 100644 --- a/WebCore/rendering/InlineFlowBox.cpp +++ b/WebCore/rendering/InlineFlowBox.cpp @@ -32,6 +32,9 @@ #include "RenderInline.h" #include "RenderLayer.h" #include "RenderListMarker.h" +#include "RenderRubyBase.h" +#include "RenderRubyRun.h" +#include "RenderRubyText.h" #include "RenderTableCell.h" #include "RootInlineBox.h" #include "Text.h" @@ -620,7 +623,8 @@ void InlineFlowBox::computeLogicalBoxHeights(int& maxPositionTop, int& maxPositi } } -void InlineFlowBox::placeBoxesInBlockDirection(int top, int maxHeight, int maxAscent, bool strictMode, int& lineTop, int& lineBottom, bool& setLineTop, FontBaseline baselineType) +void InlineFlowBox::placeBoxesInBlockDirection(int top, int maxHeight, int maxAscent, bool strictMode, int& lineTop, int& lineBottom, bool& setLineTop, + int& lineTopIncludingMargins, int& lineBottomIncludingMargins, bool& containsRuby, FontBaseline baselineType) { if (isRootInlineBox()) setLogicalTop(top + maxAscent - baselinePosition(baselineType)); // Place our root box. @@ -633,7 +637,8 @@ void InlineFlowBox::placeBoxesInBlockDirection(int top, int maxHeight, int maxAs // line-height). bool isInlineFlow = curr->isInlineFlowBox(); if (isInlineFlow) - static_cast<InlineFlowBox*>(curr)->placeBoxesInBlockDirection(top, maxHeight, maxAscent, strictMode, lineTop, lineBottom, setLineTop, baselineType); + static_cast<InlineFlowBox*>(curr)->placeBoxesInBlockDirection(top, maxHeight, maxAscent, strictMode, lineTop, lineBottom, setLineTop, + lineTopIncludingMargins, lineBottomIncludingMargins, containsRuby, baselineType); bool childAffectsTopBottomPos = true; if (curr->logicalTop() == PositionTop) @@ -648,6 +653,10 @@ void InlineFlowBox::placeBoxesInBlockDirection(int top, int maxHeight, int maxAs } int newLogicalTop = curr->logicalTop(); + int newLogicalTopIncludingMargins; + int boxHeight = curr->logicalHeight(); + int boxHeightIncludingMargins = boxHeight; + if (curr->isText() || curr->isInlineFlowBox()) { const Font& font = curr->renderer()->style(m_firstLine)->font(); newLogicalTop += curr->baselinePosition(baselineType) - font.ascent(baselineType); @@ -656,21 +665,43 @@ void InlineFlowBox::placeBoxesInBlockDirection(int top, int maxHeight, int maxAs newLogicalTop -= boxObject->style(m_firstLine)->isHorizontalWritingMode() ? boxObject->borderTop() + boxObject->paddingTop() : boxObject->borderRight() + boxObject->paddingRight(); } + newLogicalTopIncludingMargins = newLogicalTop; } else if (!curr->renderer()->isBR()) { RenderBox* box = toRenderBox(curr->renderer()); - newLogicalTop += box->style(m_firstLine)->isHorizontalWritingMode() ? box->marginTop() : box->marginRight(); + newLogicalTopIncludingMargins = newLogicalTop; + int overSideMargin = curr->isHorizontal() ? box->marginTop() : box->marginRight(); + int underSideMargin = curr->isHorizontal() ? box->marginBottom() : box->marginLeft(); + newLogicalTop += overSideMargin; + boxHeightIncludingMargins += overSideMargin + underSideMargin; } curr->setLogicalTop(newLogicalTop); if (childAffectsTopBottomPos) { - int boxHeight = curr->logicalHeight(); + if (curr->renderer()->isRubyRun()) { + // Treat the leading on the first and last lines of ruby runs as not being part of the overall lineTop/lineBottom. + // Really this is a workaround hack for the fact that ruby should have been done as line layout and not done using + // inline-block. + containsRuby = true; + RenderRubyRun* rubyRun = static_cast<RenderRubyRun*>(curr->renderer()); + if (RenderRubyBase* rubyBase = rubyRun->rubyBase()) { + int bottomRubyBaseLeading = (curr->logicalHeight() - rubyBase->logicalBottom()) + rubyBase->logicalHeight() - (rubyBase->lastRootBox() ? rubyBase->lastRootBox()->lineBottom() : 0); + int topRubyBaseLeading = rubyBase->logicalTop() + (rubyBase->firstRootBox() ? rubyBase->firstRootBox()->lineTop() : 0); + newLogicalTop += !renderer()->style()->isFlippedLinesWritingMode() ? topRubyBaseLeading : bottomRubyBaseLeading; + boxHeight -= (topRubyBaseLeading + bottomRubyBaseLeading); + } + } + if (!setLineTop) { setLineTop = true; lineTop = newLogicalTop; - } else + lineTopIncludingMargins = min(lineTop, newLogicalTopIncludingMargins); + } else { lineTop = min(lineTop, newLogicalTop); + lineTopIncludingMargins = min(lineTop, min(lineTopIncludingMargins, newLogicalTopIncludingMargins)); + } lineBottom = max(lineBottom, newLogicalTop + boxHeight); + lineBottomIncludingMargins = max(lineBottom, max(lineBottomIncludingMargins, newLogicalTopIncludingMargins + boxHeightIncludingMargins)); } } @@ -682,13 +713,17 @@ void InlineFlowBox::placeBoxesInBlockDirection(int top, int maxHeight, int maxAs if (!setLineTop) { setLineTop = true; lineTop = logicalTop(); - } else + lineTopIncludingMargins = lineTop; + } else { lineTop = min(lineTop, logicalTop()); + lineTopIncludingMargins = min(lineTop, lineTopIncludingMargins); + } lineBottom = max(lineBottom, logicalTop() + logicalHeight()); + lineBottomIncludingMargins = max(lineBottom, lineBottomIncludingMargins); } if (renderer()->style()->isFlippedLinesWritingMode()) - flipLinesInBlockDirection(lineTop, lineBottom); + flipLinesInBlockDirection(lineTopIncludingMargins, lineBottomIncludingMargins); } } @@ -1170,6 +1205,40 @@ void InlineFlowBox::clearTruncation() box->clearTruncation(); } +int InlineFlowBox::computeBlockDirectionRubyAdjustment(int allowedPosition) const +{ + int result = 0; + for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) { + if (curr->renderer()->isPositioned()) + continue; // Positioned placeholders don't affect calculations. + + if (curr->isInlineFlowBox()) + result = max(result, static_cast<InlineFlowBox*>(curr)->computeBlockDirectionRubyAdjustment(allowedPosition)); + + if (curr->renderer()->isReplaced() && curr->renderer()->isRubyRun()) { + RenderRubyRun* rubyRun = static_cast<RenderRubyRun*>(curr->renderer()); + RenderRubyText* rubyText = rubyRun->rubyText(); + if (!rubyText) + continue; + + if (!rubyRun->style()->isFlippedLinesWritingMode()) { + int topOfFirstRubyTextLine = rubyText->logicalTop() + (rubyText->firstRootBox() ? rubyText->firstRootBox()->lineTop() : 0); + if (topOfFirstRubyTextLine >= 0) + continue; + topOfFirstRubyTextLine += curr->logicalTop(); + result = max(result, allowedPosition - topOfFirstRubyTextLine); + } else { + int bottomOfLastRubyTextLine = rubyText->logicalTop() + (rubyText->lastRootBox() ? rubyText->lastRootBox()->lineBottom() : rubyText->logicalHeight()); + if (bottomOfLastRubyTextLine <= curr->logicalHeight()) + continue; + bottomOfLastRubyTextLine += curr->logicalTop(); + result = max(result, bottomOfLastRubyTextLine - allowedPosition); + } + } + } + return result; +} + #ifndef NDEBUG void InlineFlowBox::checkConsistency() const |