Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) Research In Motion Limited 2010-2012. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2010-2012. All rights reserved. |
| 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 SVGTextMetrics_h | 20 #ifndef SVGTextMetrics_h |
| 21 #define SVGTextMetrics_h | 21 #define SVGTextMetrics_h |
| 22 | 22 |
| 23 #include "platform/text/TextDirection.h" | 23 #include "platform/text/TextDirection.h" |
| 24 #include "wtf/Vector.h" | |
| 24 | 25 |
| 25 namespace blink { | 26 namespace blink { |
| 26 | 27 |
| 27 class LayoutSVGInlineText; | 28 class LayoutSVGInlineText; |
| 28 class TextRun; | 29 class TextRun; |
| 29 | 30 |
| 30 class SVGTextMetrics { | 31 class SVGTextMetrics { |
| 31 public: | 32 public: |
| 32 enum MetricsType { | 33 enum MetricsType { |
| 33 SkippedSpaceMetrics | 34 SkippedSpaceMetrics |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 49 unsigned length() const { return m_length; } | 50 unsigned length() const { return m_length; } |
| 50 | 51 |
| 51 private: | 52 private: |
| 52 SVGTextMetrics(LayoutSVGInlineText*, const TextRun&); | 53 SVGTextMetrics(LayoutSVGInlineText*, const TextRun&); |
| 53 | 54 |
| 54 float m_width; | 55 float m_width; |
| 55 float m_height; | 56 float m_height; |
| 56 unsigned m_length; | 57 unsigned m_length; |
| 57 }; | 58 }; |
| 58 | 59 |
| 60 class SVGTextMetricsIterator { | |
|
f(malita)
2015/05/27 01:53:49
nit: can this be a private nested class in SVGText
fs
2015/05/27 12:53:14
I have other possible uses in mind for this (SVGTe
| |
| 61 public: | |
| 62 SVGTextMetricsIterator() { reset(nullptr); } | |
| 63 | |
| 64 void reset(const Vector<SVGTextMetrics>* metricsList) | |
|
pdr.
2015/05/27 03:11:18
I think this can be an internal detail of the iter
fs
2015/05/27 12:53:13
I wanted to keep the interface of the iterator fai
| |
| 65 { | |
| 66 m_metricsList = metricsList; | |
| 67 m_characterOffset = 0; | |
| 68 m_metricsListOffset = 0; | |
| 69 } | |
| 70 | |
| 71 void next() | |
| 72 { | |
| 73 m_characterOffset += metrics().length(); | |
| 74 ++m_metricsListOffset; | |
| 75 } | |
| 76 | |
| 77 const SVGTextMetrics& metrics() const { return metricsList()[m_metricsListOf fset]; } | |
|
f(malita)
2015/05/27 01:53:49
nit: ASSERT(m_metricsList && m_metricsListOffset <
fs
2015/05/27 12:53:14
I've sort of been relying on the RELEASE_ASSERT in
| |
| 78 const Vector<SVGTextMetrics>& metricsList() const { return *m_metricsList; } | |
| 79 unsigned metricsListOffset() const { return m_metricsListOffset; } | |
| 80 unsigned characterOffset() const { return m_characterOffset; } | |
| 81 | |
| 82 private: | |
| 83 const Vector<SVGTextMetrics>* m_metricsList; | |
| 84 unsigned m_metricsListOffset; | |
| 85 unsigned m_characterOffset; | |
| 86 }; | |
| 87 | |
| 59 } // namespace blink | 88 } // namespace blink |
| 60 | 89 |
| 61 #endif | 90 #endif |
| OLD | NEW |