| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 updateIsCombined(); | 45 updateIsCombined(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 void LayoutTextCombine::setTextInternal(PassRefPtr<StringImpl> text) | 48 void LayoutTextCombine::setTextInternal(PassRefPtr<StringImpl> text) |
| 49 { | 49 { |
| 50 LayoutText::setTextInternal(text); | 50 LayoutText::setTextInternal(text); |
| 51 | 51 |
| 52 updateIsCombined(); | 52 updateIsCombined(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 float LayoutTextCombine::width(unsigned from, unsigned length, const Font& font,
float xPosition, TextDirection direction, HashSet<const SimpleFontData*>* fallb
ackFonts, GlyphOverflow* glyphOverflow) const | 55 float LayoutTextCombine::width(unsigned from, unsigned length, const Font& font,
LayoutUnit xPosition, TextDirection direction, HashSet<const SimpleFontData*>*
fallbackFonts, GlyphOverflow* glyphOverflow) const |
| 56 { | 56 { |
| 57 if (!length) | 57 if (!length) |
| 58 return 0; | 58 return 0; |
| 59 | 59 |
| 60 if (hasEmptyText()) | 60 if (hasEmptyText()) |
| 61 return 0; | 61 return 0; |
| 62 | 62 |
| 63 if (m_isCombined) | 63 if (m_isCombined) |
| 64 return font.fontDescription().computedSize(); | 64 return font.fontDescription().computedSize(); |
| 65 | 65 |
| 66 return LayoutText::width(from, length, font, xPosition, direction, fallbackF
onts, glyphOverflow); | 66 return LayoutText::width(from, length, font, xPosition, direction, fallbackF
onts, glyphOverflow); |
| 67 } | 67 } |
| 68 | 68 |
| 69 void scaleHorizontallyAndTranslate(GraphicsContext& context, float scaleX, float
centerX, float offsetX, float offsetY) | 69 void scaleHorizontallyAndTranslate(GraphicsContext& context, float scaleX, float
centerX, float offsetX, float offsetY) |
| 70 { | 70 { |
| 71 context.concatCTM(AffineTransform(scaleX, 0, 0, 1, centerX * (1.0f - scaleX)
+ offsetX * scaleX, offsetY)); | 71 context.concatCTM(AffineTransform(scaleX, 0, 0, 1, centerX * (1.0f - scaleX)
+ offsetX * scaleX, offsetY)); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void LayoutTextCombine::transformToInlineCoordinates(GraphicsContext& context, c
onst FloatRect& boxRect) const | 74 void LayoutTextCombine::transformToInlineCoordinates(GraphicsContext& context, c
onst LayoutRect& boxRect) const |
| 75 { | 75 { |
| 76 ASSERT(!m_needsFontUpdate); | 76 ASSERT(!m_needsFontUpdate); |
| 77 ASSERT(m_isCombined); | 77 ASSERT(m_isCombined); |
| 78 if (m_scaleX >= 1.0f) { | 78 if (m_scaleX >= 1.0f) { |
| 79 // Fast path, more than 90% of cases | 79 // Fast path, more than 90% of cases |
| 80 ASSERT(m_scaleX == 1.0f); | 80 ASSERT(m_scaleX == 1.0f); |
| 81 context.concatCTM(AffineTransform::translation(offsetXNoScale(boxRect),
0)); | 81 context.concatCTM(AffineTransform::translation(offsetXNoScale(boxRect),
0)); |
| 82 return; | 82 return; |
| 83 } | 83 } |
| 84 ASSERT(m_scaleX > 0.0f); | 84 ASSERT(m_scaleX > 0.0f); |
| 85 const float centerX = boxRect.x() + boxRect.width() / 2; | 85 float centerX = boxRect.x() + boxRect.width().toFloat() / 2; |
| 86 scaleHorizontallyAndTranslate(context, m_scaleX, centerX, offsetX(boxRect),
0); | 86 scaleHorizontallyAndTranslate(context, m_scaleX, centerX, offsetX(boxRect),
0); |
| 87 } | 87 } |
| 88 | 88 |
| 89 void LayoutTextCombine::transformLayoutRect(FloatRect& boxRect) const | 89 void LayoutTextCombine::transformLayoutRect(LayoutRect& boxRect) const |
| 90 { | 90 { |
| 91 ASSERT(!m_needsFontUpdate); | 91 ASSERT(!m_needsFontUpdate); |
| 92 ASSERT(m_isCombined); | 92 ASSERT(m_isCombined); |
| 93 boxRect.move(offsetXNoScale(boxRect), 0); | 93 boxRect.move(offsetXNoScale(boxRect), 0); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void LayoutTextCombine::updateIsCombined() | 96 void LayoutTextCombine::updateIsCombined() |
| 97 { | 97 { |
| 98 // CSS3 spec says text-combine works only in vertical writing mode. | 98 // CSS3 spec says text-combine works only in vertical writing mode. |
| 99 m_isCombined = !style()->isHorizontalWritingMode() | 99 m_isCombined = !style()->isHorizontalWritingMode() |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 } else { | 154 } else { |
| 155 m_scaleX = 1.0f; | 155 m_scaleX = 1.0f; |
| 156 } | 156 } |
| 157 } | 157 } |
| 158 | 158 |
| 159 if (shouldUpdateFont) | 159 if (shouldUpdateFont) |
| 160 style()->font().update(fontSelector); | 160 style()->font().update(fontSelector); |
| 161 } | 161 } |
| 162 | 162 |
| 163 } // namespace blink | 163 } // namespace blink |
| OLD | NEW |