OLD | NEW |
---|---|
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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
184 { | 184 { |
185 if (box->lineLayoutItem() == m_lineBreakObj) | 185 if (box->lineLayoutItem() == m_lineBreakObj) |
186 setLineBreakInfo(0, 0, BidiStatus()); | 186 setLineBreakInfo(0, 0, BidiStatus()); |
187 | 187 |
188 for (RootInlineBox* prev = prevRootBox(); prev && prev->lineBreakObj() == bo x->lineLayoutItem(); prev = prev->prevRootBox()) { | 188 for (RootInlineBox* prev = prevRootBox(); prev && prev->lineBreakObj() == bo x->lineLayoutItem(); prev = prev->prevRootBox()) { |
189 prev->setLineBreakInfo(0, 0, BidiStatus()); | 189 prev->setLineBreakInfo(0, 0, BidiStatus()); |
190 prev->markDirty(); | 190 prev->markDirty(); |
191 } | 191 } |
192 } | 192 } |
193 | 193 |
194 static inline void snapHeight(int& maxAscent, int& maxDescent, const ComputedSty le& style) | |
195 { | |
196 // https://drafts.csswg.org/css-snap-size/#snap-height | |
197 int unit = style.snapHeightUnit(); | |
198 if (!unit) | |
199 return; | |
200 | |
201 // If position is 0, add spaces to over/under equally. | |
202 int position = style.snapHeightPosition(); | |
203 if (!position) { | |
204 int space = unit - ((maxAscent + maxDescent) % unit); | |
205 maxDescent += space / 2; | |
206 maxAscent += space - space / 2; | |
207 return; | |
208 } | |
209 | |
210 // Match the baseline to the specified position. | |
211 // https://drafts.csswg.org/css-snap-size/#snap-baseline | |
212 ASSERT(position > 0 && position <= 100); | |
213 position = position * unit / 100; | |
214 int spaceOver = position - maxAscent % unit; | |
215 if (spaceOver < 0) { | |
216 spaceOver += unit; | |
217 ASSERT(spaceOver >= 0); | |
218 } | |
219 maxAscent += spaceOver; | |
220 maxDescent += unit - (maxAscent + maxDescent) % unit; | |
221 } | |
222 | |
194 LayoutUnit RootInlineBox::alignBoxesInBlockDirection(LayoutUnit heightOfBlock, G lyphOverflowAndFallbackFontsMap& textBoxDataMap, VerticalPositionCache& vertical PositionCache) | 223 LayoutUnit RootInlineBox::alignBoxesInBlockDirection(LayoutUnit heightOfBlock, G lyphOverflowAndFallbackFontsMap& textBoxDataMap, VerticalPositionCache& vertical PositionCache) |
195 { | 224 { |
196 // SVG will handle vertical alignment on its own. | 225 // SVG will handle vertical alignment on its own. |
197 if (isSVGRootInlineBox()) | 226 if (isSVGRootInlineBox()) |
198 return LayoutUnit(); | 227 return LayoutUnit(); |
199 | 228 |
200 LayoutUnit maxPositionTop; | 229 LayoutUnit maxPositionTop; |
201 LayoutUnit maxPositionBottom; | 230 LayoutUnit maxPositionBottom; |
202 int maxAscent = 0; | 231 int maxAscent = 0; |
203 int maxDescent = 0; | 232 int maxDescent = 0; |
204 bool setMaxAscent = false; | 233 bool setMaxAscent = false; |
205 bool setMaxDescent = false; | 234 bool setMaxDescent = false; |
206 | 235 |
207 // Figure out if we're in no-quirks mode. | 236 // Figure out if we're in no-quirks mode. |
208 bool noQuirksMode = lineLayoutItem().document().inNoQuirksMode(); | 237 bool noQuirksMode = lineLayoutItem().document().inNoQuirksMode(); |
209 | 238 |
210 m_baselineType = dominantBaseline(); | 239 m_baselineType = dominantBaseline(); |
211 | 240 |
212 computeLogicalBoxHeights(this, maxPositionTop, maxPositionBottom, maxAscent, maxDescent, setMaxAscent, setMaxDescent, noQuirksMode, textBoxDataMap, baseline Type(), verticalPositionCache); | 241 computeLogicalBoxHeights(this, maxPositionTop, maxPositionBottom, maxAscent, maxDescent, setMaxAscent, setMaxDescent, noQuirksMode, textBoxDataMap, baseline Type(), verticalPositionCache); |
213 | 242 |
214 if (maxAscent + maxDescent < std::max(maxPositionTop, maxPositionBottom)) | 243 if (maxAscent + maxDescent < std::max(maxPositionTop, maxPositionBottom)) |
215 adjustMaxAscentAndDescent(maxAscent, maxDescent, maxPositionTop, maxPosi tionBottom); | 244 adjustMaxAscentAndDescent(maxAscent, maxDescent, maxPositionTop, maxPosi tionBottom); |
216 | 245 |
246 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.
| |
247 | |
217 LayoutUnit maxHeight = LayoutUnit(maxAscent + maxDescent); | 248 LayoutUnit maxHeight = LayoutUnit(maxAscent + maxDescent); |
218 LayoutUnit lineTop = heightOfBlock; | 249 LayoutUnit lineTop = heightOfBlock; |
219 LayoutUnit lineBottom = heightOfBlock; | 250 LayoutUnit lineBottom = heightOfBlock; |
220 LayoutUnit lineTopIncludingMargins = heightOfBlock; | 251 LayoutUnit lineTopIncludingMargins = heightOfBlock; |
221 LayoutUnit lineBottomIncludingMargins = heightOfBlock; | 252 LayoutUnit lineBottomIncludingMargins = heightOfBlock; |
222 LayoutUnit selectionBottom = heightOfBlock; | 253 LayoutUnit selectionBottom = heightOfBlock; |
223 bool setLineTop = false; | 254 bool setLineTop = false; |
224 bool hasAnnotationsBefore = false; | 255 bool hasAnnotationsBefore = false; |
225 bool hasAnnotationsAfter = false; | 256 bool hasAnnotationsAfter = false; |
226 placeBoxesInBlockDirection(heightOfBlock, maxHeight, maxAscent, noQuirksMode , lineTop, lineBottom, selectionBottom, setLineTop, lineTopIncludingMargins, lin eBottomIncludingMargins, hasAnnotationsBefore, hasAnnotationsAfter, baselineType ()); | 257 placeBoxesInBlockDirection(heightOfBlock, maxHeight, maxAscent, noQuirksMode , lineTop, lineBottom, selectionBottom, setLineTop, lineTopIncludingMargins, lin eBottomIncludingMargins, hasAnnotationsBefore, hasAnnotationsAfter, baselineType ()); |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
706 endBox = nullptr; | 737 endBox = nullptr; |
707 return nullptr; | 738 return nullptr; |
708 } | 739 } |
709 | 740 |
710 const char* RootInlineBox::boxName() const | 741 const char* RootInlineBox::boxName() const |
711 { | 742 { |
712 return "RootInlineBox"; | 743 return "RootInlineBox"; |
713 } | 744 } |
714 | 745 |
715 } // namespace blink | 746 } // namespace blink |
OLD | NEW |