OLD | NEW |
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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 return 0; | 76 return 0; |
77 } | 77 } |
78 | 78 |
79 int SVGInlineTextBox::offsetForPositionInFragment(const SVGTextFragment& fragmen
t, FloatWillBeLayoutUnit position, bool includePartialGlyphs) const | 79 int SVGInlineTextBox::offsetForPositionInFragment(const SVGTextFragment& fragmen
t, FloatWillBeLayoutUnit position, bool includePartialGlyphs) const |
80 { | 80 { |
81 LayoutSVGInlineText& textRenderer = toLayoutSVGInlineText(this->layoutObject
()); | 81 LayoutSVGInlineText& textRenderer = toLayoutSVGInlineText(this->layoutObject
()); |
82 | 82 |
83 float scalingFactor = textRenderer.scalingFactor(); | 83 float scalingFactor = textRenderer.scalingFactor(); |
84 ASSERT(scalingFactor); | 84 ASSERT(scalingFactor); |
85 | 85 |
86 const LayoutStyle& style = textRenderer.styleRef(); | 86 const ComputedStyle& style = textRenderer.styleRef(); |
87 | 87 |
88 TextRun textRun = constructTextRun(style, fragment); | 88 TextRun textRun = constructTextRun(style, fragment); |
89 | 89 |
90 // Eventually handle lengthAdjust="spacingAndGlyphs". | 90 // Eventually handle lengthAdjust="spacingAndGlyphs". |
91 // FIXME: Handle vertical text. | 91 // FIXME: Handle vertical text. |
92 AffineTransform fragmentTransform; | 92 AffineTransform fragmentTransform; |
93 fragment.buildFragmentTransform(fragmentTransform); | 93 fragment.buildFragmentTransform(fragmentTransform); |
94 if (!fragmentTransform.isIdentity()) | 94 if (!fragmentTransform.isIdentity()) |
95 textRun.setHorizontalGlyphStretch(narrowPrecisionToFloat(fragmentTransfo
rm.xScale())); | 95 textRun.setHorizontalGlyphStretch(narrowPrecisionToFloat(fragmentTransfo
rm.xScale())); |
96 | 96 |
97 return fragment.characterOffset - start() + textRenderer.scaledFont().offset
ForPosition(textRun, position * scalingFactor, includePartialGlyphs); | 97 return fragment.characterOffset - start() + textRenderer.scaledFont().offset
ForPosition(textRun, position * scalingFactor, includePartialGlyphs); |
98 } | 98 } |
99 | 99 |
100 FloatWillBeLayoutUnit SVGInlineTextBox::positionForOffset(int) const | 100 FloatWillBeLayoutUnit SVGInlineTextBox::positionForOffset(int) const |
101 { | 101 { |
102 // SVG doesn't use the offset <-> position selection system. | 102 // SVG doesn't use the offset <-> position selection system. |
103 ASSERT_NOT_REACHED(); | 103 ASSERT_NOT_REACHED(); |
104 return 0; | 104 return 0; |
105 } | 105 } |
106 | 106 |
107 FloatRect SVGInlineTextBox::selectionRectForTextFragment(const SVGTextFragment&
fragment, int startPosition, int endPosition, const LayoutStyle& style) | 107 FloatRect SVGInlineTextBox::selectionRectForTextFragment(const SVGTextFragment&
fragment, int startPosition, int endPosition, const ComputedStyle& style) |
108 { | 108 { |
109 ASSERT(startPosition < endPosition); | 109 ASSERT(startPosition < endPosition); |
110 | 110 |
111 LayoutSVGInlineText& textRenderer = toLayoutSVGInlineText(this->layoutObject
()); | 111 LayoutSVGInlineText& textRenderer = toLayoutSVGInlineText(this->layoutObject
()); |
112 | 112 |
113 float scalingFactor = textRenderer.scalingFactor(); | 113 float scalingFactor = textRenderer.scalingFactor(); |
114 ASSERT(scalingFactor); | 114 ASSERT(scalingFactor); |
115 | 115 |
116 const Font& scaledFont = textRenderer.scaledFont(); | 116 const Font& scaledFont = textRenderer.scaledFont(); |
117 const FontMetrics& scaledFontMetrics = scaledFont.fontMetrics(); | 117 const FontMetrics& scaledFontMetrics = scaledFont.fontMetrics(); |
(...skipping 12 matching lines...) Expand all Loading... |
130 } | 130 } |
131 | 131 |
132 LayoutRect SVGInlineTextBox::localSelectionRect(int startPosition, int endPositi
on) | 132 LayoutRect SVGInlineTextBox::localSelectionRect(int startPosition, int endPositi
on) |
133 { | 133 { |
134 int boxStart = start(); | 134 int boxStart = start(); |
135 startPosition = std::max(startPosition - boxStart, 0); | 135 startPosition = std::max(startPosition - boxStart, 0); |
136 endPosition = std::min(endPosition - boxStart, static_cast<int>(len())); | 136 endPosition = std::min(endPosition - boxStart, static_cast<int>(len())); |
137 if (startPosition >= endPosition) | 137 if (startPosition >= endPosition) |
138 return LayoutRect(); | 138 return LayoutRect(); |
139 | 139 |
140 const LayoutStyle& style = layoutObject().styleRef(); | 140 const ComputedStyle& style = layoutObject().styleRef(); |
141 | 141 |
142 AffineTransform fragmentTransform; | 142 AffineTransform fragmentTransform; |
143 FloatRect selectionRect; | 143 FloatRect selectionRect; |
144 int fragmentStartPosition = 0; | 144 int fragmentStartPosition = 0; |
145 int fragmentEndPosition = 0; | 145 int fragmentEndPosition = 0; |
146 | 146 |
147 unsigned textFragmentsSize = m_textFragments.size(); | 147 unsigned textFragmentsSize = m_textFragments.size(); |
148 for (unsigned i = 0; i < textFragmentsSize; ++i) { | 148 for (unsigned i = 0; i < textFragmentsSize; ++i) { |
149 const SVGTextFragment& fragment = m_textFragments.at(i); | 149 const SVGTextFragment& fragment = m_textFragments.at(i); |
150 | 150 |
(...skipping 10 matching lines...) Expand all Loading... |
161 } | 161 } |
162 | 162 |
163 return LayoutRect(enclosingIntRect(selectionRect)); | 163 return LayoutRect(enclosingIntRect(selectionRect)); |
164 } | 164 } |
165 | 165 |
166 void SVGInlineTextBox::paint(const PaintInfo& paintInfo, const LayoutPoint& pain
tOffset, LayoutUnit, LayoutUnit) | 166 void SVGInlineTextBox::paint(const PaintInfo& paintInfo, const LayoutPoint& pain
tOffset, LayoutUnit, LayoutUnit) |
167 { | 167 { |
168 SVGInlineTextBoxPainter(*this).paint(paintInfo, paintOffset); | 168 SVGInlineTextBoxPainter(*this).paint(paintInfo, paintOffset); |
169 } | 169 } |
170 | 170 |
171 TextRun SVGInlineTextBox::constructTextRun(const LayoutStyle& style, const SVGTe
xtFragment& fragment) const | 171 TextRun SVGInlineTextBox::constructTextRun(const ComputedStyle& style, const SVG
TextFragment& fragment) const |
172 { | 172 { |
173 LayoutText* text = &layoutObject(); | 173 LayoutText* text = &layoutObject(); |
174 | 174 |
175 // FIXME(crbug.com/264211): This should not be necessary but can occur if we | 175 // FIXME(crbug.com/264211): This should not be necessary but can occur if we |
176 // layout during layout. Remove this when 264211 is
fixed. | 176 // layout during layout. Remove this when 264211 is
fixed. |
177 RELEASE_ASSERT(!text->needsLayout()); | 177 RELEASE_ASSERT(!text->needsLayout()); |
178 | 178 |
179 TextRun run(static_cast<const LChar*>(0) // characters, will be set below if
non-zero. | 179 TextRun run(static_cast<const LChar*>(0) // characters, will be set below if
non-zero. |
180 , 0 // length, will be set below if non-zero. | 180 , 0 // length, will be set below if non-zero. |
181 , 0 // xPos, only relevant with allowTabs=true | 181 , 0 // xPos, only relevant with allowTabs=true |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 endPosition = length; | 220 endPosition = length; |
221 } else { | 221 } else { |
222 ASSERT(endPosition >= offset); | 222 ASSERT(endPosition >= offset); |
223 endPosition -= offset; | 223 endPosition -= offset; |
224 } | 224 } |
225 | 225 |
226 ASSERT(startPosition < endPosition); | 226 ASSERT(startPosition < endPosition); |
227 return true; | 227 return true; |
228 } | 228 } |
229 | 229 |
230 void SVGInlineTextBox::paintDocumentMarker(GraphicsContext*, const FloatPointWil
lBeLayoutPoint&, DocumentMarker*, const LayoutStyle&, const Font&, bool) | 230 void SVGInlineTextBox::paintDocumentMarker(GraphicsContext*, const FloatPointWil
lBeLayoutPoint&, DocumentMarker*, const ComputedStyle&, const Font&, bool) |
231 { | 231 { |
232 // SVG does not have support for generic document markers (e.g., spellchecki
ng, etc). | 232 // SVG does not have support for generic document markers (e.g., spellchecki
ng, etc). |
233 } | 233 } |
234 | 234 |
235 void SVGInlineTextBox::paintTextMatchMarker(GraphicsContext* context, const Floa
tPointWillBeLayoutPoint& point, DocumentMarker* marker, const LayoutStyle& style
, const Font& font) | 235 void SVGInlineTextBox::paintTextMatchMarker(GraphicsContext* context, const Floa
tPointWillBeLayoutPoint& point, DocumentMarker* marker, const ComputedStyle& sty
le, const Font& font) |
236 { | 236 { |
237 SVGInlineTextBoxPainter(*this).paintTextMatchMarker(context, point.toFloatPo
int(), marker, style, font); | 237 SVGInlineTextBoxPainter(*this).paintTextMatchMarker(context, point.toFloatPo
int(), marker, style, font); |
238 } | 238 } |
239 | 239 |
240 FloatRectWillBeLayoutRect SVGInlineTextBox::calculateBoundaries() const | 240 FloatRectWillBeLayoutRect SVGInlineTextBox::calculateBoundaries() const |
241 { | 241 { |
242 FloatRectWillBeLayoutRect textRect; | 242 FloatRectWillBeLayoutRect textRect; |
243 | 243 |
244 LayoutSVGInlineText& textRenderer = toLayoutSVGInlineText(this->layoutObject
()); | 244 LayoutSVGInlineText& textRenderer = toLayoutSVGInlineText(this->layoutObject
()); |
245 | 245 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 layoutObject().updateHitTestResult(result, locationInContainer.p
oint() - toLayoutSize(accumulatedOffset)); | 282 layoutObject().updateHitTestResult(result, locationInContainer.p
oint() - toLayoutSize(accumulatedOffset)); |
283 if (!result.addNodeToListBasedTestResult(layoutObject().node(),
request, locationInContainer, rect.rawValue())) | 283 if (!result.addNodeToListBasedTestResult(layoutObject().node(),
request, locationInContainer, rect.rawValue())) |
284 return true; | 284 return true; |
285 } | 285 } |
286 } | 286 } |
287 } | 287 } |
288 return false; | 288 return false; |
289 } | 289 } |
290 | 290 |
291 } // namespace blink | 291 } // namespace blink |
OLD | NEW |