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

Side by Side Diff: Source/platform/text/TextRun.h

Issue 652483002: TextRun::length() should return an unsigned (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 6 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Antti Koivisto (koivisto@kde.org) 3 * (C) 2000 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2006, 2007, 2011 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2006, 2007, 2011 Apple Inc. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 } 165 }
166 166
167 UChar operator[](unsigned i) const { ASSERT_WITH_SECURITY_IMPLICATION(i < m_ len); return is8Bit() ? m_data.characters8[i] :m_data.characters16[i]; } 167 UChar operator[](unsigned i) const { ASSERT_WITH_SECURITY_IMPLICATION(i < m_ len); return is8Bit() ? m_data.characters8[i] :m_data.characters16[i]; }
168 const LChar* data8(unsigned i) const { ASSERT_WITH_SECURITY_IMPLICATION(i < m_len); ASSERT(is8Bit()); return &m_data.characters8[i]; } 168 const LChar* data8(unsigned i) const { ASSERT_WITH_SECURITY_IMPLICATION(i < m_len); ASSERT(is8Bit()); return &m_data.characters8[i]; }
169 const UChar* data16(unsigned i) const { ASSERT_WITH_SECURITY_IMPLICATION(i < m_len); ASSERT(!is8Bit()); return &m_data.characters16[i]; } 169 const UChar* data16(unsigned i) const { ASSERT_WITH_SECURITY_IMPLICATION(i < m_len); ASSERT(!is8Bit()); return &m_data.characters16[i]; }
170 170
171 const LChar* characters8() const { ASSERT(is8Bit()); return m_data.character s8; } 171 const LChar* characters8() const { ASSERT(is8Bit()); return m_data.character s8; }
172 const UChar* characters16() const { ASSERT(!is8Bit()); return m_data.charact ers16; } 172 const UChar* characters16() const { ASSERT(!is8Bit()); return m_data.charact ers16; }
173 173
174 bool is8Bit() const { return m_is8Bit; } 174 bool is8Bit() const { return m_is8Bit; }
175 int length() const { return m_len; } 175 unsigned length() const { return m_len; }
176 int charactersLength() const { return m_charactersLength; } 176 unsigned charactersLength() const { return m_charactersLength; }
177 177
178 bool normalizeSpace() const { return m_normalizeSpace; } 178 bool normalizeSpace() const { return m_normalizeSpace; }
179 void setNormalizeSpace(bool normalizeSpace) { m_normalizeSpace = normalizeSp ace; } 179 void setNormalizeSpace(bool normalizeSpace) { m_normalizeSpace = normalizeSp ace; }
180 180
181 void setText(const LChar* c, unsigned len) { m_data.characters8 = c; m_len = len; m_is8Bit = true;} 181 void setText(const LChar* c, unsigned len) { m_data.characters8 = c; m_len = len; m_is8Bit = true;}
182 void setText(const UChar* c, unsigned len) { m_data.characters16 = c; m_len = len; m_is8Bit = false;} 182 void setText(const UChar* c, unsigned len) { m_data.characters16 = c; m_len = len; m_is8Bit = false;}
183 void setText(const String&); 183 void setText(const String&);
184 void setCharactersLength(unsigned charactersLength) { m_charactersLength = c haractersLength; } 184 void setCharactersLength(unsigned charactersLength) { m_charactersLength = c haractersLength; }
185 185
186 float horizontalGlyphStretch() const { return m_horizontalGlyphStretch; } 186 float horizontalGlyphStretch() const { return m_horizontalGlyphStretch; }
(...skipping 21 matching lines...) Expand all
208 void setDirectionalOverride(bool override) { m_directionalOverride = overrid e; } 208 void setDirectionalOverride(bool override) { m_directionalOverride = overrid e; }
209 void setCharacterScanForCodePath(bool scan) { m_characterScanForCodePath = s can; } 209 void setCharacterScanForCodePath(bool scan) { m_characterScanForCodePath = s can; }
210 void setUseComplexCodePath(bool useComplex) { m_useComplexCodePath = useComp lex; } 210 void setUseComplexCodePath(bool useComplex) { m_useComplexCodePath = useComp lex; }
211 211
212 class RenderingContext : public RefCounted<RenderingContext> { 212 class RenderingContext : public RefCounted<RenderingContext> {
213 public: 213 public:
214 virtual ~RenderingContext() { } 214 virtual ~RenderingContext() { }
215 215
216 virtual GlyphData glyphDataForCharacter(const Font&, const TextRun&, Sim pleShaper&, UChar32 character, bool mirror, int currentCharacter, unsigned& adva nceLength) = 0; 216 virtual GlyphData glyphDataForCharacter(const Font&, const TextRun&, Sim pleShaper&, UChar32 character, bool mirror, int currentCharacter, unsigned& adva nceLength) = 0;
217 virtual void drawSVGGlyphs(GraphicsContext*, const TextRun&, const Simpl eFontData*, const GlyphBuffer&, int from, int to, const FloatPoint&) const = 0; 217 virtual void drawSVGGlyphs(GraphicsContext*, const TextRun&, const Simpl eFontData*, const GlyphBuffer&, int from, int to, const FloatPoint&) const = 0;
218 virtual float floatWidthUsingSVGFont(const Font&, const TextRun&, int& c harsConsumed, Glyph& glyphId) const = 0; 218 virtual float floatWidthUsingSVGFont(const Font&, const TextRun&, unsign ed& charsConsumed, Glyph& glyphId) const = 0;
219 }; 219 };
220 220
221 RenderingContext* renderingContext() const { return m_renderingContext.get() ; } 221 RenderingContext* renderingContext() const { return m_renderingContext.get() ; }
222 void setRenderingContext(PassRefPtr<RenderingContext> context) { m_rendering Context = context; } 222 void setRenderingContext(PassRefPtr<RenderingContext> context) { m_rendering Context = context; }
223 223
224 private: 224 private:
225 union { 225 union {
226 const LChar* characters8; 226 const LChar* characters8;
227 const UChar* characters16; 227 const UChar* characters16;
228 } m_data; 228 } m_data;
(...skipping 29 matching lines...) Expand all
258 // Container for parameters needed to paint TextRun. 258 // Container for parameters needed to paint TextRun.
259 struct TextRunPaintInfo { 259 struct TextRunPaintInfo {
260 explicit TextRunPaintInfo(const TextRun& r) 260 explicit TextRunPaintInfo(const TextRun& r)
261 : run(r) 261 : run(r)
262 , from(0) 262 , from(0)
263 , to(r.length()) 263 , to(r.length())
264 { 264 {
265 } 265 }
266 266
267 const TextRun& run; 267 const TextRun& run;
268 int from; 268 unsigned from;
269 int to; 269 unsigned to;
270 FloatRect bounds; 270 FloatRect bounds;
271 }; 271 };
272 272
273 } 273 }
274 #endif 274 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698