| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 { | 53 { |
| 54 ETextAlign textAlign = style()->textAlign(); | 54 ETextAlign textAlign = style()->textAlign(); |
| 55 // FIXME: This check is bogus since user can set the initial value. | 55 // FIXME: This check is bogus since user can set the initial value. |
| 56 if (textAlign != ComputedStyle::initialTextAlign()) | 56 if (textAlign != ComputedStyle::initialTextAlign()) |
| 57 return LayoutBlockFlow::textAlignmentForLine(endsWithSoftBreak); | 57 return LayoutBlockFlow::textAlignmentForLine(endsWithSoftBreak); |
| 58 | 58 |
| 59 // The default behavior is to allow ruby text to expand if it is shorter tha
n the ruby base. | 59 // The default behavior is to allow ruby text to expand if it is shorter tha
n the ruby base. |
| 60 return JUSTIFY; | 60 return JUSTIFY; |
| 61 } | 61 } |
| 62 | 62 |
| 63 void LayoutRubyText::adjustInlineDirectionLineBounds(unsigned expansionOpportuni
tyCount, float& logicalLeft, float& logicalWidth) const | 63 void LayoutRubyText::adjustInlineDirectionLineBounds(unsigned expansionOpportuni
tyCount, LayoutUnit& logicalLeft, LayoutUnit& logicalWidth) const |
| 64 { | 64 { |
| 65 ETextAlign textAlign = style()->textAlign(); | 65 ETextAlign textAlign = style()->textAlign(); |
| 66 // FIXME: This check is bogus since user can set the initial value. | 66 // FIXME: This check is bogus since user can set the initial value. |
| 67 if (textAlign != ComputedStyle::initialTextAlign()) | 67 if (textAlign != ComputedStyle::initialTextAlign()) |
| 68 return LayoutBlockFlow::adjustInlineDirectionLineBounds(expansionOpportu
nityCount, logicalLeft, logicalWidth); | 68 return LayoutBlockFlow::adjustInlineDirectionLineBounds(expansionOpportu
nityCount, logicalLeft, logicalWidth); |
| 69 | 69 |
| 70 int maxPreferredLogicalWidth = this->maxPreferredLogicalWidth(); | 70 int maxPreferredLogicalWidth = this->maxPreferredLogicalWidth(); |
| 71 if (maxPreferredLogicalWidth >= logicalWidth) | 71 if (maxPreferredLogicalWidth >= logicalWidth) |
| 72 return; | 72 return; |
| 73 | 73 |
| 74 // Inset the ruby text by half the inter-ideograph expansion amount, but no
more than a full-width | 74 // Inset the ruby text by half the inter-ideograph expansion amount, but no
more than a full-width |
| 75 // ruby character on each side. | 75 // ruby character on each side. |
| 76 float inset = (logicalWidth - maxPreferredLogicalWidth) / (expansionOpportun
ityCount + 1); | 76 LayoutUnit inset = (logicalWidth - maxPreferredLogicalWidth) / (expansionOpp
ortunityCount + 1); |
| 77 if (expansionOpportunityCount) | 77 if (expansionOpportunityCount) |
| 78 inset = std::min<float>(2 * style()->fontSize(), inset); | 78 inset = std::min(LayoutUnit(2 * style()->fontSize()), inset); |
| 79 | 79 |
| 80 logicalLeft += inset / 2; | 80 logicalLeft += inset / 2; |
| 81 logicalWidth -= inset; | 81 logicalWidth -= inset; |
| 82 } | 82 } |
| 83 | 83 |
| 84 bool LayoutRubyText::avoidsFloats() const | 84 bool LayoutRubyText::avoidsFloats() const |
| 85 { | 85 { |
| 86 return true; | 86 return true; |
| 87 } | 87 } |
| 88 | 88 |
| 89 } // namespace blink | 89 } // namespace blink |
| OLD | NEW |