Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(448)

Unified Diff: third_party/WebKit/Source/core/layout/api/LineLayoutSVGInlineText.h

Issue 1411123014: [Line Layout API] Convert SVGTextLayoutEngine and SVGTextLayoutEngineBaseline to line Layout API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/api/LineLayoutText.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/api/LineLayoutSVGInlineText.h
diff --git a/third_party/WebKit/Source/core/layout/api/LineLayoutSVGInlineText.h b/third_party/WebKit/Source/core/layout/api/LineLayoutSVGInlineText.h
index d979bc80d05fd30e00471759f44ffb2a7b1e74c2..204cd21b143c7f892db0f50e6f06d18fb35f709c 100644
--- a/third_party/WebKit/Source/core/layout/api/LineLayoutSVGInlineText.h
+++ b/third_party/WebKit/Source/core/layout/api/LineLayoutSVGInlineText.h
@@ -58,6 +58,59 @@ private:
}
};
+class SVGInlineTextMetricsIterator {
+ DISALLOW_NEW();
+public:
+ SVGInlineTextMetricsIterator() { reset(nullptr); }
+
+ void advanceToTextStart(LineLayoutSVGInlineText* textLineLayout, unsigned startCharacterOffset)
+ {
+ ASSERT(textLineLayout);
+ if (m_textLineLayout != textLineLayout) {
+ reset(textLineLayout);
+ ASSERT(!metricsList().isEmpty());
+ }
+
+ if (m_characterOffset == startCharacterOffset)
+ return;
+
+ // TODO(fs): We could walk backwards through the metrics list in these cases.
+ if (m_characterOffset > startCharacterOffset)
+ reset(textLineLayout);
+
+ while (m_characterOffset < startCharacterOffset)
+ next();
+ }
+
+ void next()
+ {
+ m_characterOffset += metrics().length();
+ ++m_metricsListOffset;
+ }
+
+ const SVGTextMetrics& metrics() const
+ {
+ ASSERT(m_textLineLayout && m_metricsListOffset < metricsList().size());
+ return metricsList()[m_metricsListOffset];
+ }
+ const Vector<SVGTextMetrics>& metricsList() const { return m_textLineLayout->layoutAttributes()->textMetricsValues(); }
+ unsigned metricsListOffset() const { return m_metricsListOffset; }
+ unsigned characterOffset() const { return m_characterOffset; }
+ bool isAtEnd() const { return m_metricsListOffset == metricsList().size(); }
+
+private:
+ void reset(LineLayoutSVGInlineText* textLineLayout)
+ {
+ m_textLineLayout = textLineLayout;
+ m_characterOffset = 0;
+ m_metricsListOffset = 0;
+ }
+
+ LineLayoutSVGInlineText* m_textLineLayout;
+ unsigned m_metricsListOffset;
+ unsigned m_characterOffset;
+};
+
} // namespace blink
#endif // LineLayoutSVGInlineText_h
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/api/LineLayoutText.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698