Chromium Code Reviews| Index: third_party/WebKit/Source/core/layout/line/RootInlineBox.cpp |
| diff --git a/third_party/WebKit/Source/core/layout/line/RootInlineBox.cpp b/third_party/WebKit/Source/core/layout/line/RootInlineBox.cpp |
| index 4f369da0b2bfd09bbb7fbfc5755952052fd331b3..8d6a511e563d20b99a8cd4e26fd1aacf3bdf59e8 100644 |
| --- a/third_party/WebKit/Source/core/layout/line/RootInlineBox.cpp |
| +++ b/third_party/WebKit/Source/core/layout/line/RootInlineBox.cpp |
| @@ -191,6 +191,35 @@ void RootInlineBox::childRemoved(InlineBox* box) |
| } |
| } |
| +static inline void snapHeight(int& maxAscent, int& maxDescent, const ComputedStyle& style) |
| +{ |
| + // https://drafts.csswg.org/css-snap-size/#snap-height |
| + int unit = style.snapHeightUnit(); |
| + if (!unit) |
| + return; |
| + |
| + // If position is 0, add spaces to over/under equally. |
| + int position = style.snapHeightPosition(); |
| + if (!position) { |
| + int space = unit - ((maxAscent + maxDescent) % unit); |
| + maxDescent += space / 2; |
| + maxAscent += space - space / 2; |
| + return; |
| + } |
| + |
| + // Match the baseline to the specified position. |
| + // https://drafts.csswg.org/css-snap-size/#snap-baseline |
| + ASSERT(position > 0 && position <= 100); |
| + position = position * unit / 100; |
| + int spaceOver = position - maxAscent % unit; |
| + if (spaceOver < 0) { |
| + spaceOver += unit; |
| + ASSERT(spaceOver >= 0); |
| + } |
| + maxAscent += spaceOver; |
| + maxDescent += unit - (maxAscent + maxDescent) % unit; |
| +} |
| + |
| LayoutUnit RootInlineBox::alignBoxesInBlockDirection(LayoutUnit heightOfBlock, GlyphOverflowAndFallbackFontsMap& textBoxDataMap, VerticalPositionCache& verticalPositionCache) |
| { |
| // SVG will handle vertical alignment on its own. |
| @@ -214,6 +243,8 @@ LayoutUnit RootInlineBox::alignBoxesInBlockDirection(LayoutUnit heightOfBlock, G |
| if (maxAscent + maxDescent < std::max(maxPositionTop, maxPositionBottom)) |
| adjustMaxAscentAndDescent(maxAscent, maxDescent, maxPositionTop, maxPositionBottom); |
| + snapHeight(maxAscent, maxDescent, lineLayoutItem().styleRef()); |
|
eae
2016/02/18 18:02:12
if (lineLayoutItem().styleRef().snapHeightUnit())
kojii
2016/02/18 20:30:32
Done, thank you.
|
| + |
| LayoutUnit maxHeight = LayoutUnit(maxAscent + maxDescent); |
| LayoutUnit lineTop = heightOfBlock; |
| LayoutUnit lineBottom = heightOfBlock; |