| OLD | NEW |
| 1 /* | 1 /* |
| 2 * (C) 1999 Lars Knoll (knoll@kde.org) | 2 * (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 2000 Dirk Mueller (mueller@kde.org) | 3 * (C) 2000 Dirk Mueller (mueller@kde.org) |
| 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. | 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. |
| 5 * All rights reserved. | 5 * All rights reserved. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 return LayoutUnit( | 118 return LayoutUnit( |
| 119 LineLayoutBR(GetLineLayoutItem()).LineHeight(IsFirstLineStyle())); | 119 LineLayoutBR(GetLineLayoutItem()).LineHeight(IsFirstLineStyle())); |
| 120 if (Parent()->GetLineLayoutItem() == GetLineLayoutItem().Parent()) | 120 if (Parent()->GetLineLayoutItem() == GetLineLayoutItem().Parent()) |
| 121 return Parent()->LineHeight(); | 121 return Parent()->LineHeight(); |
| 122 return LineLayoutBoxModel(GetLineLayoutItem().Parent()) | 122 return LineLayoutBoxModel(GetLineLayoutItem().Parent()) |
| 123 .LineHeight(IsFirstLineStyle(), | 123 .LineHeight(IsFirstLineStyle(), |
| 124 IsHorizontal() ? kHorizontalLine : kVerticalLine, | 124 IsHorizontal() ? kHorizontalLine : kVerticalLine, |
| 125 kPositionOnContainingLine); | 125 kPositionOnContainingLine); |
| 126 } | 126 } |
| 127 | 127 |
| 128 LayoutUnit InlineTextBox::OffsetTo(LineVerticalPositionType position_type, |
| 129 FontBaseline baseline_type) const { |
| 130 if (IsText() && |
| 131 (position_type == LineVerticalPositionType::TopOfEmHeight || |
| 132 position_type == LineVerticalPositionType::BottomOfEmHeight)) { |
| 133 const Font& font = GetLineLayoutItem().Style(IsFirstLineStyle())->GetFont(); |
| 134 if (const SimpleFontData* font_data = font.PrimaryFont()) { |
| 135 const FontMetrics& metrics = font_data->GetFontMetrics(); |
| 136 if (position_type == LineVerticalPositionType::TopOfEmHeight) { |
| 137 return metrics.FixedAscent(baseline_type) - |
| 138 font_data->EmHeightAscent(baseline_type); |
| 139 } |
| 140 if (position_type == LineVerticalPositionType::BottomOfEmHeight) { |
| 141 return metrics.FixedAscent(baseline_type) + |
| 142 font_data->EmHeightDescent(baseline_type); |
| 143 } |
| 144 } |
| 145 } |
| 146 switch (position_type) { |
| 147 case LineVerticalPositionType::TextTop: |
| 148 case LineVerticalPositionType::TopOfEmHeight: |
| 149 return LayoutUnit(); |
| 150 case LineVerticalPositionType::TextBottom: |
| 151 case LineVerticalPositionType::BottomOfEmHeight: |
| 152 return LogicalHeight(); |
| 153 } |
| 154 NOTREACHED(); |
| 155 return LayoutUnit(); |
| 156 } |
| 157 |
| 158 LayoutUnit InlineTextBox::VerticalPosition( |
| 159 LineVerticalPositionType position_type, |
| 160 FontBaseline baseline_type) const { |
| 161 return LogicalTop() + OffsetTo(position_type, baseline_type); |
| 162 } |
| 163 |
| 128 bool InlineTextBox::IsSelected(int start_pos, int end_pos) const { | 164 bool InlineTextBox::IsSelected(int start_pos, int end_pos) const { |
| 129 int s_pos = std::max(start_pos - start_, 0); | 165 int s_pos = std::max(start_pos - start_, 0); |
| 130 // The position after a hard line break is considered to be past its end. | 166 // The position after a hard line break is considered to be past its end. |
| 131 // See the corresponding code in InlineTextBox::getSelectionState. | 167 // See the corresponding code in InlineTextBox::getSelectionState. |
| 132 int e_pos = std::min(end_pos - start_, int(len_) + (IsLineBreak() ? 0 : 1)); | 168 int e_pos = std::min(end_pos - start_, int(len_) + (IsLineBreak() ? 0 : 1)); |
| 133 return (s_pos < e_pos); | 169 return (s_pos < e_pos); |
| 134 } | 170 } |
| 135 | 171 |
| 136 SelectionState InlineTextBox::GetSelectionState() const { | 172 SelectionState InlineTextBox::GetSelectionState() const { |
| 137 SelectionState state = GetLineLayoutItem().GetSelectionState(); | 173 SelectionState state = GetLineLayoutItem().GetSelectionState(); |
| (...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 for (; printed_characters < kLayoutObjectCharacterOffset; | 758 for (; printed_characters < kLayoutObjectCharacterOffset; |
| 723 printed_characters++) | 759 printed_characters++) |
| 724 fputc(' ', stderr); | 760 fputc(' ', stderr); |
| 725 fprintf(stderr, "(%d,%d) \"%s\"\n", Start(), Start() + Len(), | 761 fprintf(stderr, "(%d,%d) \"%s\"\n", Start(), Start() + Len(), |
| 726 value.Utf8().data()); | 762 value.Utf8().data()); |
| 727 } | 763 } |
| 728 | 764 |
| 729 #endif | 765 #endif |
| 730 | 766 |
| 731 } // namespace blink | 767 } // namespace blink |
| OLD | NEW |