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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2003, 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2003, 2006, 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 setLineBreakInfo(0, 0, BidiStatus()); 214 setLineBreakInfo(0, 0, BidiStatus());
215 215
216 for (RootInlineBox* prev = prevRootBox(); 216 for (RootInlineBox* prev = prevRootBox();
217 prev && prev->lineBreakObj() == box->getLineLayoutItem(); 217 prev && prev->lineBreakObj() == box->getLineLayoutItem();
218 prev = prev->prevRootBox()) { 218 prev = prev->prevRootBox()) {
219 prev->setLineBreakInfo(0, 0, BidiStatus()); 219 prev->setLineBreakInfo(0, 0, BidiStatus());
220 prev->markDirty(); 220 prev->markDirty();
221 } 221 }
222 } 222 }
223 223
224 static inline void applyLineHeightStep(uint8_t lineHeightStep, 224 static inline void snapHeight(int& maxAscent,
225 int& maxAscent, 225 int& maxDescent,
226 int& maxDescent) { 226 const ComputedStyle& style) {
227 // Round up to the multiple of units, by adding spaces to over/under equally. 227 // If position is 0, add spaces to over/under equally.
228 // https://drafts.csswg.org/css-rhythm/#line-height-step 228 // https://drafts.csswg.org/css-snap-size/#snap-height
229 int remainder = (maxAscent + maxDescent) % lineHeightStep; 229 int unit = style.snapHeightUnit();
230 if (!remainder) 230 ASSERT(unit);
231 int position = style.snapHeightPosition();
232 if (!position) {
233 int space = unit - ((maxAscent + maxDescent) % unit);
234 maxDescent += space / 2;
235 maxAscent += space - space / 2;
231 return; 236 return;
232 DCHECK_GT(remainder, 0); 237 }
233 int space = lineHeightStep - remainder; 238
234 maxDescent += space / 2; 239 // Match the baseline to the specified position.
235 maxAscent += space - space / 2; 240 // https://drafts.csswg.org/css-snap-size/#snap-baseline
241 ASSERT(position > 0 && position <= 100);
242 position = position * unit / 100;
243 int spaceOver = position - maxAscent % unit;
244 if (spaceOver < 0) {
245 spaceOver += unit;
246 ASSERT(spaceOver >= 0);
247 }
248 maxAscent += spaceOver;
249 maxDescent += unit - (maxAscent + maxDescent) % unit;
236 } 250 }
237 251
238 LayoutUnit RootInlineBox::alignBoxesInBlockDirection( 252 LayoutUnit RootInlineBox::alignBoxesInBlockDirection(
239 LayoutUnit heightOfBlock, 253 LayoutUnit heightOfBlock,
240 GlyphOverflowAndFallbackFontsMap& textBoxDataMap, 254 GlyphOverflowAndFallbackFontsMap& textBoxDataMap,
241 VerticalPositionCache& verticalPositionCache) { 255 VerticalPositionCache& verticalPositionCache) {
242 // SVG will handle vertical alignment on its own. 256 // SVG will handle vertical alignment on its own.
243 if (isSVGRootInlineBox()) 257 if (isSVGRootInlineBox())
244 return LayoutUnit(); 258 return LayoutUnit();
245 259
(...skipping 11 matching lines...) Expand all
257 271
258 computeLogicalBoxHeights(this, maxPositionTop, maxPositionBottom, maxAscent, 272 computeLogicalBoxHeights(this, maxPositionTop, maxPositionBottom, maxAscent,
259 maxDescent, setMaxAscent, setMaxDescent, 273 maxDescent, setMaxAscent, setMaxDescent,
260 noQuirksMode, textBoxDataMap, baselineType(), 274 noQuirksMode, textBoxDataMap, baselineType(),
261 verticalPositionCache); 275 verticalPositionCache);
262 276
263 if (maxAscent + maxDescent < std::max(maxPositionTop, maxPositionBottom)) 277 if (maxAscent + maxDescent < std::max(maxPositionTop, maxPositionBottom))
264 adjustMaxAscentAndDescent(maxAscent, maxDescent, maxPositionTop.toInt(), 278 adjustMaxAscentAndDescent(maxAscent, maxDescent, maxPositionTop.toInt(),
265 maxPositionBottom.toInt()); 279 maxPositionBottom.toInt());
266 280
267 if (uint8_t lineHeightStep = getLineLayoutItem().styleRef().lineHeightStep()) 281 if (getLineLayoutItem().styleRef().snapHeightUnit())
268 applyLineHeightStep(lineHeightStep, maxAscent, maxDescent); 282 snapHeight(maxAscent, maxDescent, getLineLayoutItem().styleRef());
269 283
270 LayoutUnit maxHeight = LayoutUnit(maxAscent + maxDescent); 284 LayoutUnit maxHeight = LayoutUnit(maxAscent + maxDescent);
271 LayoutUnit lineTop = heightOfBlock; 285 LayoutUnit lineTop = heightOfBlock;
272 LayoutUnit lineBottom = heightOfBlock; 286 LayoutUnit lineBottom = heightOfBlock;
273 LayoutUnit lineTopIncludingMargins = heightOfBlock; 287 LayoutUnit lineTopIncludingMargins = heightOfBlock;
274 LayoutUnit lineBottomIncludingMargins = heightOfBlock; 288 LayoutUnit lineBottomIncludingMargins = heightOfBlock;
275 LayoutUnit selectionBottom = heightOfBlock; 289 LayoutUnit selectionBottom = heightOfBlock;
276 bool setLineTop = false; 290 bool setLineTop = false;
277 bool hasAnnotationsBefore = false; 291 bool hasAnnotationsBefore = false;
278 bool hasAnnotationsAfter = false; 292 bool hasAnnotationsAfter = false;
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 } 788 }
775 endBox = nullptr; 789 endBox = nullptr;
776 return nullptr; 790 return nullptr;
777 } 791 }
778 792
779 const char* RootInlineBox::boxName() const { 793 const char* RootInlineBox::boxName() const {
780 return "RootInlineBox"; 794 return "RootInlineBox";
781 } 795 }
782 796
783 } // namespace blink 797 } // namespace blink
OLDNEW
« 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