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

Side by Side 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 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 snapHeight(int& maxAscent, 224 static inline void applyLineHeightStep(uint8_t lineHeightStep,
225 int& maxDescent, 225 int& maxAscent,
226 const ComputedStyle& style) { 226 int& maxDescent) {
227 // If position is 0, add spaces to over/under equally. 227 // Round up to the multiple of units, by adding spaces to over/under equally.
228 // https://drafts.csswg.org/css-snap-size/#snap-height 228 // https://drafts.csswg.org/css-rhythm/#line-height-step
229 int unit = style.snapHeightUnit(); 229 int remainder = (maxAscent + maxDescent) % lineHeightStep;
230 ASSERT(unit); 230 if (!remainder)
231 int position = style.snapHeightPosition();
232 if (!position) {
233 int space = unit - ((maxAscent + maxDescent) % unit);
234 maxDescent += space / 2;
235 maxAscent += space - space / 2;
236 return; 231 return;
237 } 232 DCHECK_GT(remainder, 0);
238 233 int space = lineHeightStep - remainder;
239 // Match the baseline to the specified position. 234 maxDescent += space / 2;
240 // https://drafts.csswg.org/css-snap-size/#snap-baseline 235 maxAscent += space - space / 2;
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;
250 } 236 }
251 237
252 LayoutUnit RootInlineBox::alignBoxesInBlockDirection( 238 LayoutUnit RootInlineBox::alignBoxesInBlockDirection(
253 LayoutUnit heightOfBlock, 239 LayoutUnit heightOfBlock,
254 GlyphOverflowAndFallbackFontsMap& textBoxDataMap, 240 GlyphOverflowAndFallbackFontsMap& textBoxDataMap,
255 VerticalPositionCache& verticalPositionCache) { 241 VerticalPositionCache& verticalPositionCache) {
256 // SVG will handle vertical alignment on its own. 242 // SVG will handle vertical alignment on its own.
257 if (isSVGRootInlineBox()) 243 if (isSVGRootInlineBox())
258 return LayoutUnit(); 244 return LayoutUnit();
259 245
(...skipping 11 matching lines...) Expand all
271 257
272 computeLogicalBoxHeights(this, maxPositionTop, maxPositionBottom, maxAscent, 258 computeLogicalBoxHeights(this, maxPositionTop, maxPositionBottom, maxAscent,
273 maxDescent, setMaxAscent, setMaxDescent, 259 maxDescent, setMaxAscent, setMaxDescent,
274 noQuirksMode, textBoxDataMap, baselineType(), 260 noQuirksMode, textBoxDataMap, baselineType(),
275 verticalPositionCache); 261 verticalPositionCache);
276 262
277 if (maxAscent + maxDescent < std::max(maxPositionTop, maxPositionBottom)) 263 if (maxAscent + maxDescent < std::max(maxPositionTop, maxPositionBottom))
278 adjustMaxAscentAndDescent(maxAscent, maxDescent, maxPositionTop.toInt(), 264 adjustMaxAscentAndDescent(maxAscent, maxDescent, maxPositionTop.toInt(),
279 maxPositionBottom.toInt()); 265 maxPositionBottom.toInt());
280 266
281 if (getLineLayoutItem().styleRef().snapHeightUnit()) 267 if (uint8_t lineHeightStep = getLineLayoutItem().styleRef().lineHeightStep())
282 snapHeight(maxAscent, maxDescent, getLineLayoutItem().styleRef()); 268 applyLineHeightStep(lineHeightStep, maxAscent, maxDescent);
283 269
284 LayoutUnit maxHeight = LayoutUnit(maxAscent + maxDescent); 270 LayoutUnit maxHeight = LayoutUnit(maxAscent + maxDescent);
285 LayoutUnit lineTop = heightOfBlock; 271 LayoutUnit lineTop = heightOfBlock;
286 LayoutUnit lineBottom = heightOfBlock; 272 LayoutUnit lineBottom = heightOfBlock;
287 LayoutUnit lineTopIncludingMargins = heightOfBlock; 273 LayoutUnit lineTopIncludingMargins = heightOfBlock;
288 LayoutUnit lineBottomIncludingMargins = heightOfBlock; 274 LayoutUnit lineBottomIncludingMargins = heightOfBlock;
289 LayoutUnit selectionBottom = heightOfBlock; 275 LayoutUnit selectionBottom = heightOfBlock;
290 bool setLineTop = false; 276 bool setLineTop = false;
291 bool hasAnnotationsBefore = false; 277 bool hasAnnotationsBefore = false;
292 bool hasAnnotationsAfter = false; 278 bool hasAnnotationsAfter = false;
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 } 774 }
789 endBox = nullptr; 775 endBox = nullptr;
790 return nullptr; 776 return nullptr;
791 } 777 }
792 778
793 const char* RootInlineBox::boxName() const { 779 const char* RootInlineBox::boxName() const {
794 return "RootInlineBox"; 780 return "RootInlineBox";
795 } 781 }
796 782
797 } // namespace blink 783 } // 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