| 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 RenderSVGInlineText& textRenderer = toRenderSVGInlineText(this->renderer()); | 81 RenderSVGInlineText& textRenderer = toRenderSVGInlineText(this->renderer()); |
| 82 | 82 |
| 83 float scalingFactor = textRenderer.scalingFactor(); | 83 float scalingFactor = textRenderer.scalingFactor(); |
| 84 ASSERT(scalingFactor); | 84 ASSERT(scalingFactor); |
| 85 | 85 |
| 86 RenderStyle* style = textRenderer.style(); | 86 const RenderStyle* style = textRenderer.style(); |
| 87 ASSERT(style); | 87 ASSERT(style); |
| 88 | 88 |
| 89 TextRun textRun = constructTextRun(style, fragment); | 89 TextRun textRun = constructTextRun(style, fragment); |
| 90 | 90 |
| 91 // Eventually handle lengthAdjust="spacingAndGlyphs". | 91 // Eventually handle lengthAdjust="spacingAndGlyphs". |
| 92 // FIXME: Handle vertical text. | 92 // FIXME: Handle vertical text. |
| 93 AffineTransform fragmentTransform; | 93 AffineTransform fragmentTransform; |
| 94 fragment.buildFragmentTransform(fragmentTransform); | 94 fragment.buildFragmentTransform(fragmentTransform); |
| 95 if (!fragmentTransform.isIdentity()) | 95 if (!fragmentTransform.isIdentity()) |
| 96 textRun.setHorizontalGlyphStretch(narrowPrecisionToFloat(fragmentTransfo
rm.xScale())); | 96 textRun.setHorizontalGlyphStretch(narrowPrecisionToFloat(fragmentTransfo
rm.xScale())); |
| 97 | 97 |
| 98 return fragment.characterOffset - start() + textRenderer.scaledFont().offset
ForPosition(textRun, position * scalingFactor, includePartialGlyphs); | 98 return fragment.characterOffset - start() + textRenderer.scaledFont().offset
ForPosition(textRun, position * scalingFactor, includePartialGlyphs); |
| 99 } | 99 } |
| 100 | 100 |
| 101 FloatWillBeLayoutUnit SVGInlineTextBox::positionForOffset(int) const | 101 FloatWillBeLayoutUnit SVGInlineTextBox::positionForOffset(int) const |
| 102 { | 102 { |
| 103 // SVG doesn't use the offset <-> position selection system. | 103 // SVG doesn't use the offset <-> position selection system. |
| 104 ASSERT_NOT_REACHED(); | 104 ASSERT_NOT_REACHED(); |
| 105 return 0; | 105 return 0; |
| 106 } | 106 } |
| 107 | 107 |
| 108 FloatRectWillBeLayoutRect SVGInlineTextBox::selectionRectForTextFragment(const S
VGTextFragment& fragment, int startPosition, int endPosition, RenderStyle* style
) | 108 FloatRectWillBeLayoutRect SVGInlineTextBox::selectionRectForTextFragment(const S
VGTextFragment& fragment, int startPosition, int endPosition, const RenderStyle*
style) |
| 109 { | 109 { |
| 110 ASSERT(startPosition < endPosition); | 110 ASSERT(startPosition < endPosition); |
| 111 ASSERT(style); | 111 ASSERT(style); |
| 112 | 112 |
| 113 RenderSVGInlineText& textRenderer = toRenderSVGInlineText(this->renderer()); | 113 RenderSVGInlineText& textRenderer = toRenderSVGInlineText(this->renderer()); |
| 114 | 114 |
| 115 float scalingFactor = textRenderer.scalingFactor(); | 115 float scalingFactor = textRenderer.scalingFactor(); |
| 116 ASSERT(scalingFactor); | 116 ASSERT(scalingFactor); |
| 117 | 117 |
| 118 const Font& scaledFont = textRenderer.scaledFont(); | 118 const Font& scaledFont = textRenderer.scaledFont(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 132 } | 132 } |
| 133 | 133 |
| 134 LayoutRect SVGInlineTextBox::localSelectionRect(int startPosition, int endPositi
on) | 134 LayoutRect SVGInlineTextBox::localSelectionRect(int startPosition, int endPositi
on) |
| 135 { | 135 { |
| 136 int boxStart = start(); | 136 int boxStart = start(); |
| 137 startPosition = std::max(startPosition - boxStart, 0); | 137 startPosition = std::max(startPosition - boxStart, 0); |
| 138 endPosition = std::min(endPosition - boxStart, static_cast<int>(len())); | 138 endPosition = std::min(endPosition - boxStart, static_cast<int>(len())); |
| 139 if (startPosition >= endPosition) | 139 if (startPosition >= endPosition) |
| 140 return LayoutRect(); | 140 return LayoutRect(); |
| 141 | 141 |
| 142 RenderStyle* style = renderer().style(); | 142 const RenderStyle* style = renderer().style(); |
| 143 ASSERT(style); | 143 ASSERT(style); |
| 144 | 144 |
| 145 AffineTransform fragmentTransform; | 145 AffineTransform fragmentTransform; |
| 146 FloatRectWillBeLayoutRect selectionRect; | 146 FloatRectWillBeLayoutRect selectionRect; |
| 147 int fragmentStartPosition = 0; | 147 int fragmentStartPosition = 0; |
| 148 int fragmentEndPosition = 0; | 148 int fragmentEndPosition = 0; |
| 149 | 149 |
| 150 unsigned textFragmentsSize = m_textFragments.size(); | 150 unsigned textFragmentsSize = m_textFragments.size(); |
| 151 for (unsigned i = 0; i < textFragmentsSize; ++i) { | 151 for (unsigned i = 0; i < textFragmentsSize; ++i) { |
| 152 const SVGTextFragment& fragment = m_textFragments.at(i); | 152 const SVGTextFragment& fragment = m_textFragments.at(i); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 166 // FIXME: the call to rawValue() below is temporary and should be removed on
ce the transition | 166 // FIXME: the call to rawValue() below is temporary and should be removed on
ce the transition |
| 167 // to LayoutUnit-based types is complete (crbug.com/321237) | 167 // to LayoutUnit-based types is complete (crbug.com/321237) |
| 168 return enclosingIntRect(selectionRect.rawValue()); | 168 return enclosingIntRect(selectionRect.rawValue()); |
| 169 } | 169 } |
| 170 | 170 |
| 171 void SVGInlineTextBox::paint(const PaintInfo& paintInfo, const LayoutPoint& pain
tOffset, LayoutUnit, LayoutUnit) | 171 void SVGInlineTextBox::paint(const PaintInfo& paintInfo, const LayoutPoint& pain
tOffset, LayoutUnit, LayoutUnit) |
| 172 { | 172 { |
| 173 SVGInlineTextBoxPainter(*this).paint(paintInfo, paintOffset); | 173 SVGInlineTextBoxPainter(*this).paint(paintInfo, paintOffset); |
| 174 } | 174 } |
| 175 | 175 |
| 176 TextRun SVGInlineTextBox::constructTextRun(RenderStyle* style, const SVGTextFrag
ment& fragment) const | 176 TextRun SVGInlineTextBox::constructTextRun(const RenderStyle* style, const SVGTe
xtFragment& fragment) const |
| 177 { | 177 { |
| 178 ASSERT(style); | 178 ASSERT(style); |
| 179 | 179 |
| 180 RenderText* text = &renderer(); | 180 RenderText* text = &renderer(); |
| 181 | 181 |
| 182 // FIXME(crbug.com/264211): This should not be necessary but can occur if we | 182 // FIXME(crbug.com/264211): This should not be necessary but can occur if we |
| 183 // layout during layout. Remove this when 264211 is
fixed. | 183 // layout during layout. Remove this when 264211 is
fixed. |
| 184 RELEASE_ASSERT(!text->needsLayout()); | 184 RELEASE_ASSERT(!text->needsLayout()); |
| 185 | 185 |
| 186 TextRun run(static_cast<const LChar*>(0) // characters, will be set below if
non-zero. | 186 TextRun run(static_cast<const LChar*>(0) // characters, will be set below if
non-zero. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 endPosition = length; | 227 endPosition = length; |
| 228 else { | 228 else { |
| 229 ASSERT(endPosition >= offset); | 229 ASSERT(endPosition >= offset); |
| 230 endPosition -= offset; | 230 endPosition -= offset; |
| 231 } | 231 } |
| 232 | 232 |
| 233 ASSERT(startPosition < endPosition); | 233 ASSERT(startPosition < endPosition); |
| 234 return true; | 234 return true; |
| 235 } | 235 } |
| 236 | 236 |
| 237 void SVGInlineTextBox::paintDocumentMarker(GraphicsContext*, const FloatPointWil
lBeLayoutPoint&, DocumentMarker*, RenderStyle*, const Font&, bool) | 237 void SVGInlineTextBox::paintDocumentMarker(GraphicsContext*, const FloatPointWil
lBeLayoutPoint&, DocumentMarker*, const RenderStyle*, const Font&, bool) |
| 238 { | 238 { |
| 239 // SVG does not have support for generic document markers (e.g., spellchecki
ng, etc). | 239 // SVG does not have support for generic document markers (e.g., spellchecki
ng, etc). |
| 240 } | 240 } |
| 241 | 241 |
| 242 void SVGInlineTextBox::paintTextMatchMarker(GraphicsContext* context, const Floa
tPointWillBeLayoutPoint& point, DocumentMarker* marker, RenderStyle* style, cons
t Font& font) | 242 void SVGInlineTextBox::paintTextMatchMarker(GraphicsContext* context, const Floa
tPointWillBeLayoutPoint& point, DocumentMarker* marker, const RenderStyle* style
, const Font& font) |
| 243 { | 243 { |
| 244 SVGInlineTextBoxPainter(*this).paintTextMatchMarker(context, point.toFloatPo
int(), marker, style, font); | 244 SVGInlineTextBoxPainter(*this).paintTextMatchMarker(context, point.toFloatPo
int(), marker, style, font); |
| 245 } | 245 } |
| 246 | 246 |
| 247 FloatRectWillBeLayoutRect SVGInlineTextBox::calculateBoundaries() const | 247 FloatRectWillBeLayoutRect SVGInlineTextBox::calculateBoundaries() const |
| 248 { | 248 { |
| 249 FloatRectWillBeLayoutRect textRect; | 249 FloatRectWillBeLayoutRect textRect; |
| 250 | 250 |
| 251 RenderSVGInlineText& textRenderer = toRenderSVGInlineText(this->renderer()); | 251 RenderSVGInlineText& textRenderer = toRenderSVGInlineText(this->renderer()); |
| 252 | 252 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 renderer().updateHitTestResult(result, locationInContainer.point
() - toLayoutSize(accumulatedOffset)); | 289 renderer().updateHitTestResult(result, locationInContainer.point
() - toLayoutSize(accumulatedOffset)); |
| 290 if (!result.addNodeToRectBasedTestResult(renderer().node(), requ
est, locationInContainer, rect.rawValue())) | 290 if (!result.addNodeToRectBasedTestResult(renderer().node(), requ
est, locationInContainer, rect.rawValue())) |
| 291 return true; | 291 return true; |
| 292 } | 292 } |
| 293 } | 293 } |
| 294 } | 294 } |
| 295 return false; | 295 return false; |
| 296 } | 296 } |
| 297 | 297 |
| 298 } // namespace blink | 298 } // namespace blink |
| OLD | NEW |