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

Unified Diff: third_party/WebKit/Source/core/layout/line/RootInlineBox.cpp

Issue 2737673003: Revert of Catch up the spec update in CSS Rhythmic Sizing (Closed)
Patch Set: Created 3 years, 9 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
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 5f6d60807a964114156add7f39ee213263353938..6314b189868fc6cab52c10390e96fa3d16362477 100644
--- a/third_party/WebKit/Source/core/layout/line/RootInlineBox.cpp
+++ b/third_party/WebKit/Source/core/layout/line/RootInlineBox.cpp
@@ -221,18 +221,32 @@
}
}
-static inline void applyLineHeightStep(uint8_t lineHeightStep,
- int& maxAscent,
- int& maxDescent) {
- // Round up to the multiple of units, by adding spaces to over/under equally.
- // https://drafts.csswg.org/css-rhythm/#line-height-step
- int remainder = (maxAscent + maxDescent) % lineHeightStep;
- if (!remainder)
+static inline void snapHeight(int& maxAscent,
+ int& maxDescent,
+ const ComputedStyle& style) {
+ // If position is 0, add spaces to over/under equally.
+ // https://drafts.csswg.org/css-snap-size/#snap-height
+ int unit = style.snapHeightUnit();
+ ASSERT(unit);
+ int position = style.snapHeightPosition();
+ if (!position) {
+ int space = unit - ((maxAscent + maxDescent) % unit);
+ maxDescent += space / 2;
+ maxAscent += space - space / 2;
return;
- DCHECK_GT(remainder, 0);
- int space = lineHeightStep - remainder;
- maxDescent += space / 2;
- maxAscent += space - space / 2;
+ }
+
+ // 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(
@@ -264,8 +278,8 @@
adjustMaxAscentAndDescent(maxAscent, maxDescent, maxPositionTop.toInt(),
maxPositionBottom.toInt());
- if (uint8_t lineHeightStep = getLineLayoutItem().styleRef().lineHeightStep())
- applyLineHeightStep(lineHeightStep, maxAscent, maxDescent);
+ if (getLineLayoutItem().styleRef().snapHeightUnit())
+ snapHeight(maxAscent, maxDescent, getLineLayoutItem().styleRef());
LayoutUnit maxHeight = LayoutUnit(maxAscent + maxDescent);
LayoutUnit lineTop = heightOfBlock;
« no previous file with comments | « third_party/WebKit/Source/core/frame/UseCounter.cpp ('k') | third_party/WebKit/Source/core/style/ComputedStyle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698