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

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

Issue 2400783002: Reformat comments in core/layout/svg (Closed)
Patch Set: Created 4 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) 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 } 125 }
126 126
127 LayoutRect LayoutSVGInlineText::linesBoundingBox() const { 127 LayoutRect LayoutSVGInlineText::linesBoundingBox() const {
128 return enclosingLayoutRect(floatLinesBoundingBox()); 128 return enclosingLayoutRect(floatLinesBoundingBox());
129 } 129 }
130 130
131 bool LayoutSVGInlineText::characterStartsNewTextChunk(int position) const { 131 bool LayoutSVGInlineText::characterStartsNewTextChunk(int position) const {
132 ASSERT(position >= 0); 132 ASSERT(position >= 0);
133 ASSERT(position < static_cast<int>(textLength())); 133 ASSERT(position < static_cast<int>(textLength()));
134 134
135 // Each <textPath> element starts a new text chunk, regardless of any x/y valu es. 135 // Each <textPath> element starts a new text chunk, regardless of any x/y
136 // values.
136 if (!position && parent()->isSVGTextPath() && !previousSibling()) 137 if (!position && parent()->isSVGTextPath() && !previousSibling())
137 return true; 138 return true;
138 139
139 const SVGCharacterDataMap::const_iterator it = 140 const SVGCharacterDataMap::const_iterator it =
140 m_characterDataMap.find(static_cast<unsigned>(position + 1)); 141 m_characterDataMap.find(static_cast<unsigned>(position + 1));
141 if (it == m_characterDataMap.end()) 142 if (it == m_characterDataMap.end())
142 return false; 143 return false;
143 144
144 return it->value.hasX() || it->value.hasY(); 145 return it->value.hasX() || it->value.hasY();
145 } 146 }
146 147
147 PositionWithAffinity LayoutSVGInlineText::positionForPoint( 148 PositionWithAffinity LayoutSVGInlineText::positionForPoint(
148 const LayoutPoint& point) { 149 const LayoutPoint& point) {
149 if (!hasTextBoxes() || !textLength()) 150 if (!hasTextBoxes() || !textLength())
150 return createPositionWithAffinity(0); 151 return createPositionWithAffinity(0);
151 152
152 ASSERT(m_scalingFactor); 153 ASSERT(m_scalingFactor);
153 float baseline = 154 float baseline =
154 m_scaledFont.getFontMetrics().floatAscent() / m_scalingFactor; 155 m_scaledFont.getFontMetrics().floatAscent() / m_scalingFactor;
155 156
156 LayoutBlock* containingBlock = this->containingBlock(); 157 LayoutBlock* containingBlock = this->containingBlock();
157 ASSERT(containingBlock); 158 ASSERT(containingBlock);
158 159
159 // Map local point to absolute point, as the character origins stored in the t ext fragments use absolute coordinates. 160 // Map local point to absolute point, as the character origins stored in the
161 // text fragments use absolute coordinates.
160 FloatPoint absolutePoint(point); 162 FloatPoint absolutePoint(point);
161 absolutePoint.moveBy(containingBlock->location()); 163 absolutePoint.moveBy(containingBlock->location());
162 164
163 float closestDistance = std::numeric_limits<float>::max(); 165 float closestDistance = std::numeric_limits<float>::max();
164 float closestDistancePosition = 0; 166 float closestDistancePosition = 0;
165 const SVGTextFragment* closestDistanceFragment = nullptr; 167 const SVGTextFragment* closestDistanceFragment = nullptr;
166 SVGInlineTextBox* closestDistanceBox = nullptr; 168 SVGInlineTextBox* closestDistanceBox = nullptr;
167 169
168 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) { 170 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) {
169 if (!box->isSVGInlineTextBox()) 171 if (!box->isSVGInlineTextBox())
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 if (length) { 227 if (length) {
226 if (text.is8Bit()) 228 if (text.is8Bit())
227 run.setText(text.characters8() + position, length); 229 run.setText(text.characters8() + position, length);
228 else 230 else
229 run.setText(text.characters16() + position, length); 231 run.setText(text.characters16() + position, length);
230 } 232 }
231 233
232 // We handle letter & word spacing ourselves. 234 // We handle letter & word spacing ourselves.
233 run.disableSpacing(); 235 run.disableSpacing();
234 236
235 // Propagate the maximum length of the characters buffer to the TextRun, even when we're only processing a substring. 237 // Propagate the maximum length of the characters buffer to the TextRun, even
238 // when we're only processing a substring.
236 run.setCharactersLength(text.textLength() - position); 239 run.setCharactersLength(text.textLength() - position);
237 ASSERT(run.charactersLength() >= run.length()); 240 ASSERT(run.charactersLength() >= run.length());
238 return run; 241 return run;
239 } 242 }
240 243
241 // TODO(pdr): We only have per-glyph data so we need to synthesize per-grapheme 244 // TODO(pdr): We only have per-glyph data so we need to synthesize per-grapheme
242 // data. E.g., if 'fi' is shaped into a single glyph, we do not know the 'i' 245 // data. E.g., if 'fi' is shaped into a single glyph, we do not know the 'i'
243 // position. The code below synthesizes an average glyph width when characters 246 // position. The code below synthesizes an average glyph width when characters
244 // share a single position. This will incorrectly split combining diacritics. 247 // share a single position. This will incorrectly split combining diacritics.
245 // See: https://crbug.com/473476. 248 // See: https://crbug.com/473476.
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 } 360 }
358 361
359 void LayoutSVGInlineText::computeNewScaledFontForStyle( 362 void LayoutSVGInlineText::computeNewScaledFontForStyle(
360 LayoutObject* layoutObject, 363 LayoutObject* layoutObject,
361 float& scalingFactor, 364 float& scalingFactor,
362 Font& scaledFont) { 365 Font& scaledFont) {
363 const ComputedStyle* style = layoutObject->style(); 366 const ComputedStyle* style = layoutObject->style();
364 ASSERT(style); 367 ASSERT(style);
365 ASSERT(layoutObject); 368 ASSERT(layoutObject);
366 369
367 // Alter font-size to the right on-screen value to avoid scaling the glyphs th emselves, except when GeometricPrecision is specified. 370 // Alter font-size to the right on-screen value to avoid scaling the glyphs
371 // themselves, except when GeometricPrecision is specified.
368 scalingFactor = 372 scalingFactor =
369 SVGLayoutSupport::calculateScreenFontSizeScalingFactor(layoutObject); 373 SVGLayoutSupport::calculateScreenFontSizeScalingFactor(layoutObject);
370 if (style->effectiveZoom() == 1 && (scalingFactor == 1 || !scalingFactor)) { 374 if (style->effectiveZoom() == 1 && (scalingFactor == 1 || !scalingFactor)) {
371 scalingFactor = 1; 375 scalingFactor = 1;
372 scaledFont = style->font(); 376 scaledFont = style->font();
373 return; 377 return;
374 } 378 }
375 379
376 if (style->getFontDescription().textRendering() == GeometricPrecision) 380 if (style->getFontDescription().textRendering() == GeometricPrecision)
377 scalingFactor = 1; 381 scalingFactor = 1;
378 382
379 FontDescription fontDescription(style->getFontDescription()); 383 FontDescription fontDescription(style->getFontDescription());
380 384
381 Document& document = layoutObject->document(); 385 Document& document = layoutObject->document();
382 // FIXME: We need to better handle the case when we compute very small fonts b elow (below 1pt). 386 // FIXME: We need to better handle the case when we compute very small fonts
387 // below (below 1pt).
383 fontDescription.setComputedSize(FontSize::getComputedSizeFromSpecifiedSize( 388 fontDescription.setComputedSize(FontSize::getComputedSizeFromSpecifiedSize(
384 &document, scalingFactor, fontDescription.isAbsoluteSize(), 389 &document, scalingFactor, fontDescription.isAbsoluteSize(),
385 fontDescription.specifiedSize(), DoNotUseSmartMinimumForFontSize)); 390 fontDescription.specifiedSize(), DoNotUseSmartMinimumForFontSize));
386 391
387 scaledFont = Font(fontDescription); 392 scaledFont = Font(fontDescription);
388 scaledFont.update(document.styleEngine().fontSelector()); 393 scaledFont.update(document.styleEngine().fontSelector());
389 } 394 }
390 395
391 LayoutRect LayoutSVGInlineText::absoluteClippedOverflowRect() const { 396 LayoutRect LayoutSVGInlineText::absoluteClippedOverflowRect() const {
392 return parent()->absoluteClippedOverflowRect(); 397 return parent()->absoluteClippedOverflowRect();
393 } 398 }
394 399
395 FloatRect LayoutSVGInlineText::paintInvalidationRectInLocalSVGCoordinates() 400 FloatRect LayoutSVGInlineText::paintInvalidationRectInLocalSVGCoordinates()
396 const { 401 const {
397 return parent()->paintInvalidationRectInLocalSVGCoordinates(); 402 return parent()->paintInvalidationRectInLocalSVGCoordinates();
398 } 403 }
399 404
400 PassRefPtr<StringImpl> LayoutSVGInlineText::originalText() const { 405 PassRefPtr<StringImpl> LayoutSVGInlineText::originalText() const {
401 RefPtr<StringImpl> result = LayoutText::originalText(); 406 RefPtr<StringImpl> result = LayoutText::originalText();
402 if (!result) 407 if (!result)
403 return nullptr; 408 return nullptr;
404 return normalizeWhitespace(result); 409 return normalizeWhitespace(result);
405 } 410 }
406 411
407 } // namespace blink 412 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698