| OLD | NEW |
| 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 144 |
| 145 return it->value.hasX() || it->value.hasY(); | 145 return it->value.hasX() || it->value.hasY(); |
| 146 } | 146 } |
| 147 | 147 |
| 148 PositionWithAffinity LayoutSVGInlineText::positionForPoint( | 148 PositionWithAffinity LayoutSVGInlineText::positionForPoint( |
| 149 const LayoutPoint& point) { | 149 const LayoutPoint& point) { |
| 150 if (!hasTextBoxes() || !textLength()) | 150 if (!hasTextBoxes() || !textLength()) |
| 151 return createPositionWithAffinity(0); | 151 return createPositionWithAffinity(0); |
| 152 | 152 |
| 153 ASSERT(m_scalingFactor); | 153 ASSERT(m_scalingFactor); |
| 154 |
| 155 const SimpleFontData* fontData = m_scaledFont.primaryFont(); |
| 156 DCHECK(fontData); |
| 154 float baseline = | 157 float baseline = |
| 155 m_scaledFont.getFontMetrics().floatAscent() / m_scalingFactor; | 158 fontData ? fontData->getFontMetrics().floatAscent() / m_scalingFactor : 0; |
| 156 | 159 |
| 157 LayoutBlock* containingBlock = this->containingBlock(); | 160 LayoutBlock* containingBlock = this->containingBlock(); |
| 158 ASSERT(containingBlock); | 161 ASSERT(containingBlock); |
| 159 | 162 |
| 160 // Map local point to absolute point, as the character origins stored in the | 163 // Map local point to absolute point, as the character origins stored in the |
| 161 // text fragments use absolute coordinates. | 164 // text fragments use absolute coordinates. |
| 162 FloatPoint absolutePoint(point); | 165 FloatPoint absolutePoint(point); |
| 163 absolutePoint.moveBy(containingBlock->location()); | 166 absolutePoint.moveBy(containingBlock->location()); |
| 164 | 167 |
| 165 float closestDistance = std::numeric_limits<float>::max(); | 168 float closestDistance = std::numeric_limits<float>::max(); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 } | 283 } |
| 281 | 284 |
| 282 } // namespace | 285 } // namespace |
| 283 | 286 |
| 284 void LayoutSVGInlineText::addMetricsFromRun(const TextRun& run, | 287 void LayoutSVGInlineText::addMetricsFromRun(const TextRun& run, |
| 285 bool& lastCharacterWasWhiteSpace) { | 288 bool& lastCharacterWasWhiteSpace) { |
| 286 Vector<CharacterRange> charRanges = | 289 Vector<CharacterRange> charRanges = |
| 287 scaledFont().individualCharacterRanges(run); | 290 scaledFont().individualCharacterRanges(run); |
| 288 synthesizeGraphemeWidths(run, charRanges); | 291 synthesizeGraphemeWidths(run, charRanges); |
| 289 | 292 |
| 293 const SimpleFontData* fontData = scaledFont().primaryFont(); |
| 294 DCHECK(fontData); |
| 295 if (!fontData) |
| 296 return; |
| 297 |
| 290 const float cachedFontHeight = | 298 const float cachedFontHeight = |
| 291 scaledFont().getFontMetrics().floatHeight() / m_scalingFactor; | 299 fontData->getFontMetrics().floatHeight() / m_scalingFactor; |
| 292 const bool preserveWhiteSpace = styleRef().whiteSpace() == PRE; | 300 const bool preserveWhiteSpace = styleRef().whiteSpace() == PRE; |
| 293 const unsigned runLength = run.length(); | 301 const unsigned runLength = run.length(); |
| 294 | 302 |
| 295 // TODO(pdr): Character-based iteration is ambiguous and error-prone. It | 303 // TODO(pdr): Character-based iteration is ambiguous and error-prone. It |
| 296 // should be unified under a single concept. See: https://crbug.com/593570 | 304 // should be unified under a single concept. See: https://crbug.com/593570 |
| 297 unsigned characterIndex = 0; | 305 unsigned characterIndex = 0; |
| 298 while (characterIndex < runLength) { | 306 while (characterIndex < runLength) { |
| 299 bool currentCharacterIsWhiteSpace = run[characterIndex] == ' '; | 307 bool currentCharacterIsWhiteSpace = run[characterIndex] == ' '; |
| 300 if (!preserveWhiteSpace && lastCharacterWasWhiteSpace && | 308 if (!preserveWhiteSpace && lastCharacterWasWhiteSpace && |
| 301 currentCharacterIsWhiteSpace) { | 309 currentCharacterIsWhiteSpace) { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 } | 411 } |
| 404 | 412 |
| 405 PassRefPtr<StringImpl> LayoutSVGInlineText::originalText() const { | 413 PassRefPtr<StringImpl> LayoutSVGInlineText::originalText() const { |
| 406 RefPtr<StringImpl> result = LayoutText::originalText(); | 414 RefPtr<StringImpl> result = LayoutText::originalText(); |
| 407 if (!result) | 415 if (!result) |
| 408 return nullptr; | 416 return nullptr; |
| 409 return normalizeWhitespace(result); | 417 return normalizeWhitespace(result); |
| 410 } | 418 } |
| 411 | 419 |
| 412 } // namespace blink | 420 } // namespace blink |
| OLD | NEW |