Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(509)

Unified Diff: third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp

Issue 1952753002: Move parts of baseline calculation over to LayoutBlockFlow. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBlockFlow.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp b/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp
index 86c89055bb7ce6623f6cc00e09fdd72669e442c7..b1865cf71958b75fc6183e693d72eb23345aadc5 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBlockFlow.cpp
@@ -1951,6 +1951,46 @@ int LayoutBlockFlow::lineCount(const RootInlineBox* stopRootInlineBox) const
return count;
}
+int LayoutBlockFlow::firstLineBoxBaseline() const
+{
+ if (isWritingModeRoot() && !isRubyRun())
+ return -1;
+ if (!childrenInline())
+ return LayoutBlock::firstLineBoxBaseline();
+ if (firstLineBox())
+ return firstLineBox()->logicalTop() + style(true)->getFontMetrics().ascent(firstRootBox()->baselineType());
+ return -1;
+}
+
+int LayoutBlockFlow::inlineBlockBaseline(LineDirectionMode lineDirection) const
+{
+ // CSS2.1 states that the baseline of an 'inline-block' is:
+ // the baseline of the last line box in the normal flow, unless it has
+ // either no in-flow line boxes or if its 'overflow' property has a computed
+ // value other than 'visible', in which case the baseline is the bottom
+ // margin edge.
+ // We likewise avoid using the last line box in the case of size containment,
+ // where the block's contents shouldn't be considered when laying out its
+ // ancestors or siblings.
+
+ if ((!style()->isOverflowVisible() && !shouldIgnoreOverflowPropertyForInlineBlockBaseline()) || style()->containsSize()) {
+ // We are not calling baselinePosition here because the caller should add the margin-top/margin-right, not us.
+ return lineDirection == HorizontalLine ? size().height() + marginBottom() : size().width() + marginLeft();
+ }
+ if (isWritingModeRoot() && !isRubyRun())
+ return -1;
+ if (!childrenInline())
+ return LayoutBlock::inlineBlockBaseline(lineDirection);
+ if (lastLineBox())
+ return lastLineBox()->logicalTop() + style(lastLineBox() == firstLineBox())->getFontMetrics().ascent(lastRootBox()->baselineType());
+ if (!hasLineIfEmpty())
+ return -1;
+ const FontMetrics& fontMetrics = firstLineStyle()->getFontMetrics();
+ return fontMetrics.ascent()
+ + (lineHeight(true, lineDirection, PositionOfInteriorLineBoxes) - fontMetrics.height()) / 2
+ + (lineDirection == HorizontalLine ? borderTop() + paddingTop() : borderRight() + paddingRight());
+}
+
void LayoutBlockFlow::removeFloatingObjectsFromDescendants()
{
if (!containsFloats())
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBlockFlow.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698