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

Side by Side Diff: third_party/WebKit/Source/core/layout/svg/LayoutSVGInlineText.cpp

Issue 2748103015: Replace ASSERT with DCHECK in core/layout/<sub dirs> (Closed)
Patch Set: Rebase with latest Created 3 years, 9 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) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz> 2 * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>
3 * Copyright (C) 2006 Apple Computer Inc. 3 * Copyright (C) 2006 Apple Computer Inc.
4 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> 4 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
5 * Copyright (C) 2008 Rob Buis <buis@kde.org> 5 * Copyright (C) 2008 Rob Buis <buis@kde.org>
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) 125 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox())
126 boundingBox.unite(FloatRect(box->frameRect())); 126 boundingBox.unite(FloatRect(box->frameRect()));
127 return boundingBox; 127 return boundingBox;
128 } 128 }
129 129
130 LayoutRect LayoutSVGInlineText::linesBoundingBox() const { 130 LayoutRect LayoutSVGInlineText::linesBoundingBox() const {
131 return enclosingLayoutRect(floatLinesBoundingBox()); 131 return enclosingLayoutRect(floatLinesBoundingBox());
132 } 132 }
133 133
134 bool LayoutSVGInlineText::characterStartsNewTextChunk(int position) const { 134 bool LayoutSVGInlineText::characterStartsNewTextChunk(int position) const {
135 ASSERT(position >= 0); 135 DCHECK_GE(position, 0);
136 ASSERT(position < static_cast<int>(textLength())); 136 DCHECK_LT(position, static_cast<int>(textLength()));
137 137
138 // Each <textPath> element starts a new text chunk, regardless of any x/y 138 // Each <textPath> element starts a new text chunk, regardless of any x/y
139 // values. 139 // values.
140 if (!position && parent()->isSVGTextPath() && !previousSibling()) 140 if (!position && parent()->isSVGTextPath() && !previousSibling())
141 return true; 141 return true;
142 142
143 const SVGCharacterDataMap::const_iterator it = 143 const SVGCharacterDataMap::const_iterator it =
144 m_characterDataMap.find(static_cast<unsigned>(position + 1)); 144 m_characterDataMap.find(static_cast<unsigned>(position + 1));
145 if (it == m_characterDataMap.end()) 145 if (it == m_characterDataMap.end())
146 return false; 146 return false;
147 147
148 return it->value.hasX() || it->value.hasY(); 148 return it->value.hasX() || it->value.hasY();
149 } 149 }
150 150
151 PositionWithAffinity LayoutSVGInlineText::positionForPoint( 151 PositionWithAffinity LayoutSVGInlineText::positionForPoint(
152 const LayoutPoint& point) { 152 const LayoutPoint& point) {
153 if (!hasTextBoxes() || !textLength()) 153 if (!hasTextBoxes() || !textLength())
154 return createPositionWithAffinity(0); 154 return createPositionWithAffinity(0);
155 155
156 ASSERT(m_scalingFactor); 156 DCHECK(m_scalingFactor);
157 157
158 const SimpleFontData* fontData = m_scaledFont.primaryFont(); 158 const SimpleFontData* fontData = m_scaledFont.primaryFont();
159 DCHECK(fontData); 159 DCHECK(fontData);
160 float baseline = 160 float baseline =
161 fontData ? fontData->getFontMetrics().floatAscent() / m_scalingFactor : 0; 161 fontData ? fontData->getFontMetrics().floatAscent() / m_scalingFactor : 0;
162 162
163 LayoutBlock* containingBlock = this->containingBlock(); 163 LayoutBlock* containingBlock = this->containingBlock();
164 ASSERT(containingBlock); 164 DCHECK(containingBlock);
165 165
166 // Map local point to absolute point, as the character origins stored in the 166 // Map local point to absolute point, as the character origins stored in the
167 // text fragments use absolute coordinates. 167 // text fragments use absolute coordinates.
168 FloatPoint absolutePoint(point); 168 FloatPoint absolutePoint(point);
169 absolutePoint.moveBy(containingBlock->location()); 169 absolutePoint.moveBy(containingBlock->location());
170 170
171 float closestDistance = std::numeric_limits<float>::max(); 171 float closestDistance = std::numeric_limits<float>::max();
172 float closestDistancePosition = 0; 172 float closestDistancePosition = 0;
173 const SVGTextFragment* closestDistanceFragment = nullptr; 173 const SVGTextFragment* closestDistanceFragment = nullptr;
174 SVGInlineTextBox* closestDistanceBox = nullptr; 174 SVGInlineTextBox* closestDistanceBox = nullptr;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 else 236 else
237 run.setText(text.characters16() + position, length); 237 run.setText(text.characters16() + position, length);
238 } 238 }
239 239
240 // We handle letter & word spacing ourselves. 240 // We handle letter & word spacing ourselves.
241 run.disableSpacing(); 241 run.disableSpacing();
242 242
243 // Propagate the maximum length of the characters buffer to the TextRun, even 243 // Propagate the maximum length of the characters buffer to the TextRun, even
244 // when we're only processing a substring. 244 // when we're only processing a substring.
245 run.setCharactersLength(text.textLength() - position); 245 run.setCharactersLength(text.textLength() - position);
246 ASSERT(run.charactersLength() >= run.length()); 246 DCHECK_GE(run.charactersLength(), run.length());
247 return run; 247 return run;
248 } 248 }
249 249
250 // TODO(pdr): We only have per-glyph data so we need to synthesize per-grapheme 250 // TODO(pdr): We only have per-glyph data so we need to synthesize per-grapheme
251 // data. E.g., if 'fi' is shaped into a single glyph, we do not know the 'i' 251 // data. E.g., if 'fi' is shaped into a single glyph, we do not know the 'i'
252 // position. The code below synthesizes an average glyph width when characters 252 // position. The code below synthesizes an average glyph width when characters
253 // share a single position. This will incorrectly split combining diacritics. 253 // share a single position. This will incorrectly split combining diacritics.
254 // See: https://crbug.com/473476. 254 // See: https://crbug.com/473476.
255 void synthesizeGraphemeWidths(const TextRun& run, 255 void synthesizeGraphemeWidths(const TextRun& run,
256 Vector<CharacterRange>& ranges) { 256 Vector<CharacterRange>& ranges) {
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 } 416 }
417 417
418 PassRefPtr<StringImpl> LayoutSVGInlineText::originalText() const { 418 PassRefPtr<StringImpl> LayoutSVGInlineText::originalText() const {
419 RefPtr<StringImpl> result = LayoutText::originalText(); 419 RefPtr<StringImpl> result = LayoutText::originalText();
420 if (!result) 420 if (!result)
421 return nullptr; 421 return nullptr;
422 return normalizeWhitespace(result); 422 return normalizeWhitespace(result);
423 } 423 }
424 424
425 } // namespace blink 425 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698