Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2007 David Smith (catfish.man@gmail.com) | 4 * (C) 2007 David Smith (catfish.man@gmail.com) |
| 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. |
| 6 * All rights reserved. | 6 * All rights reserved. |
| 7 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 7 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 1672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1683 | 1683 |
| 1684 return LayoutBox::baselinePosition(baselineType, firstLine, direction, | 1684 return LayoutBox::baselinePosition(baselineType, firstLine, direction, |
| 1685 linePositionMode); | 1685 linePositionMode); |
| 1686 } | 1686 } |
| 1687 | 1687 |
| 1688 // If we're not replaced, we'll only get called with | 1688 // If we're not replaced, we'll only get called with |
| 1689 // PositionOfInteriorLineBoxes. | 1689 // PositionOfInteriorLineBoxes. |
| 1690 // Note that inline-block counts as replaced here. | 1690 // Note that inline-block counts as replaced here. |
| 1691 ASSERT(linePositionMode == PositionOfInteriorLineBoxes); | 1691 ASSERT(linePositionMode == PositionOfInteriorLineBoxes); |
| 1692 | 1692 |
| 1693 const FontMetrics& fontMetrics = style(firstLine)->getFontMetrics(); | 1693 const SimpleFontData* fontData = style(firstLine)->font().primaryFont(); |
| 1694 DCHECK(fontData); | |
| 1695 if (!fontData) | |
| 1696 return -1; | |
|
wkorman
2016/10/13 22:54:30
Is -1 the correct error value? I see LayoutTheme::
eae
2016/10/13 23:09:58
Yeah, -1 is the magic value for unknown baseline.
| |
| 1697 | |
| 1698 const FontMetrics& fontMetrics = fontData->getFontMetrics(); | |
| 1694 return (fontMetrics.ascent(baselineType) + | 1699 return (fontMetrics.ascent(baselineType) + |
| 1695 (lineHeight(firstLine, direction, linePositionMode) - | 1700 (lineHeight(firstLine, direction, linePositionMode) - |
| 1696 fontMetrics.height()) / | 1701 fontMetrics.height()) / |
| 1697 2) | 1702 2) |
| 1698 .toInt(); | 1703 .toInt(); |
| 1699 } | 1704 } |
| 1700 | 1705 |
| 1701 LayoutUnit LayoutBlock::minLineHeightForReplacedObject( | 1706 LayoutUnit LayoutBlock::minLineHeightForReplacedObject( |
| 1702 bool isFirstLine, | 1707 bool isFirstLine, |
| 1703 LayoutUnit replacedHeight) const { | 1708 LayoutUnit replacedHeight) const { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1752 for (LayoutBox* curr = lastChildBox(); curr; | 1757 for (LayoutBox* curr = lastChildBox(); curr; |
| 1753 curr = curr->previousSiblingBox()) { | 1758 curr = curr->previousSiblingBox()) { |
| 1754 if (!curr->isFloatingOrOutOfFlowPositioned()) { | 1759 if (!curr->isFloatingOrOutOfFlowPositioned()) { |
| 1755 haveNormalFlowChild = true; | 1760 haveNormalFlowChild = true; |
| 1756 int result = curr->inlineBlockBaseline(lineDirection); | 1761 int result = curr->inlineBlockBaseline(lineDirection); |
| 1757 if (result != -1) | 1762 if (result != -1) |
| 1758 return (curr->logicalTop() + result) | 1763 return (curr->logicalTop() + result) |
| 1759 .toInt(); // Translate to our coordinate space. | 1764 .toInt(); // Translate to our coordinate space. |
| 1760 } | 1765 } |
| 1761 } | 1766 } |
| 1762 if (!haveNormalFlowChild && hasLineIfEmpty()) { | 1767 const SimpleFontData* fontData = firstLineStyle()->font().primaryFont(); |
| 1763 const FontMetrics& fontMetrics = firstLineStyle()->getFontMetrics(); | 1768 if (!haveNormalFlowChild && hasLineIfEmpty() && fontData) { |
|
wkorman
2016/10/13 22:54:30
Perhaps worth putting fontData first to save on ch
eae
2016/10/13 23:09:58
Acknowledged.
| |
| 1769 const FontMetrics& fontMetrics = fontData->getFontMetrics(); | |
| 1764 return (fontMetrics.ascent() + | 1770 return (fontMetrics.ascent() + |
| 1765 (lineHeight(true, lineDirection, PositionOfInteriorLineBoxes) - | 1771 (lineHeight(true, lineDirection, PositionOfInteriorLineBoxes) - |
| 1766 fontMetrics.height()) / | 1772 fontMetrics.height()) / |
| 1767 2 + | 1773 2 + |
| 1768 (lineDirection == HorizontalLine ? borderTop() + paddingTop() | 1774 (lineDirection == HorizontalLine ? borderTop() + paddingTop() |
| 1769 : borderRight() + paddingRight())) | 1775 : borderRight() + paddingRight())) |
| 1770 .toInt(); | 1776 .toInt(); |
| 1771 } | 1777 } |
| 1772 return -1; | 1778 return -1; |
| 1773 } | 1779 } |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2202 } | 2208 } |
| 2203 | 2209 |
| 2204 return availableHeight; | 2210 return availableHeight; |
| 2205 } | 2211 } |
| 2206 | 2212 |
| 2207 bool LayoutBlock::hasDefiniteLogicalHeight() const { | 2213 bool LayoutBlock::hasDefiniteLogicalHeight() const { |
| 2208 return availableLogicalHeightForPercentageComputation() != LayoutUnit(-1); | 2214 return availableLogicalHeightForPercentageComputation() != LayoutUnit(-1); |
| 2209 } | 2215 } |
| 2210 | 2216 |
| 2211 } // namespace blink | 2217 } // namespace blink |
| OLD | NEW |