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

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

Issue 2748103015: Replace ASSERT with DCHECK in core/layout/<sub dirs> (Closed)
Patch Set: Rebase with latest Created 3 years, 8 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
« no previous file with comments | « third_party/WebKit/Source/core/layout/svg/SVGTextQuery.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007 Rob Buis <buis@kde.org> 2 * Copyright (C) 2007 Rob Buis <buis@kde.org>
3 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> 3 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
4 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 4 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 } 66 }
67 67
68 int SVGInlineTextBox::offsetForPositionInFragment( 68 int SVGInlineTextBox::offsetForPositionInFragment(
69 const SVGTextFragment& fragment, 69 const SVGTextFragment& fragment,
70 LayoutUnit position, 70 LayoutUnit position,
71 bool includePartialGlyphs) const { 71 bool includePartialGlyphs) const {
72 LineLayoutSVGInlineText lineLayoutItem = 72 LineLayoutSVGInlineText lineLayoutItem =
73 LineLayoutSVGInlineText(this->getLineLayoutItem()); 73 LineLayoutSVGInlineText(this->getLineLayoutItem());
74 74
75 float scalingFactor = lineLayoutItem.scalingFactor(); 75 float scalingFactor = lineLayoutItem.scalingFactor();
76 ASSERT(scalingFactor); 76 DCHECK(scalingFactor);
77 77
78 const ComputedStyle& style = lineLayoutItem.styleRef(); 78 const ComputedStyle& style = lineLayoutItem.styleRef();
79 79
80 TextRun textRun = constructTextRun(style, fragment); 80 TextRun textRun = constructTextRun(style, fragment);
81 81
82 // Eventually handle lengthAdjust="spacingAndGlyphs". 82 // Eventually handle lengthAdjust="spacingAndGlyphs".
83 // FIXME: Handle vertical text. 83 // FIXME: Handle vertical text.
84 if (fragment.isTransformed()) { 84 if (fragment.isTransformed()) {
85 AffineTransform fragmentTransform = fragment.buildFragmentTransform(); 85 AffineTransform fragmentTransform = fragment.buildFragmentTransform();
86 textRun.setHorizontalGlyphStretch( 86 textRun.setHorizontalGlyphStretch(
87 clampTo<float>(fragmentTransform.xScale())); 87 clampTo<float>(fragmentTransform.xScale()));
88 } 88 }
89 89
90 return fragment.characterOffset - start() + 90 return fragment.characterOffset - start() +
91 lineLayoutItem.scaledFont().offsetForPosition( 91 lineLayoutItem.scaledFont().offsetForPosition(
92 textRun, position * scalingFactor, includePartialGlyphs); 92 textRun, position * scalingFactor, includePartialGlyphs);
93 } 93 }
94 94
95 LayoutUnit SVGInlineTextBox::positionForOffset(int) const { 95 LayoutUnit SVGInlineTextBox::positionForOffset(int) const {
96 // SVG doesn't use the offset <-> position selection system. 96 // SVG doesn't use the offset <-> position selection system.
97 NOTREACHED(); 97 NOTREACHED();
98 return LayoutUnit(); 98 return LayoutUnit();
99 } 99 }
100 100
101 FloatRect SVGInlineTextBox::selectionRectForTextFragment( 101 FloatRect SVGInlineTextBox::selectionRectForTextFragment(
102 const SVGTextFragment& fragment, 102 const SVGTextFragment& fragment,
103 int startPosition, 103 int startPosition,
104 int endPosition, 104 int endPosition,
105 const ComputedStyle& style) const { 105 const ComputedStyle& style) const {
106 ASSERT(startPosition < endPosition); 106 DCHECK_LT(startPosition, endPosition);
107 107
108 LineLayoutSVGInlineText lineLayoutItem = 108 LineLayoutSVGInlineText lineLayoutItem =
109 LineLayoutSVGInlineText(this->getLineLayoutItem()); 109 LineLayoutSVGInlineText(this->getLineLayoutItem());
110 110
111 float scalingFactor = lineLayoutItem.scalingFactor(); 111 float scalingFactor = lineLayoutItem.scalingFactor();
112 ASSERT(scalingFactor); 112 DCHECK(scalingFactor);
113 113
114 const Font& scaledFont = lineLayoutItem.scaledFont(); 114 const Font& scaledFont = lineLayoutItem.scaledFont();
115 const SimpleFontData* fontData = scaledFont.primaryFont(); 115 const SimpleFontData* fontData = scaledFont.primaryFont();
116 DCHECK(fontData); 116 DCHECK(fontData);
117 if (!fontData) 117 if (!fontData)
118 return FloatRect(); 118 return FloatRect();
119 119
120 const FontMetrics& scaledFontMetrics = fontData->getFontMetrics(); 120 const FontMetrics& scaledFontMetrics = fontData->getFontMetrics();
121 FloatPoint textOrigin(fragment.x, fragment.y); 121 FloatPoint textOrigin(fragment.x, fragment.y);
122 if (scalingFactor != 1) 122 if (scalingFactor != 1)
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 run.setText(text.characters16() + fragment.characterOffset, 200 run.setText(text.characters16() + fragment.characterOffset,
201 fragment.length); 201 fragment.length);
202 } 202 }
203 203
204 // We handle letter & word spacing ourselves. 204 // We handle letter & word spacing ourselves.
205 run.disableSpacing(); 205 run.disableSpacing();
206 206
207 // Propagate the maximum length of the characters buffer to the TextRun, even 207 // Propagate the maximum length of the characters buffer to the TextRun, even
208 // when we're only processing a substring. 208 // when we're only processing a substring.
209 run.setCharactersLength(text.textLength() - fragment.characterOffset); 209 run.setCharactersLength(text.textLength() - fragment.characterOffset);
210 ASSERT(run.charactersLength() >= run.length()); 210 DCHECK_GE(run.charactersLength(), run.length());
211 return run; 211 return run;
212 } 212 }
213 213
214 bool SVGInlineTextBox::mapStartEndPositionsIntoFragmentCoordinates( 214 bool SVGInlineTextBox::mapStartEndPositionsIntoFragmentCoordinates(
215 const SVGTextFragment& fragment, 215 const SVGTextFragment& fragment,
216 int& startPosition, 216 int& startPosition,
217 int& endPosition) const { 217 int& endPosition) const {
218 int fragmentOffsetInBox = 218 int fragmentOffsetInBox =
219 static_cast<int>(fragment.characterOffset) - start(); 219 static_cast<int>(fragment.characterOffset) - start();
220 220
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 261
262 LayoutRect SVGInlineTextBox::calculateBoundaries() const { 262 LayoutRect SVGInlineTextBox::calculateBoundaries() const {
263 LineLayoutSVGInlineText lineLayoutItem = 263 LineLayoutSVGInlineText lineLayoutItem =
264 LineLayoutSVGInlineText(this->getLineLayoutItem()); 264 LineLayoutSVGInlineText(this->getLineLayoutItem());
265 const SimpleFontData* fontData = lineLayoutItem.scaledFont().primaryFont(); 265 const SimpleFontData* fontData = lineLayoutItem.scaledFont().primaryFont();
266 DCHECK(fontData); 266 DCHECK(fontData);
267 if (!fontData) 267 if (!fontData)
268 return LayoutRect(); 268 return LayoutRect();
269 269
270 float scalingFactor = lineLayoutItem.scalingFactor(); 270 float scalingFactor = lineLayoutItem.scalingFactor();
271 ASSERT(scalingFactor); 271 DCHECK(scalingFactor);
272 LayoutUnit baseline(fontData->getFontMetrics().floatAscent() / scalingFactor); 272 LayoutUnit baseline(fontData->getFontMetrics().floatAscent() / scalingFactor);
273 273
274 LayoutRect textBoundingRect; 274 LayoutRect textBoundingRect;
275 for (const SVGTextFragment& fragment : m_textFragments) 275 for (const SVGTextFragment& fragment : m_textFragments)
276 textBoundingRect.unite(LayoutRect(fragment.overflowBoundingBox(baseline))); 276 textBoundingRect.unite(LayoutRect(fragment.overflowBoundingBox(baseline)));
277 277
278 return textBoundingRect; 278 return textBoundingRect;
279 } 279 }
280 280
281 bool SVGInlineTextBox::nodeAtPoint(HitTestResult& result, 281 bool SVGInlineTextBox::nodeAtPoint(HitTestResult& result,
282 const HitTestLocation& locationInContainer, 282 const HitTestLocation& locationInContainer,
283 const LayoutPoint& accumulatedOffset, 283 const LayoutPoint& accumulatedOffset,
284 LayoutUnit, 284 LayoutUnit,
285 LayoutUnit) { 285 LayoutUnit) {
286 // FIXME: integrate with InlineTextBox::nodeAtPoint better. 286 // FIXME: integrate with InlineTextBox::nodeAtPoint better.
287 ASSERT(!isLineBreak()); 287 DCHECK(!isLineBreak());
288 288
289 PointerEventsHitRules hitRules(PointerEventsHitRules::SVG_TEXT_HITTESTING, 289 PointerEventsHitRules hitRules(PointerEventsHitRules::SVG_TEXT_HITTESTING,
290 result.hitTestRequest(), 290 result.hitTestRequest(),
291 getLineLayoutItem().style()->pointerEvents()); 291 getLineLayoutItem().style()->pointerEvents());
292 bool isVisible = 292 bool isVisible =
293 getLineLayoutItem().style()->visibility() == EVisibility::kVisible; 293 getLineLayoutItem().style()->visibility() == EVisibility::kVisible;
294 if (isVisible || !hitRules.requireVisible) { 294 if (isVisible || !hitRules.requireVisible) {
295 if (hitRules.canHitBoundingBox || 295 if (hitRules.canHitBoundingBox ||
296 (hitRules.canHitStroke && 296 (hitRules.canHitStroke &&
297 (getLineLayoutItem().style()->svgStyle().hasStroke() || 297 (getLineLayoutItem().style()->svgStyle().hasStroke() ||
(...skipping 28 matching lines...) Expand all
326 return true; 326 return true;
327 } 327 }
328 } 328 }
329 } 329 }
330 } 330 }
331 } 331 }
332 return false; 332 return false;
333 } 333 }
334 334
335 } // namespace blink 335 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/svg/SVGTextQuery.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698