OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz> | 2 * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz> |
3 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. | 3 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. |
4 * Copyright (C) 2008 Rob Buis <buis@kde.org> | 4 * Copyright (C) 2008 Rob Buis <buis@kde.org> |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 | 62 |
63 LayoutRect clippedOverflowRectForPaintInvalidation(const LayoutBoxModelObjec
t* paintInvalidationContainer, const PaintInvalidationState*) const final; | 63 LayoutRect clippedOverflowRectForPaintInvalidation(const LayoutBoxModelObjec
t* paintInvalidationContainer, const PaintInvalidationState*) const final; |
64 | 64 |
65 float m_scalingFactor; | 65 float m_scalingFactor; |
66 Font m_scaledFont; | 66 Font m_scaledFont; |
67 SVGTextLayoutAttributes m_layoutAttributes; | 67 SVGTextLayoutAttributes m_layoutAttributes; |
68 }; | 68 }; |
69 | 69 |
70 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutSVGInlineText, isSVGInlineText()); | 70 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutSVGInlineText, isSVGInlineText()); |
71 | 71 |
72 class SVGInlineTextMetricsIterator { | |
73 DISALLOW_NEW(); | |
74 public: | |
75 SVGInlineTextMetricsIterator() { reset(nullptr); } | |
76 | |
77 void advanceToTextStart(const LayoutSVGInlineText* textLayoutObject, unsigne
d startCharacterOffset) | |
78 { | |
79 ASSERT(textLayoutObject); | |
80 if (m_textLayoutObject != textLayoutObject) { | |
81 reset(textLayoutObject); | |
82 ASSERT(!metricsList().isEmpty()); | |
83 } | |
84 | |
85 if (m_characterOffset == startCharacterOffset) | |
86 return; | |
87 | |
88 // TODO(fs): We could walk backwards through the metrics list in these c
ases. | |
89 if (m_characterOffset > startCharacterOffset) | |
90 reset(textLayoutObject); | |
91 | |
92 while (m_characterOffset < startCharacterOffset) | |
93 next(); | |
94 } | |
95 | |
96 void next() | |
97 { | |
98 m_characterOffset += metrics().length(); | |
99 ++m_metricsListOffset; | |
100 } | |
101 | |
102 const SVGTextMetrics& metrics() const | |
103 { | |
104 ASSERT(m_textLayoutObject && m_metricsListOffset < metricsList().size())
; | |
105 return metricsList()[m_metricsListOffset]; | |
106 } | |
107 const Vector<SVGTextMetrics>& metricsList() const { return m_textLayoutObjec
t->layoutAttributes()->textMetricsValues(); } | |
108 unsigned metricsListOffset() const { return m_metricsListOffset; } | |
109 unsigned characterOffset() const { return m_characterOffset; } | |
110 bool isAtEnd() const { return m_metricsListOffset == metricsList().size(); } | |
111 | |
112 private: | |
113 void reset(const LayoutSVGInlineText* textLayoutObject) | |
114 { | |
115 m_textLayoutObject = textLayoutObject; | |
116 m_characterOffset = 0; | |
117 m_metricsListOffset = 0; | |
118 } | |
119 | |
120 const LayoutSVGInlineText* m_textLayoutObject; | |
121 unsigned m_metricsListOffset; | |
122 unsigned m_characterOffset; | |
123 }; | |
124 | |
125 } | 72 } |
126 | 73 |
127 #endif // LayoutSVGInlineText_h | 74 #endif // LayoutSVGInlineText_h |
OLD | NEW |