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 * |
11 * This library is distributed in the hope that it will be useful, | 11 * This library is distributed in the hope that it will be useful, |
(...skipping 28 matching lines...) Expand all Loading... | |
40 "SVGInlineTextBox has an unexpected size"); | 40 "SVGInlineTextBox has an unexpected size"); |
41 | 41 |
42 SVGInlineTextBox::SVGInlineTextBox(LineLayoutItem item, | 42 SVGInlineTextBox::SVGInlineTextBox(LineLayoutItem item, |
43 int start, | 43 int start, |
44 unsigned short length) | 44 unsigned short length) |
45 : InlineTextBox(item, start, length), m_startsNewTextChunk(false) {} | 45 : InlineTextBox(item, start, length), m_startsNewTextChunk(false) {} |
46 | 46 |
47 void SVGInlineTextBox::dirtyLineBoxes() { | 47 void SVGInlineTextBox::dirtyLineBoxes() { |
48 InlineTextBox::dirtyLineBoxes(); | 48 InlineTextBox::dirtyLineBoxes(); |
49 | 49 |
50 // Clear the now stale text fragments | 50 // Clear the now stale text fragments. |
51 clearTextFragments(); | 51 clearTextFragments(); |
52 | 52 |
53 // And clear any following text fragments as the text on which they | 53 // And clear any following text fragments as the text on which they depend may |
54 // depend may now no longer exist, or glyph positions may be wrong | 54 // now no longer exist, or glyph positions may be wrong. |
55 InlineTextBox* nextBox = nextTextBox(); | 55 InlineTextBox* nextBox = nextTextBox(); |
56 if (nextBox) | 56 if (nextBox) |
57 nextBox->dirtyLineBoxes(); | 57 nextBox->dirtyLineBoxes(); |
58 } | 58 } |
59 | 59 |
60 int SVGInlineTextBox::offsetForPosition(LayoutUnit, bool) const { | 60 int SVGInlineTextBox::offsetForPosition(LayoutUnit, bool) const { |
61 // SVG doesn't use the standard offset <-> position selection system, as it's not suitable for SVGs complex needs. | 61 // SVG doesn't use the standard offset <-> position selection system, as it's |
62 // vertical text selection, inline boxes spanning multiple lines (contrary to HTML, etc.) | 62 // not suitable for SVGs complex needs. Vertical text selection, inline boxes |
63 // spanning multiple lines (contrary to HTML, etc.) | |
63 ASSERT_NOT_REACHED(); | 64 ASSERT_NOT_REACHED(); |
64 return 0; | 65 return 0; |
65 } | 66 } |
66 | 67 |
67 int SVGInlineTextBox::offsetForPositionInFragment( | 68 int SVGInlineTextBox::offsetForPositionInFragment( |
68 const SVGTextFragment& fragment, | 69 const SVGTextFragment& fragment, |
69 LayoutUnit position, | 70 LayoutUnit position, |
70 bool includePartialGlyphs) const { | 71 bool includePartialGlyphs) const { |
71 LineLayoutSVGInlineText lineLayoutItem = | 72 LineLayoutSVGInlineText lineLayoutItem = |
72 LineLayoutSVGInlineText(this->getLineLayoutItem()); | 73 LineLayoutSVGInlineText(this->getLineLayoutItem()); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
168 LayoutUnit, | 169 LayoutUnit, |
169 LayoutUnit) const { | 170 LayoutUnit) const { |
170 SVGInlineTextBoxPainter(*this).paint(paintInfo, paintOffset); | 171 SVGInlineTextBoxPainter(*this).paint(paintInfo, paintOffset); |
171 } | 172 } |
172 | 173 |
173 TextRun SVGInlineTextBox::constructTextRun( | 174 TextRun SVGInlineTextBox::constructTextRun( |
174 const ComputedStyle& style, | 175 const ComputedStyle& style, |
175 const SVGTextFragment& fragment) const { | 176 const SVGTextFragment& fragment) const { |
176 LineLayoutText text = getLineLayoutItem(); | 177 LineLayoutText text = getLineLayoutItem(); |
177 | 178 |
178 // FIXME(crbug.com/264211): This should not be necessary but can occur if we | 179 // FIXME: This should not be necessary but can occur if we layout during |
pdr.
2016/10/04 22:05:41
I will be fixing this in https://codereview.chromi
| |
179 // layout during layout. Remove this when 264211 is f ixed. | 180 // layout. Remove this when crbug.com/264211 is fixed. |
180 RELEASE_ASSERT(!text.needsLayout()); | 181 RELEASE_ASSERT(!text.needsLayout()); |
181 | 182 |
182 TextRun run( | 183 TextRun run( |
183 static_cast<const LChar*>( | 184 // Characters, will be set below if non-zero. |
184 nullptr) // characters, will be set below if non-zero. | 185 static_cast<const LChar*>(nullptr), |
185 , | 186 // Length, will be set below if non-zero. |
186 0 // length, will be set below if non-zero. | 187 0, |
187 , | 188 // xPos, only relevant with allowTabs=true. |
188 0 // xPos, only relevant with allowTabs=true | 189 0, |
189 , | 190 // Padding, only relevant for justified text, not relevant for SVG. |
190 0 // padding, only relevant for justified text, not relevant for SVG | 191 0, TextRun::AllowTrailingExpansion, direction(), |
191 , | |
192 TextRun::AllowTrailingExpansion, direction(), | |
193 dirOverride() || | 192 dirOverride() || |
194 style.rtlOrdering() == VisualOrder /* directionalOverride */); | 193 style.rtlOrdering() == VisualOrder /* directionalOverride */); |
195 | 194 |
196 if (fragment.length) { | 195 if (fragment.length) { |
197 if (text.is8Bit()) | 196 if (text.is8Bit()) |
198 run.setText(text.characters8() + fragment.characterOffset, | 197 run.setText(text.characters8() + fragment.characterOffset, |
199 fragment.length); | 198 fragment.length); |
200 else | 199 else |
201 run.setText(text.characters16() + fragment.characterOffset, | 200 run.setText(text.characters16() + fragment.characterOffset, |
202 fragment.length); | 201 fragment.length); |
203 } | 202 } |
204 | 203 |
205 // We handle letter & word spacing ourselves. | 204 // We handle letter & word spacing ourselves. |
206 run.disableSpacing(); | 205 run.disableSpacing(); |
207 | 206 |
208 // Propagate the maximum length of the characters buffer to the TextRun, even when we're only processing a substring. | 207 // Propagate the maximum length of the characters buffer to the TextRun, even |
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 ASSERT(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 |
221 // Compute positions relative to the fragment. | 221 // Compute positions relative to the fragment. |
222 startPosition -= fragmentOffsetInBox; | 222 startPosition -= fragmentOffsetInBox; |
223 endPosition -= fragmentOffsetInBox; | 223 endPosition -= fragmentOffsetInBox; |
224 | 224 |
225 // Intersect with the fragment range. | 225 // Intersect with the fragment range. |
226 startPosition = std::max(startPosition, 0); | 226 startPosition = std::max(startPosition, 0); |
227 endPosition = std::min(endPosition, static_cast<int>(fragment.length)); | 227 endPosition = std::min(endPosition, static_cast<int>(fragment.length)); |
228 | 228 |
229 return startPosition < endPosition; | 229 return startPosition < endPosition; |
230 } | 230 } |
231 | 231 |
232 void SVGInlineTextBox::paintDocumentMarker(GraphicsContext&, | 232 void SVGInlineTextBox::paintDocumentMarker(GraphicsContext&, |
233 const LayoutPoint&, | 233 const LayoutPoint&, |
234 DocumentMarker*, | 234 DocumentMarker*, |
235 const ComputedStyle&, | 235 const ComputedStyle&, |
236 const Font&, | 236 const Font&, |
237 bool) const { | 237 bool) const { |
238 // SVG does not have support for generic document markers (e.g., spellchecking , etc). | 238 // SVG does not have support for generic document markers (e.g., |
239 // spellchecking, etc). | |
239 } | 240 } |
240 | 241 |
241 void SVGInlineTextBox::paintTextMatchMarkerForeground( | 242 void SVGInlineTextBox::paintTextMatchMarkerForeground( |
242 const PaintInfo& paintInfo, | 243 const PaintInfo& paintInfo, |
243 const LayoutPoint& point, | 244 const LayoutPoint& point, |
244 DocumentMarker* marker, | 245 DocumentMarker* marker, |
245 const ComputedStyle& style, | 246 const ComputedStyle& style, |
246 const Font& font) const { | 247 const Font& font) const { |
247 SVGInlineTextBoxPainter(*this).paintTextMatchMarkerForeground( | 248 SVGInlineTextBoxPainter(*this).paintTextMatchMarkerForeground( |
248 paintInfo, point, marker, style, font); | 249 paintInfo, point, marker, style, font); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
318 return true; | 319 return true; |
319 } | 320 } |
320 } | 321 } |
321 } | 322 } |
322 } | 323 } |
323 } | 324 } |
324 return false; | 325 return false; |
325 } | 326 } |
326 | 327 |
327 } // namespace blink | 328 } // namespace blink |
OLD | NEW |