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.
All rights reserved. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. |
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 3729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3740 | 3740 |
3741 LayoutUnit RenderBlock::lineHeight(bool firstLine, LineDirectionMode direction,
LinePositionMode linePositionMode) const | 3741 LayoutUnit RenderBlock::lineHeight(bool firstLine, LineDirectionMode direction,
LinePositionMode linePositionMode) const |
3742 { | 3742 { |
3743 // Inline blocks are replaced elements. Otherwise, just pass off to | 3743 // Inline blocks are replaced elements. Otherwise, just pass off to |
3744 // the base class. If we're being queried as though we're the root line | 3744 // the base class. If we're being queried as though we're the root line |
3745 // box, then the fact that we're an inline-block is irrelevant, and we behav
e | 3745 // box, then the fact that we're an inline-block is irrelevant, and we behav
e |
3746 // just like a block. | 3746 // just like a block. |
3747 if (isReplaced() && linePositionMode == PositionOnContainingLine) | 3747 if (isReplaced() && linePositionMode == PositionOnContainingLine) |
3748 return RenderBox::lineHeight(firstLine, direction, linePositionMode); | 3748 return RenderBox::lineHeight(firstLine, direction, linePositionMode); |
3749 | 3749 |
3750 RenderStyle* s = style(firstLine && document().styleEngine()->usesFirstLineR
ules()); | 3750 RenderStyle* s = styleOrFirstLineStyle(firstLine && document().styleEngine()
->usesFirstLineRules()); |
3751 return s->computedLineHeight(); | 3751 return s->computedLineHeight(); |
3752 } | 3752 } |
3753 | 3753 |
3754 int RenderBlock::beforeMarginInLineDirection(LineDirectionMode direction) const | 3754 int RenderBlock::beforeMarginInLineDirection(LineDirectionMode direction) const |
3755 { | 3755 { |
3756 return direction == HorizontalLine ? marginTop() : marginRight(); | 3756 return direction == HorizontalLine ? marginTop() : marginRight(); |
3757 } | 3757 } |
3758 | 3758 |
3759 int RenderBlock::baselinePosition(FontBaseline baselineType, bool firstLine, Lin
eDirectionMode direction, LinePositionMode linePositionMode) const | 3759 int RenderBlock::baselinePosition(FontBaseline baselineType, bool firstLine, Lin
eDirectionMode direction, LinePositionMode linePositionMode) const |
3760 { | 3760 { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3793 if (baselinePos != -1) | 3793 if (baselinePos != -1) |
3794 return beforeMarginInLineDirection(direction) + baselinePos; | 3794 return beforeMarginInLineDirection(direction) + baselinePos; |
3795 | 3795 |
3796 return RenderBox::baselinePosition(baselineType, firstLine, direction, l
inePositionMode); | 3796 return RenderBox::baselinePosition(baselineType, firstLine, direction, l
inePositionMode); |
3797 } | 3797 } |
3798 | 3798 |
3799 // If we're not replaced, we'll only get called with PositionOfInteriorLineB
oxes. | 3799 // If we're not replaced, we'll only get called with PositionOfInteriorLineB
oxes. |
3800 // Note that inline-block counts as replaced here. | 3800 // Note that inline-block counts as replaced here. |
3801 ASSERT(linePositionMode == PositionOfInteriorLineBoxes); | 3801 ASSERT(linePositionMode == PositionOfInteriorLineBoxes); |
3802 | 3802 |
3803 const FontMetrics& fontMetrics = style(firstLine)->fontMetrics(); | 3803 const FontMetrics& fontMetrics = styleOrFirstLineStyle(firstLine)->fontMetri
cs(); |
3804 return fontMetrics.ascent(baselineType) + (lineHeight(firstLine, direction,
linePositionMode) - fontMetrics.height()) / 2; | 3804 return fontMetrics.ascent(baselineType) + (lineHeight(firstLine, direction,
linePositionMode) - fontMetrics.height()) / 2; |
3805 } | 3805 } |
3806 | 3806 |
3807 LayoutUnit RenderBlock::minLineHeightForReplacedRenderer(bool isFirstLine, Layou
tUnit replacedHeight) const | 3807 LayoutUnit RenderBlock::minLineHeightForReplacedRenderer(bool isFirstLine, Layou
tUnit replacedHeight) const |
3808 { | 3808 { |
3809 if (!document().inNoQuirksMode() && replacedHeight) | 3809 if (!document().inNoQuirksMode() && replacedHeight) |
3810 return replacedHeight; | 3810 return replacedHeight; |
3811 | 3811 |
3812 if (!(style(isFirstLine)->lineBoxContain() & LineBoxContainBlock)) | 3812 if (!(styleOrFirstLineStyle(isFirstLine)->lineBoxContain() & LineBoxContainB
lock)) |
3813 return 0; | 3813 return 0; |
3814 | 3814 |
3815 return std::max<LayoutUnit>(replacedHeight, lineHeight(isFirstLine, isHorizo
ntalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes))
; | 3815 return std::max<LayoutUnit>(replacedHeight, lineHeight(isFirstLine, isHorizo
ntalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes))
; |
3816 } | 3816 } |
3817 | 3817 |
3818 int RenderBlock::firstLineBoxBaseline() const | 3818 int RenderBlock::firstLineBoxBaseline() const |
3819 { | 3819 { |
3820 if (isWritingModeRoot() && !isRubyRun()) | 3820 if (isWritingModeRoot() && !isRubyRun()) |
3821 return -1; | 3821 return -1; |
3822 | 3822 |
3823 if (childrenInline()) { | 3823 if (childrenInline()) { |
3824 if (firstLineBox()) | 3824 if (firstLineBox()) |
3825 return firstLineBox()->logicalTop() + style(true)->fontMetrics().asc
ent(firstRootBox()->baselineType()); | 3825 return firstLineBox()->logicalTop() + styleOrFirstLineStyle(true)->f
ontMetrics().ascent(firstRootBox()->baselineType()); |
3826 else | 3826 else |
3827 return -1; | 3827 return -1; |
3828 } | 3828 } |
3829 else { | 3829 else { |
3830 for (RenderBox* curr = firstChildBox(); curr; curr = curr->nextSiblingBo
x()) { | 3830 for (RenderBox* curr = firstChildBox(); curr; curr = curr->nextSiblingBo
x()) { |
3831 if (!curr->isFloatingOrOutOfFlowPositioned()) { | 3831 if (!curr->isFloatingOrOutOfFlowPositioned()) { |
3832 int result = curr->firstLineBoxBaseline(); | 3832 int result = curr->firstLineBoxBaseline(); |
3833 if (result != -1) | 3833 if (result != -1) |
3834 return curr->logicalTop() + result; // Translate to our coor
dinate space. | 3834 return curr->logicalTop() + result; // Translate to our coor
dinate space. |
3835 } | 3835 } |
(...skipping 19 matching lines...) Expand all Loading... |
3855 return -1; | 3855 return -1; |
3856 | 3856 |
3857 if (childrenInline()) { | 3857 if (childrenInline()) { |
3858 if (!firstLineBox() && hasLineIfEmpty()) { | 3858 if (!firstLineBox() && hasLineIfEmpty()) { |
3859 const FontMetrics& fontMetrics = firstLineStyle()->fontMetrics(); | 3859 const FontMetrics& fontMetrics = firstLineStyle()->fontMetrics(); |
3860 return fontMetrics.ascent() | 3860 return fontMetrics.ascent() |
3861 + (lineHeight(true, lineDirection, PositionOfInteriorLineBoxes)
- fontMetrics.height()) / 2 | 3861 + (lineHeight(true, lineDirection, PositionOfInteriorLineBoxes)
- fontMetrics.height()) / 2 |
3862 + (lineDirection == HorizontalLine ? borderTop() + paddingTop()
: borderRight() + paddingRight()); | 3862 + (lineDirection == HorizontalLine ? borderTop() + paddingTop()
: borderRight() + paddingRight()); |
3863 } | 3863 } |
3864 if (lastLineBox()) | 3864 if (lastLineBox()) |
3865 return lastLineBox()->logicalTop() + style(lastLineBox() == firstLin
eBox())->fontMetrics().ascent(lastRootBox()->baselineType()); | 3865 return lastLineBox()->logicalTop() + styleOrFirstLineStyle(lastLineB
ox() == firstLineBox())->fontMetrics().ascent(lastRootBox()->baselineType()); |
3866 return -1; | 3866 return -1; |
3867 } else { | 3867 } else { |
3868 bool haveNormalFlowChild = false; | 3868 bool haveNormalFlowChild = false; |
3869 for (RenderBox* curr = lastChildBox(); curr; curr = curr->previousSiblin
gBox()) { | 3869 for (RenderBox* curr = lastChildBox(); curr; curr = curr->previousSiblin
gBox()) { |
3870 if (!curr->isFloatingOrOutOfFlowPositioned()) { | 3870 if (!curr->isFloatingOrOutOfFlowPositioned()) { |
3871 haveNormalFlowChild = true; | 3871 haveNormalFlowChild = true; |
3872 int result = curr->inlineBlockBaseline(lineDirection); | 3872 int result = curr->inlineBlockBaseline(lineDirection); |
3873 if (result != -1) | 3873 if (result != -1) |
3874 return curr->logicalTop() + result; // Translate to our coor
dinate space. | 3874 return curr->logicalTop() + result; // Translate to our coor
dinate space. |
3875 } | 3875 } |
(...skipping 1143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5019 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m
arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render
Object* obj) const | 5019 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m
arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render
Object* obj) const |
5020 { | 5020 { |
5021 showRenderObject(); | 5021 showRenderObject(); |
5022 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot
Box()) | 5022 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot
Box()) |
5023 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa
bel2, obj, 1); | 5023 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa
bel2, obj, 1); |
5024 } | 5024 } |
5025 | 5025 |
5026 #endif | 5026 #endif |
5027 | 5027 |
5028 } // namespace WebCore | 5028 } // namespace WebCore |
OLD | NEW |