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

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

Issue 2704343003: Catch up the spec update in CSS Rhythmic Sizing (Closed)
Patch Set: Sorted CSSProperties.json5 alphabetically (meade@'s nit) 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 6314b189868fc6cab52c10390e96fa3d16362477..5f6d60807a964114156add7f39ee213263353938 100644
--- a/third_party/WebKit/Source/core/layout/line/RootInlineBox.cpp
+++ b/third_party/WebKit/Source/core/layout/line/RootInlineBox.cpp
@@ -221,32 +221,18 @@ void RootInlineBox::childRemoved(InlineBox* box) {
}
}
-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;
+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)
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;
+ DCHECK_GT(remainder, 0);
+ int space = lineHeightStep - remainder;
+ maxDescent += space / 2;
+ maxAscent += space - space / 2;
}
LayoutUnit RootInlineBox::alignBoxesInBlockDirection(
@@ -278,8 +264,8 @@ LayoutUnit RootInlineBox::alignBoxesInBlockDirection(
adjustMaxAscentAndDescent(maxAscent, maxDescent, maxPositionTop.toInt(),
maxPositionBottom.toInt());
- if (getLineLayoutItem().styleRef().snapHeightUnit())
- snapHeight(maxAscent, maxDescent, getLineLayoutItem().styleRef());
+ if (uint8_t lineHeightStep = getLineLayoutItem().styleRef().lineHeightStep())
+ applyLineHeightStep(lineHeightStep, maxAscent, maxDescent);
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