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 virtual LayoutRect clippedOverflowRectForPaintInvalidation(const LayoutBoxMo
delObject* paintInvalidationContainer, const PaintInvalidationState*) const over
ride final; | 63 virtual LayoutRect clippedOverflowRectForPaintInvalidation(const LayoutBoxMo
delObject* paintInvalidationContainer, const PaintInvalidationState*) const over
ride 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 public: |
| 74 SVGInlineTextMetricsIterator() { reset(nullptr); } |
| 75 |
| 76 void advanceToTextStart(const LayoutSVGInlineText* textLayoutObject, unsigne
d startCharacterOffset) |
| 77 { |
| 78 ASSERT(textLayoutObject); |
| 79 if (m_textLayoutObject != textLayoutObject) { |
| 80 reset(textLayoutObject); |
| 81 ASSERT(!metricsList().isEmpty()); |
| 82 } |
| 83 |
| 84 if (m_characterOffset == startCharacterOffset) |
| 85 return; |
| 86 |
| 87 // TODO(fs): We could walk backwards through the metrics list in these c
ases. |
| 88 if (m_characterOffset > startCharacterOffset) |
| 89 reset(textLayoutObject); |
| 90 |
| 91 while (m_characterOffset < startCharacterOffset) |
| 92 next(); |
| 93 } |
| 94 |
| 95 void next() |
| 96 { |
| 97 m_characterOffset += metrics().length(); |
| 98 ++m_metricsListOffset; |
| 99 } |
| 100 |
| 101 const SVGTextMetrics& metrics() const |
| 102 { |
| 103 ASSERT(m_textLayoutObject && m_metricsListOffset < metricsList().size())
; |
| 104 return metricsList()[m_metricsListOffset]; |
| 105 } |
| 106 const Vector<SVGTextMetrics>& metricsList() const { return m_textLayoutObjec
t->layoutAttributes()->textMetricsValues(); } |
| 107 unsigned metricsListOffset() const { return m_metricsListOffset; } |
| 108 unsigned characterOffset() const { return m_characterOffset; } |
| 109 |
| 110 private: |
| 111 void reset(const LayoutSVGInlineText* textLayoutObject) |
| 112 { |
| 113 m_textLayoutObject = textLayoutObject; |
| 114 m_characterOffset = 0; |
| 115 m_metricsListOffset = 0; |
| 116 } |
| 117 |
| 118 const LayoutSVGInlineText* m_textLayoutObject; |
| 119 unsigned m_metricsListOffset; |
| 120 unsigned m_characterOffset; |
| 121 }; |
| 122 |
72 } | 123 } |
73 | 124 |
74 #endif // LayoutSVGInlineText_h | 125 #endif // LayoutSVGInlineText_h |
OLD | NEW |