OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * Copyright (C) 2011 Apple Inc. All rights reserved. | 3 * Copyright (C) 2011 Apple Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 30 matching lines...) Expand all Loading... |
41 const ComputedStyle&) const { | 41 const ComputedStyle&) const { |
42 return child->isInline(); | 42 return child->isInline(); |
43 } | 43 } |
44 | 44 |
45 ETextAlign LayoutRubyText::textAlignmentForLine(bool endsWithSoftBreak) const { | 45 ETextAlign LayoutRubyText::textAlignmentForLine(bool endsWithSoftBreak) const { |
46 ETextAlign textAlign = style()->textAlign(); | 46 ETextAlign textAlign = style()->textAlign(); |
47 // FIXME: This check is bogus since user can set the initial value. | 47 // FIXME: This check is bogus since user can set the initial value. |
48 if (textAlign != ComputedStyle::initialTextAlign()) | 48 if (textAlign != ComputedStyle::initialTextAlign()) |
49 return LayoutBlockFlow::textAlignmentForLine(endsWithSoftBreak); | 49 return LayoutBlockFlow::textAlignmentForLine(endsWithSoftBreak); |
50 | 50 |
51 // The default behavior is to allow ruby text to expand if it is shorter than
the ruby base. | 51 // The default behavior is to allow ruby text to expand if it is shorter than |
| 52 // the ruby base. |
52 return JUSTIFY; | 53 return JUSTIFY; |
53 } | 54 } |
54 | 55 |
55 void LayoutRubyText::adjustInlineDirectionLineBounds( | 56 void LayoutRubyText::adjustInlineDirectionLineBounds( |
56 unsigned expansionOpportunityCount, | 57 unsigned expansionOpportunityCount, |
57 LayoutUnit& logicalLeft, | 58 LayoutUnit& logicalLeft, |
58 LayoutUnit& logicalWidth) const { | 59 LayoutUnit& logicalWidth) const { |
59 ETextAlign textAlign = style()->textAlign(); | 60 ETextAlign textAlign = style()->textAlign(); |
60 // FIXME: This check is bogus since user can set the initial value. | 61 // FIXME: This check is bogus since user can set the initial value. |
61 if (textAlign != ComputedStyle::initialTextAlign()) | 62 if (textAlign != ComputedStyle::initialTextAlign()) |
62 return LayoutBlockFlow::adjustInlineDirectionLineBounds( | 63 return LayoutBlockFlow::adjustInlineDirectionLineBounds( |
63 expansionOpportunityCount, logicalLeft, logicalWidth); | 64 expansionOpportunityCount, logicalLeft, logicalWidth); |
64 | 65 |
65 int maxPreferredLogicalWidth = this->maxPreferredLogicalWidth().toInt(); | 66 int maxPreferredLogicalWidth = this->maxPreferredLogicalWidth().toInt(); |
66 if (maxPreferredLogicalWidth >= logicalWidth) | 67 if (maxPreferredLogicalWidth >= logicalWidth) |
67 return; | 68 return; |
68 | 69 |
69 // Inset the ruby text by half the inter-ideograph expansion amount, but no mo
re than a full-width | 70 // Inset the ruby text by half the inter-ideograph expansion amount, but no |
70 // ruby character on each side. | 71 // more than a full-width ruby character on each side. |
71 LayoutUnit inset = (logicalWidth - maxPreferredLogicalWidth) / | 72 LayoutUnit inset = (logicalWidth - maxPreferredLogicalWidth) / |
72 (expansionOpportunityCount + 1); | 73 (expansionOpportunityCount + 1); |
73 if (expansionOpportunityCount) | 74 if (expansionOpportunityCount) |
74 inset = std::min(LayoutUnit(2 * style()->fontSize()), inset); | 75 inset = std::min(LayoutUnit(2 * style()->fontSize()), inset); |
75 | 76 |
76 logicalLeft += inset / 2; | 77 logicalLeft += inset / 2; |
77 logicalWidth -= inset; | 78 logicalWidth -= inset; |
78 } | 79 } |
79 | 80 |
80 bool LayoutRubyText::avoidsFloats() const { | 81 bool LayoutRubyText::avoidsFloats() const { |
81 return true; | 82 return true; |
82 } | 83 } |
83 | 84 |
84 } // namespace blink | 85 } // namespace blink |
OLD | NEW |