OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) Research In Motion Limited 2010-2012. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2010-2012. All rights reserved. |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 ASSERT(layoutObject->isSVGText()); | 57 ASSERT(layoutObject->isSVGText()); |
58 LayoutBlockFlow* layoutBlockFlow = toLayoutBlockFlow(layoutObject); | 58 LayoutBlockFlow* layoutBlockFlow = toLayoutBlockFlow(layoutObject); |
59 | 59 |
60 // LayoutSVGText only ever contains a single line box. | 60 // LayoutSVGText only ever contains a single line box. |
61 InlineFlowBox* flowBox = layoutBlockFlow->firstLineBox(); | 61 InlineFlowBox* flowBox = layoutBlockFlow->firstLineBox(); |
62 ASSERT(flowBox == layoutBlockFlow->lastLineBox()); | 62 ASSERT(flowBox == layoutBlockFlow->lastLineBox()); |
63 return flowBox; | 63 return flowBox; |
64 } | 64 } |
65 | 65 |
66 if (layoutObject->isLayoutInline()) { | 66 if (layoutObject->isLayoutInline()) { |
67 // We're given a LayoutSVGInline or objects that derive from it (LayoutSVGTS
pan / LayoutSVGTextPath) | 67 // We're given a LayoutSVGInline or objects that derive from it |
| 68 // (LayoutSVGTSpan / LayoutSVGTextPath) |
68 LayoutInline* layoutInline = toLayoutInline(layoutObject); | 69 LayoutInline* layoutInline = toLayoutInline(layoutObject); |
69 | 70 |
70 // LayoutSVGInline only ever contains a single line box. | 71 // LayoutSVGInline only ever contains a single line box. |
71 InlineFlowBox* flowBox = layoutInline->firstLineBox(); | 72 InlineFlowBox* flowBox = layoutInline->firstLineBox(); |
72 ASSERT(flowBox == layoutInline->lastLineBox()); | 73 ASSERT(flowBox == layoutInline->lastLineBox()); |
73 return flowBox; | 74 return flowBox; |
74 } | 75 } |
75 | 76 |
76 ASSERT_NOT_REACHED(); | 77 ASSERT_NOT_REACHED(); |
77 return nullptr; | 78 return nullptr; |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 logicalQuery(m_queryRootLayoutObject, &data, textLengthCallback); | 225 logicalQuery(m_queryRootLayoutObject, &data, textLengthCallback); |
225 return data.textLength; | 226 return data.textLength; |
226 } | 227 } |
227 | 228 |
228 using MetricsList = Vector<SVGTextMetrics>; | 229 using MetricsList = Vector<SVGTextMetrics>; |
229 | 230 |
230 MetricsList::const_iterator findMetricsForCharacter( | 231 MetricsList::const_iterator findMetricsForCharacter( |
231 const MetricsList& metricsList, | 232 const MetricsList& metricsList, |
232 const SVGTextFragment& fragment, | 233 const SVGTextFragment& fragment, |
233 unsigned startInFragment) { | 234 unsigned startInFragment) { |
234 // Find the text metrics cell that starts at or contains the character at |sta
rtInFragment|. | 235 // Find the text metrics cell that starts at or contains the character at |
| 236 // |startInFragment|. |
235 MetricsList::const_iterator metrics = | 237 MetricsList::const_iterator metrics = |
236 metricsList.begin() + fragment.metricsListOffset; | 238 metricsList.begin() + fragment.metricsListOffset; |
237 unsigned fragmentOffset = 0; | 239 unsigned fragmentOffset = 0; |
238 while (fragmentOffset < fragment.length) { | 240 while (fragmentOffset < fragment.length) { |
239 fragmentOffset += metrics->length(); | 241 fragmentOffset += metrics->length(); |
240 if (startInFragment < fragmentOffset) | 242 if (startInFragment < fragmentOffset) |
241 break; | 243 break; |
242 ++metrics; | 244 ++metrics; |
243 } | 245 } |
244 ASSERT(metrics <= metricsList.end()); | 246 ASSERT(metrics <= metricsList.end()); |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 | 442 |
441 static FloatRect physicalGlyphExtents(const QueryData* queryData, | 443 static FloatRect physicalGlyphExtents(const QueryData* queryData, |
442 const SVGTextMetrics& metrics, | 444 const SVGTextMetrics& metrics, |
443 const FloatPoint& glyphPosition) { | 445 const FloatPoint& glyphPosition) { |
444 // TODO(fs): Negative glyph extents seems kind of weird to have, but | 446 // TODO(fs): Negative glyph extents seems kind of weird to have, but |
445 // presently it can occur in some cases (like Arabic.) | 447 // presently it can occur in some cases (like Arabic.) |
446 FloatRect glyphExtents(glyphPosition, | 448 FloatRect glyphExtents(glyphPosition, |
447 FloatSize(std::max<float>(metrics.width(), 0), | 449 FloatSize(std::max<float>(metrics.width(), 0), |
448 std::max<float>(metrics.height(), 0))); | 450 std::max<float>(metrics.height(), 0))); |
449 | 451 |
450 // If RTL, adjust the starting point to align with the LHS of the glyph boundi
ng box. | 452 // If RTL, adjust the starting point to align with the LHS of the glyph |
| 453 // bounding box. |
451 if (!queryData->textBox->isLeftToRightDirection()) { | 454 if (!queryData->textBox->isLeftToRightDirection()) { |
452 if (queryData->isVerticalText) | 455 if (queryData->isVerticalText) |
453 glyphExtents.move(0, -glyphExtents.height()); | 456 glyphExtents.move(0, -glyphExtents.height()); |
454 else | 457 else |
455 glyphExtents.move(-glyphExtents.width(), 0); | 458 glyphExtents.move(-glyphExtents.width(), 0); |
456 } | 459 } |
457 return glyphExtents; | 460 return glyphExtents; |
458 } | 461 } |
459 | 462 |
460 static inline FloatRect calculateGlyphBoundaries( | 463 static inline FloatRect calculateGlyphBoundaries( |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 } | 607 } |
605 | 608 |
606 int SVGTextQuery::characterNumberAtPosition(const FloatPoint& position) const { | 609 int SVGTextQuery::characterNumberAtPosition(const FloatPoint& position) const { |
607 CharacterNumberAtPositionData data(position); | 610 CharacterNumberAtPositionData data(position); |
608 spatialQuery(m_queryRootLayoutObject, &data, | 611 spatialQuery(m_queryRootLayoutObject, &data, |
609 characterNumberAtPositionCallback); | 612 characterNumberAtPositionCallback); |
610 return data.characterNumberWithin(m_queryRootLayoutObject); | 613 return data.characterNumberWithin(m_queryRootLayoutObject); |
611 } | 614 } |
612 | 615 |
613 } // namespace blink | 616 } // namespace blink |
OLD | NEW |