| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef LineLayoutSVGInlineText_h | 5 #ifndef LineLayoutSVGInlineText_h |
| 6 #define LineLayoutSVGInlineText_h | 6 #define LineLayoutSVGInlineText_h |
| 7 | 7 |
| 8 #include "core/layout/api/LineLayoutText.h" | 8 #include "core/layout/api/LineLayoutText.h" |
| 9 #include "core/layout/svg/LayoutSVGInlineText.h" | 9 #include "core/layout/svg/LayoutSVGInlineText.h" |
| 10 | 10 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 | 55 |
| 56 public: | 56 public: |
| 57 SVGInlineTextMetricsIterator() { reset(LineLayoutSVGInlineText()); } | 57 SVGInlineTextMetricsIterator() { reset(LineLayoutSVGInlineText()); } |
| 58 explicit SVGInlineTextMetricsIterator( | 58 explicit SVGInlineTextMetricsIterator( |
| 59 LineLayoutSVGInlineText textLineLayout) { | 59 LineLayoutSVGInlineText textLineLayout) { |
| 60 reset(textLineLayout); | 60 reset(textLineLayout); |
| 61 } | 61 } |
| 62 | 62 |
| 63 void advanceToTextStart(LineLayoutSVGInlineText textLineLayout, | 63 void advanceToTextStart(LineLayoutSVGInlineText textLineLayout, |
| 64 unsigned startCharacterOffset) { | 64 unsigned startCharacterOffset) { |
| 65 ASSERT(textLineLayout); | 65 DCHECK(textLineLayout); |
| 66 if (!m_textLineLayout || m_textLineLayout != textLineLayout) { | 66 if (!m_textLineLayout || m_textLineLayout != textLineLayout) { |
| 67 reset(textLineLayout); | 67 reset(textLineLayout); |
| 68 ASSERT(!metricsList().isEmpty()); | 68 DCHECK(!metricsList().isEmpty()); |
| 69 } | 69 } |
| 70 | 70 |
| 71 if (m_characterOffset == startCharacterOffset) | 71 if (m_characterOffset == startCharacterOffset) |
| 72 return; | 72 return; |
| 73 | 73 |
| 74 // TODO(fs): We could walk backwards through the metrics list in these | 74 // TODO(fs): We could walk backwards through the metrics list in these |
| 75 // cases. | 75 // cases. |
| 76 if (m_characterOffset > startCharacterOffset) | 76 if (m_characterOffset > startCharacterOffset) |
| 77 reset(textLineLayout); | 77 reset(textLineLayout); |
| 78 | 78 |
| 79 while (m_characterOffset < startCharacterOffset) | 79 while (m_characterOffset < startCharacterOffset) |
| 80 next(); | 80 next(); |
| 81 ASSERT(m_characterOffset == startCharacterOffset); | 81 DCHECK_EQ(m_characterOffset, startCharacterOffset); |
| 82 } | 82 } |
| 83 | 83 |
| 84 void next() { | 84 void next() { |
| 85 m_characterOffset += metrics().length(); | 85 m_characterOffset += metrics().length(); |
| 86 ASSERT(m_characterOffset <= m_textLineLayout.length()); | 86 DCHECK_LE(m_characterOffset, m_textLineLayout.length()); |
| 87 ASSERT(m_metricsListOffset < metricsList().size()); | 87 DCHECK_LT(m_metricsListOffset, metricsList().size()); |
| 88 ++m_metricsListOffset; | 88 ++m_metricsListOffset; |
| 89 } | 89 } |
| 90 | 90 |
| 91 const SVGTextMetrics& metrics() const { | 91 const SVGTextMetrics& metrics() const { |
| 92 ASSERT(m_textLineLayout && m_metricsListOffset < metricsList().size()); | 92 DCHECK(m_textLineLayout); |
| 93 DCHECK_LT(m_metricsListOffset, metricsList().size()); |
| 93 return metricsList()[m_metricsListOffset]; | 94 return metricsList()[m_metricsListOffset]; |
| 94 } | 95 } |
| 95 const Vector<SVGTextMetrics>& metricsList() const { | 96 const Vector<SVGTextMetrics>& metricsList() const { |
| 96 return m_textLineLayout.metricsList(); | 97 return m_textLineLayout.metricsList(); |
| 97 } | 98 } |
| 98 unsigned metricsListOffset() const { return m_metricsListOffset; } | 99 unsigned metricsListOffset() const { return m_metricsListOffset; } |
| 99 unsigned characterOffset() const { return m_characterOffset; } | 100 unsigned characterOffset() const { return m_characterOffset; } |
| 100 bool isAtEnd() const { return m_metricsListOffset == metricsList().size(); } | 101 bool isAtEnd() const { return m_metricsListOffset == metricsList().size(); } |
| 101 | 102 |
| 102 private: | 103 private: |
| 103 void reset(LineLayoutSVGInlineText textLineLayout) { | 104 void reset(LineLayoutSVGInlineText textLineLayout) { |
| 104 m_textLineLayout = textLineLayout; | 105 m_textLineLayout = textLineLayout; |
| 105 m_characterOffset = 0; | 106 m_characterOffset = 0; |
| 106 m_metricsListOffset = 0; | 107 m_metricsListOffset = 0; |
| 107 } | 108 } |
| 108 | 109 |
| 109 LineLayoutSVGInlineText m_textLineLayout; | 110 LineLayoutSVGInlineText m_textLineLayout; |
| 110 unsigned m_metricsListOffset; | 111 unsigned m_metricsListOffset; |
| 111 unsigned m_characterOffset; | 112 unsigned m_characterOffset; |
| 112 }; | 113 }; |
| 113 | 114 |
| 114 } // namespace blink | 115 } // namespace blink |
| 115 | 116 |
| 116 #endif // LineLayoutSVGInlineText_h | 117 #endif // LineLayoutSVGInlineText_h |
| OLD | NEW |