| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2011 Apple Inc. All rights reserved. | |
| 3 * | |
| 4 * This library is free software; you can redistribute it and/or | |
| 5 * modify it under the terms of the GNU Library General Public | |
| 6 * License as published by the Free Software Foundation; either | |
| 7 * version 2 of the License, or (at your option) any later version. | |
| 8 * | |
| 9 * This library is distributed in the hope that it will be useful, | |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 12 * Library General Public License for more details. | |
| 13 * | |
| 14 * You should have received a copy of the GNU Library General Public License | |
| 15 * along with this library; see the file COPYING.LIB. If not, write to | |
| 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
| 17 * Boston, MA 02110-1301, USA. | |
| 18 * | |
| 19 */ | |
| 20 | |
| 21 #ifndef RenderCombineText_h | |
| 22 #define RenderCombineText_h | |
| 23 | |
| 24 #include "core/rendering/RenderText.h" | |
| 25 #include "platform/fonts/Font.h" | |
| 26 | |
| 27 namespace blink { | |
| 28 | |
| 29 // RenderCombineText uses different coordinate systems for layout and inlineText
Box, | |
| 30 // because it is treated as 1em-box character in vertical flow for the layout, | |
| 31 // while its inline box is in horizontal flow. | |
| 32 class RenderCombineText final : public RenderText { | |
| 33 public: | |
| 34 RenderCombineText(Node*, PassRefPtr<StringImpl>); | |
| 35 | |
| 36 void updateFont(); | |
| 37 bool isCombined() const { return m_isCombined; } | |
| 38 float combinedTextWidth(const Font& font) const { return font.fontDescriptio
n().computedSize(); } | |
| 39 const Font& originalFont() const { return parent()->style()->font(); } | |
| 40 void transformToInlineCoordinates(GraphicsContext&, const FloatRect& boxRect
) const; | |
| 41 void transformLayoutRect(FloatRect& boxRect) const; | |
| 42 float inlineWidthForLayout() const; | |
| 43 | |
| 44 private: | |
| 45 virtual bool isCombineText() const override { return true; } | |
| 46 virtual float width(unsigned from, unsigned length, const Font&, float xPosi
tion, TextDirection, HashSet<const SimpleFontData*>* fallbackFonts = 0, GlyphOve
rflow* = 0) const override; | |
| 47 virtual const char* renderName() const override { return "RenderCombineText"
; } | |
| 48 virtual void styleDidChange(StyleDifference, const LayoutStyle* oldStyle) ov
erride; | |
| 49 virtual void setTextInternal(PassRefPtr<StringImpl>) override; | |
| 50 void updateIsCombined(); | |
| 51 | |
| 52 float offsetX(const FloatRect& boxRect) const; | |
| 53 float offsetXNoScale(const FloatRect& boxRect) const; | |
| 54 float offsetY() const { return style()->font().fontDescription().computedPix
elSize(); } | |
| 55 | |
| 56 float m_combinedTextWidth; | |
| 57 float m_scaleX; | |
| 58 bool m_isCombined : 1; | |
| 59 bool m_needsFontUpdate : 1; | |
| 60 }; | |
| 61 | |
| 62 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(RenderCombineText, isCombineText()); | |
| 63 | |
| 64 inline float RenderCombineText::inlineWidthForLayout() const | |
| 65 { | |
| 66 ASSERT(!m_needsFontUpdate); | |
| 67 return m_combinedTextWidth; | |
| 68 } | |
| 69 | |
| 70 inline float RenderCombineText::offsetX(const FloatRect& boxRect) const | |
| 71 { | |
| 72 ASSERT(!m_needsFontUpdate); | |
| 73 return (boxRect.height() - m_combinedTextWidth / m_scaleX) / 2; | |
| 74 } | |
| 75 | |
| 76 inline float RenderCombineText::offsetXNoScale(const FloatRect& boxRect) const | |
| 77 { | |
| 78 ASSERT(!m_needsFontUpdate); | |
| 79 return (boxRect.height() - m_combinedTextWidth) / 2; | |
| 80 } | |
| 81 | |
| 82 | |
| 83 } // namespace blink | |
| 84 | |
| 85 #endif // RenderCombineText_h | |
| OLD | NEW |