Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org> |
| 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 |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU Library General Public License | 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 | 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, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
| 18 */ | 18 */ |
| 19 | 19 |
| 20 #ifndef SVGFontData_h | 20 #ifndef SVGFontData_h |
| 21 #define SVGFontData_h | 21 #define SVGFontData_h |
| 22 | 22 |
| 23 #if ENABLE(SVG_FONTS) | 23 #if ENABLE(SVG_FONTS) |
| 24 #include "platform/fonts/CustomFontData.h" | 24 #include "platform/fonts/CustomFontData.h" |
| 25 #include "wtf/WeakPtr.h" | |
| 25 #include "wtf/text/WTFString.h" | 26 #include "wtf/text/WTFString.h" |
| 26 | 27 |
| 27 namespace WebCore { | 28 namespace WebCore { |
| 28 | 29 |
| 29 class SimpleFontData; | 30 class SimpleFontData; |
| 30 class SVGFontElement; | 31 class SVGFontElement; |
| 31 class SVGFontFaceElement; | 32 class SVGFontFaceElement; |
| 32 | 33 |
| 33 class SVGFontData FINAL : public CustomFontData { | 34 class SVGFontData FINAL : public CustomFontData { |
| 34 public: | 35 public: |
| 35 static PassRefPtr<SVGFontData> create(SVGFontFaceElement* element) | 36 static PassRefPtr<SVGFontData> create(SVGFontFaceElement* element) |
| 36 { | 37 { |
| 37 return adoptRef(new SVGFontData(element)); | 38 return adoptRef(new SVGFontData(element)); |
| 38 } | 39 } |
| 39 | 40 |
| 40 virtual ~SVGFontData() { } | 41 virtual ~SVGFontData(); |
| 41 | 42 |
| 42 virtual bool isSVGFont() const OVERRIDE { return true; }; | 43 virtual bool isSVGFont() const OVERRIDE { return true; }; |
| 43 virtual void initializeFontData(SimpleFontData*, float fontSize) OVERRIDE; | 44 virtual void initializeFontData(SimpleFontData*, float fontSize) OVERRIDE; |
| 44 virtual float widthForSVGGlyph(Glyph, float fontSize) const OVERRIDE; | 45 virtual float widthForSVGGlyph(Glyph, float fontSize) const OVERRIDE; |
| 45 virtual bool fillSVGGlyphPage(GlyphPage*, unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength, const SimpleFontData*) const OVERRIDE; | 46 virtual bool fillSVGGlyphPage(GlyphPage*, unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength, const SimpleFontData*) const OVERRIDE; |
| 46 virtual bool applySVGGlyphSelection(WidthIterator&, GlyphData&, bool mirror, int currentCharacter, unsigned& advanceLength) const OVERRIDE; | 47 virtual bool applySVGGlyphSelection(WidthIterator&, GlyphData&, bool mirror, int currentCharacter, unsigned& advanceLength) const OVERRIDE; |
| 47 | 48 |
| 48 | 49 |
| 49 SVGFontFaceElement* svgFontFaceElement() const { return m_svgFontFaceElement ; } | 50 SVGFontFaceElement* svgFontFaceElement() const { return m_svgFontFaceElement .get(); } |
|
Kunihiko Sakamoto
2014/04/01 04:44:14
Maybe RELEASE_ASSERT in this method? A couple of c
kouhei (in TOK)
2014/04/03 01:57:18
Done.
| |
| 50 | 51 |
| 51 float horizontalOriginX() const { return m_horizontalOriginX; } | 52 float horizontalOriginX() const { return m_horizontalOriginX; } |
| 52 float horizontalOriginY() const { return m_horizontalOriginY; } | 53 float horizontalOriginY() const { return m_horizontalOriginY; } |
| 53 float horizontalAdvanceX() const { return m_horizontalAdvanceX; } | 54 float horizontalAdvanceX() const { return m_horizontalAdvanceX; } |
| 54 | 55 |
| 55 float verticalOriginX() const { return m_verticalOriginX; } | 56 float verticalOriginX() const { return m_verticalOriginX; } |
| 56 float verticalOriginY() const { return m_verticalOriginY; } | 57 float verticalOriginY() const { return m_verticalOriginY; } |
| 57 float verticalAdvanceY() const { return m_verticalAdvanceY; } | 58 float verticalAdvanceY() const { return m_verticalAdvanceY; } |
| 58 | 59 |
| 59 private: | 60 private: |
| 60 SVGFontData(SVGFontFaceElement*); | 61 SVGFontData(SVGFontFaceElement*); |
| 61 | 62 |
| 62 bool fillBMPGlyphs(SVGFontElement*, GlyphPage* , unsigned offset, unsigned l ength, UChar* buffer, const SimpleFontData*) const; | 63 bool fillBMPGlyphs(SVGFontElement*, GlyphPage* , unsigned offset, unsigned l ength, UChar* buffer, const SimpleFontData*) const; |
| 63 bool fillNonBMPGlyphs(SVGFontElement*, GlyphPage* , unsigned offset, unsigne d length, UChar* buffer, const SimpleFontData*) const; | 64 bool fillNonBMPGlyphs(SVGFontElement*, GlyphPage* , unsigned offset, unsigne d length, UChar* buffer, const SimpleFontData*) const; |
| 64 | 65 |
| 65 String createStringWithMirroredCharacters(const String&) const; | 66 String createStringWithMirroredCharacters(const String&) const; |
| 66 | 67 |
| 67 // Ths SVGFontFaceElement is kept alive -- | 68 // Ths SVGFontFaceElement is kept alive -- |
| 68 // 1) in the external font case: by the CSSFontFaceSource, which holds a ref erence to the external SVG document | 69 // 1) in the external font case: by the CSSFontFaceSource, which holds a ref erence to the external SVG document |
| 69 // containing the element; | 70 // containing the element; |
| 70 // 2) in the in-document font case: by virtue of being in the document tree and making sure that when it is removed | 71 // 2) in the in-document font case: by virtue of being in the document tree and making sure that when it is removed |
| 71 // from the document, it removes the @font-face rule it owns from the doc ument's mapped element sheet and forces | 72 // from the document, it removes the @font-face rule it owns from the doc ument's mapped element sheet and forces |
| 72 // a style update. | 73 // a style update. |
| 73 SVGFontFaceElement* m_svgFontFaceElement; | 74 WeakPtr<SVGFontFaceElement> m_svgFontFaceElement; |
| 74 | 75 |
| 75 float m_horizontalOriginX; | 76 float m_horizontalOriginX; |
| 76 float m_horizontalOriginY; | 77 float m_horizontalOriginY; |
| 77 float m_horizontalAdvanceX; | 78 float m_horizontalAdvanceX; |
| 78 | 79 |
| 79 float m_verticalOriginX; | 80 float m_verticalOriginX; |
| 80 float m_verticalOriginY; | 81 float m_verticalOriginY; |
| 81 float m_verticalAdvanceY; | 82 float m_verticalAdvanceY; |
| 82 }; | 83 }; |
| 83 | 84 |
| 84 } // namespace WebCore | 85 } // namespace WebCore |
| 85 | 86 |
| 86 #endif | 87 #endif |
| 87 #endif // SVGFontData_h | 88 #endif // SVGFontData_h |
| OLD | NEW |