| OLD | NEW | 
|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "config.h" | 5 #include "config.h" | 
| 6 #include "core/paint/SVGInlineTextBoxPainter.h" | 6 #include "core/paint/SVGInlineTextBoxPainter.h" | 
| 7 | 7 | 
| 8 #include "core/dom/DocumentMarkerController.h" | 8 #include "core/dom/DocumentMarkerController.h" | 
| 9 #include "core/dom/RenderedDocumentMarker.h" | 9 #include "core/dom/RenderedDocumentMarker.h" | 
| 10 #include "core/editing/Editor.h" | 10 #include "core/editing/Editor.h" | 
| (...skipping 14 matching lines...) Expand all  Loading... | 
| 25 | 25 | 
| 26 static inline bool textShouldBePainted(LayoutSVGInlineText& textRenderer) | 26 static inline bool textShouldBePainted(LayoutSVGInlineText& textRenderer) | 
| 27 { | 27 { | 
| 28     // Font::pixelSize(), returns FontDescription::computedPixelSize(), which re
     turns "int(x + 0.5)". | 28     // Font::pixelSize(), returns FontDescription::computedPixelSize(), which re
     turns "int(x + 0.5)". | 
| 29     // If the absolute font size on screen is below x=0.5, don't render anything
     . | 29     // If the absolute font size on screen is below x=0.5, don't render anything
     . | 
| 30     return textRenderer.scaledFont().fontDescription().computedPixelSize(); | 30     return textRenderer.scaledFont().fontDescription().computedPixelSize(); | 
| 31 } | 31 } | 
| 32 | 32 | 
| 33 bool SVGInlineTextBoxPainter::shouldPaintSelection() const | 33 bool SVGInlineTextBoxPainter::shouldPaintSelection() const | 
| 34 { | 34 { | 
| 35     bool isPrinting = m_svgInlineTextBox.renderer().document().printing(); | 35     bool isPrinting = m_svgInlineTextBox.layoutObject().document().printing(); | 
| 36     return !isPrinting && m_svgInlineTextBox.selectionState() != LayoutObject::S
     electionNone; | 36     return !isPrinting && m_svgInlineTextBox.selectionState() != LayoutObject::S
     electionNone; | 
| 37 } | 37 } | 
| 38 | 38 | 
| 39 void SVGInlineTextBoxPainter::paint(const PaintInfo& paintInfo, const LayoutPoin
     t& paintOffset) | 39 void SVGInlineTextBoxPainter::paint(const PaintInfo& paintInfo, const LayoutPoin
     t& paintOffset) | 
| 40 { | 40 { | 
| 41     ASSERT(paintInfo.shouldPaintWithinRoot(&m_svgInlineTextBox.renderer())); | 41     ASSERT(paintInfo.shouldPaintWithinRoot(&m_svgInlineTextBox.layoutObject())); | 
| 42     ASSERT(paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPh
     aseSelection); | 42     ASSERT(paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPh
     aseSelection); | 
| 43     ASSERT(m_svgInlineTextBox.truncation() == cNoTruncation); | 43     ASSERT(m_svgInlineTextBox.truncation() == cNoTruncation); | 
| 44 | 44 | 
| 45     if (m_svgInlineTextBox.renderer().style()->visibility() != VISIBLE) | 45     if (m_svgInlineTextBox.layoutObject().style()->visibility() != VISIBLE) | 
| 46         return; | 46         return; | 
| 47 | 47 | 
| 48     // We're explicitly not supporting composition & custom underlines and custo
     m highlighters -- unlike InlineTextBox. | 48     // We're explicitly not supporting composition & custom underlines and custo
     m highlighters -- unlike InlineTextBox. | 
| 49     // If we ever need that for SVG, it's very easy to refactor and reuse the co
     de. | 49     // If we ever need that for SVG, it's very easy to refactor and reuse the co
     de. | 
| 50 | 50 | 
| 51     if (paintInfo.phase == PaintPhaseSelection && !shouldPaintSelection()) | 51     if (paintInfo.phase == PaintPhaseSelection && !shouldPaintSelection()) | 
| 52         return; | 52         return; | 
| 53 | 53 | 
| 54     LayoutSVGInlineText& textRenderer = toLayoutSVGInlineText(m_svgInlineTextBox
     .renderer()); | 54     LayoutSVGInlineText& textRenderer = toLayoutSVGInlineText(m_svgInlineTextBox
     .layoutObject()); | 
| 55     if (!textShouldBePainted(textRenderer)) | 55     if (!textShouldBePainted(textRenderer)) | 
| 56         return; | 56         return; | 
| 57 | 57 | 
| 58     LayoutObject& parentRenderer = m_svgInlineTextBox.parent()->renderer(); | 58     LayoutObject& parentRenderer = m_svgInlineTextBox.parent()->layoutObject(); | 
| 59     const LayoutStyle& style = parentRenderer.styleRef(); | 59     const LayoutStyle& style = parentRenderer.styleRef(); | 
| 60 | 60 | 
| 61     InlineTextBoxPainter(m_svgInlineTextBox).paintDocumentMarkers( | 61     InlineTextBoxPainter(m_svgInlineTextBox).paintDocumentMarkers( | 
| 62         paintInfo.context, FloatPoint(paintOffset), style, | 62         paintInfo.context, FloatPoint(paintOffset), style, | 
| 63         textRenderer.scaledFont(), true); | 63         textRenderer.scaledFont(), true); | 
| 64 | 64 | 
| 65     if (!m_svgInlineTextBox.textFragments().isEmpty()) { | 65     if (!m_svgInlineTextBox.textFragments().isEmpty()) { | 
| 66         DrawingRecorder recorder(paintInfo.context, m_svgInlineTextBox.displayIt
     emClient(), DisplayItem::paintPhaseToDrawingType(paintInfo.phase), paintInfo.rec
     t); | 66         DrawingRecorder recorder(paintInfo.context, m_svgInlineTextBox.displayIt
     emClient(), DisplayItem::paintPhaseToDrawingType(paintInfo.phase), paintInfo.rec
     t); | 
| 67         if (!recorder.canUseCachedDrawing()) | 67         if (!recorder.canUseCachedDrawing()) | 
| 68             paintTextFragments(paintInfo, parentRenderer); | 68             paintTextFragments(paintInfo, parentRenderer); | 
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 140         } | 140         } | 
| 141 | 141 | 
| 142         // Spec: Line-through should be drawn after the text is filled and strok
     ed; thus, the line-through is rendered on top of the text. | 142         // Spec: Line-through should be drawn after the text is filled and strok
     ed; thus, the line-through is rendered on top of the text. | 
| 143         if (decorations & TextDecorationLineThrough) | 143         if (decorations & TextDecorationLineThrough) | 
| 144             paintDecoration(paintInfo, TextDecorationLineThrough, fragment); | 144             paintDecoration(paintInfo, TextDecorationLineThrough, fragment); | 
| 145     } | 145     } | 
| 146 } | 146 } | 
| 147 | 147 | 
| 148 void SVGInlineTextBoxPainter::paintSelectionBackground(const PaintInfo& paintInf
     o) | 148 void SVGInlineTextBoxPainter::paintSelectionBackground(const PaintInfo& paintInf
     o) | 
| 149 { | 149 { | 
| 150     if (m_svgInlineTextBox.renderer().style()->visibility() != VISIBLE) | 150     if (m_svgInlineTextBox.layoutObject().style()->visibility() != VISIBLE) | 
| 151         return; | 151         return; | 
| 152 | 152 | 
| 153     ASSERT(!m_svgInlineTextBox.renderer().document().printing()); | 153     ASSERT(!m_svgInlineTextBox.layoutObject().document().printing()); | 
| 154 | 154 | 
| 155     if (paintInfo.phase == PaintPhaseSelection || !shouldPaintSelection()) | 155     if (paintInfo.phase == PaintPhaseSelection || !shouldPaintSelection()) | 
| 156         return; | 156         return; | 
| 157 | 157 | 
| 158     Color backgroundColor = m_svgInlineTextBox.renderer().selectionBackgroundCol
     or(); | 158     Color backgroundColor = m_svgInlineTextBox.layoutObject().selectionBackgroun
     dColor(); | 
| 159     if (!backgroundColor.alpha()) | 159     if (!backgroundColor.alpha()) | 
| 160         return; | 160         return; | 
| 161 | 161 | 
| 162     LayoutSVGInlineText& textRenderer = toLayoutSVGInlineText(m_svgInlineTextBox
     .renderer()); | 162     LayoutSVGInlineText& textRenderer = toLayoutSVGInlineText(m_svgInlineTextBox
     .layoutObject()); | 
| 163     if (!textShouldBePainted(textRenderer)) | 163     if (!textShouldBePainted(textRenderer)) | 
| 164         return; | 164         return; | 
| 165 | 165 | 
| 166     const LayoutStyle& style = m_svgInlineTextBox.parent()->renderer().styleRef(
     ); | 166     const LayoutStyle& style = m_svgInlineTextBox.parent()->layoutObject().style
     Ref(); | 
| 167 | 167 | 
| 168     int startPosition, endPosition; | 168     int startPosition, endPosition; | 
| 169     m_svgInlineTextBox.selectionStartEnd(startPosition, endPosition); | 169     m_svgInlineTextBox.selectionStartEnd(startPosition, endPosition); | 
| 170 | 170 | 
| 171     int fragmentStartPosition = 0; | 171     int fragmentStartPosition = 0; | 
| 172     int fragmentEndPosition = 0; | 172     int fragmentEndPosition = 0; | 
| 173     AffineTransform fragmentTransform; | 173     AffineTransform fragmentTransform; | 
| 174     unsigned textFragmentsSize = m_svgInlineTextBox.textFragments().size(); | 174     unsigned textFragmentsSize = m_svgInlineTextBox.textFragments().size(); | 
| 175     for (unsigned i = 0; i < textFragmentsSize; ++i) { | 175     for (unsigned i = 0; i < textFragmentsSize; ++i) { | 
| 176         SVGTextFragment& fragment = m_svgInlineTextBox.textFragments().at(i); | 176         SVGTextFragment& fragment = m_svgInlineTextBox.textFragments().at(i); | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
| 188         paintInfo.context->setFillColor(backgroundColor); | 188         paintInfo.context->setFillColor(backgroundColor); | 
| 189         paintInfo.context->fillRect(m_svgInlineTextBox.selectionRectForTextFragm
     ent(fragment, fragmentStartPosition, fragmentEndPosition, style).toFloatRect(), 
     backgroundColor); | 189         paintInfo.context->fillRect(m_svgInlineTextBox.selectionRectForTextFragm
     ent(fragment, fragmentStartPosition, fragmentEndPosition, style).toFloatRect(), 
     backgroundColor); | 
| 190     } | 190     } | 
| 191 } | 191 } | 
| 192 | 192 | 
| 193 static inline LayoutObject* findLayoutObjectDefininingTextDecoration(InlineFlowB
     ox* parentBox) | 193 static inline LayoutObject* findLayoutObjectDefininingTextDecoration(InlineFlowB
     ox* parentBox) | 
| 194 { | 194 { | 
| 195     // Lookup first render object in parent hierarchy which has text-decoration 
     set. | 195     // Lookup first render object in parent hierarchy which has text-decoration 
     set. | 
| 196     LayoutObject* renderer = 0; | 196     LayoutObject* renderer = 0; | 
| 197     while (parentBox) { | 197     while (parentBox) { | 
| 198         renderer = &parentBox->renderer(); | 198         renderer = &parentBox->layoutObject(); | 
| 199 | 199 | 
| 200         if (renderer->style() && renderer->style()->textDecoration() != TextDeco
     rationNone) | 200         if (renderer->style() && renderer->style()->textDecoration() != TextDeco
     rationNone) | 
| 201             break; | 201             break; | 
| 202 | 202 | 
| 203         parentBox = parentBox->parent(); | 203         parentBox = parentBox->parent(); | 
| 204     } | 204     } | 
| 205 | 205 | 
| 206     ASSERT(renderer); | 206     ASSERT(renderer); | 
| 207     return renderer; | 207     return renderer; | 
| 208 } | 208 } | 
| (...skipping 16 matching lines...) Expand all  Loading... | 
| 225 | 225 | 
| 226 static inline float thicknessForDecoration(TextDecoration, const Font& font) | 226 static inline float thicknessForDecoration(TextDecoration, const Font& font) | 
| 227 { | 227 { | 
| 228     // FIXME: For SVG Fonts we need to use the attributes defined in the <font-f
     ace> if specified. | 228     // FIXME: For SVG Fonts we need to use the attributes defined in the <font-f
     ace> if specified. | 
| 229     // Compatible with Batik/Presto | 229     // Compatible with Batik/Presto | 
| 230     return font.fontDescription().computedSize() / 20.0f; | 230     return font.fontDescription().computedSize() / 20.0f; | 
| 231 } | 231 } | 
| 232 | 232 | 
| 233 void SVGInlineTextBoxPainter::paintDecoration(const PaintInfo& paintInfo, TextDe
     coration decoration, const SVGTextFragment& fragment) | 233 void SVGInlineTextBoxPainter::paintDecoration(const PaintInfo& paintInfo, TextDe
     coration decoration, const SVGTextFragment& fragment) | 
| 234 { | 234 { | 
| 235     if (m_svgInlineTextBox.renderer().style()->textDecorationsInEffect() == Text
     DecorationNone) | 235     if (m_svgInlineTextBox.layoutObject().style()->textDecorationsInEffect() == 
     TextDecorationNone) | 
| 236         return; | 236         return; | 
| 237 | 237 | 
| 238     if (fragment.width <= 0) | 238     if (fragment.width <= 0) | 
| 239         return; | 239         return; | 
| 240 | 240 | 
| 241     // Find out which render style defined the text-decoration, as its fill/stro
     ke properties have to be used for drawing instead of ours. | 241     // Find out which render style defined the text-decoration, as its fill/stro
     ke properties have to be used for drawing instead of ours. | 
| 242     LayoutObject* decorationRenderer = findLayoutObjectDefininingTextDecoration(
     m_svgInlineTextBox.parent()); | 242     LayoutObject* decorationRenderer = findLayoutObjectDefininingTextDecoration(
     m_svgInlineTextBox.parent()); | 
| 243     const LayoutStyle& decorationStyle = decorationRenderer->styleRef(); | 243     const LayoutStyle& decorationStyle = decorationRenderer->styleRef(); | 
| 244 | 244 | 
| 245     if (decorationStyle.visibility() == HIDDEN) | 245     if (decorationStyle.visibility() == HIDDEN) | 
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 286         default: | 286         default: | 
| 287             ASSERT_NOT_REACHED(); | 287             ASSERT_NOT_REACHED(); | 
| 288         } | 288         } | 
| 289     } | 289     } | 
| 290 } | 290 } | 
| 291 | 291 | 
| 292 void SVGInlineTextBoxPainter::paintTextWithShadows(const PaintInfo& paintInfo, c
     onst LayoutStyle& style, | 292 void SVGInlineTextBoxPainter::paintTextWithShadows(const PaintInfo& paintInfo, c
     onst LayoutStyle& style, | 
| 293     TextRun& textRun, const SVGTextFragment& fragment, int startPosition, int en
     dPosition, | 293     TextRun& textRun, const SVGTextFragment& fragment, int startPosition, int en
     dPosition, | 
| 294     LayoutSVGResourceMode resourceMode) | 294     LayoutSVGResourceMode resourceMode) | 
| 295 { | 295 { | 
| 296     LayoutSVGInlineText& textRenderer = toLayoutSVGInlineText(m_svgInlineTextBox
     .renderer()); | 296     LayoutSVGInlineText& textRenderer = toLayoutSVGInlineText(m_svgInlineTextBox
     .layoutObject()); | 
| 297 | 297 | 
| 298     float scalingFactor = textRenderer.scalingFactor(); | 298     float scalingFactor = textRenderer.scalingFactor(); | 
| 299     ASSERT(scalingFactor); | 299     ASSERT(scalingFactor); | 
| 300 | 300 | 
| 301     const Font& scaledFont = textRenderer.scaledFont(); | 301     const Font& scaledFont = textRenderer.scaledFont(); | 
| 302     const ShadowList* shadowList = style.textShadow(); | 302     const ShadowList* shadowList = style.textShadow(); | 
| 303     GraphicsContext* context = paintInfo.context; | 303     GraphicsContext* context = paintInfo.context; | 
| 304 | 304 | 
| 305     // Text shadows are disabled when printing. http://crbug.com/258321 | 305     // Text shadows are disabled when printing. http://crbug.com/258321 | 
| 306     bool hasShadow = shadowList && !context->printing(); | 306     bool hasShadow = shadowList && !context->printing(); | 
| 307 | 307 | 
| 308     FloatPoint textOrigin(fragment.x, fragment.y); | 308     FloatPoint textOrigin(fragment.x, fragment.y); | 
| 309     FloatSize textSize(fragment.width, fragment.height); | 309     FloatSize textSize(fragment.width, fragment.height); | 
| 310     AffineTransform paintServerTransform; | 310     AffineTransform paintServerTransform; | 
| 311     const AffineTransform* additionalPaintServerTransform = 0; | 311     const AffineTransform* additionalPaintServerTransform = 0; | 
| 312 | 312 | 
| 313     GraphicsContextStateSaver stateSaver(*context, false); | 313     GraphicsContextStateSaver stateSaver(*context, false); | 
| 314     if (scalingFactor != 1) { | 314     if (scalingFactor != 1) { | 
| 315         textOrigin.scale(scalingFactor, scalingFactor); | 315         textOrigin.scale(scalingFactor, scalingFactor); | 
| 316         textSize.scale(scalingFactor); | 316         textSize.scale(scalingFactor); | 
| 317         stateSaver.save(); | 317         stateSaver.save(); | 
| 318         context->scale(1 / scalingFactor, 1 / scalingFactor); | 318         context->scale(1 / scalingFactor, 1 / scalingFactor); | 
| 319         // Adjust the paint-server coordinate space. | 319         // Adjust the paint-server coordinate space. | 
| 320         paintServerTransform.scale(scalingFactor); | 320         paintServerTransform.scale(scalingFactor); | 
| 321         additionalPaintServerTransform = &paintServerTransform; | 321         additionalPaintServerTransform = &paintServerTransform; | 
| 322     } | 322     } | 
| 323 | 323 | 
| 324     // FIXME: Non-scaling stroke is not applied here. | 324     // FIXME: Non-scaling stroke is not applied here. | 
| 325 | 325 | 
| 326     if (!SVGLayoutSupport::updateGraphicsContext(paintInfo, stateSaver, style, m
     _svgInlineTextBox.parent()->renderer(), resourceMode, additionalPaintServerTrans
     form)) | 326     if (!SVGLayoutSupport::updateGraphicsContext(paintInfo, stateSaver, style, m
     _svgInlineTextBox.parent()->layoutObject(), resourceMode, additionalPaintServerT
     ransform)) | 
| 327         return; | 327         return; | 
| 328 | 328 | 
| 329     if (hasShadow) { | 329     if (hasShadow) { | 
| 330         stateSaver.saveIfNeeded(); | 330         stateSaver.saveIfNeeded(); | 
| 331         context->setDrawLooper(shadowList->createDrawLooper(DrawLooperBuilder::S
     hadowRespectsAlpha)); | 331         context->setDrawLooper(shadowList->createDrawLooper(DrawLooperBuilder::S
     hadowRespectsAlpha)); | 
| 332     } | 332     } | 
| 333 | 333 | 
| 334     context->setTextDrawingMode(resourceMode == ApplyToFillMode ? TextModeFill :
      TextModeStroke); | 334     context->setTextDrawingMode(resourceMode == ApplyToFillMode ? TextModeFill :
      TextModeStroke); | 
| 335 | 335 | 
| 336     if (scalingFactor != 1 && resourceMode == ApplyToStrokeMode) | 336     if (scalingFactor != 1 && resourceMode == ApplyToStrokeMode) | 
| (...skipping 30 matching lines...) Expand all  Loading... | 
| 367 | 367 | 
| 368     // Eventually draw text using regular style until the start position of the 
     selection | 368     // Eventually draw text using regular style until the start position of the 
     selection | 
| 369     bool paintSelectedTextOnly = paintInfo.phase == PaintPhaseSelection; | 369     bool paintSelectedTextOnly = paintInfo.phase == PaintPhaseSelection; | 
| 370     if (startPosition > 0 && !paintSelectedTextOnly) | 370     if (startPosition > 0 && !paintSelectedTextOnly) | 
| 371         paintTextWithShadows(paintInfo, style, textRun, fragment, 0, startPositi
     on, resourceMode); | 371         paintTextWithShadows(paintInfo, style, textRun, fragment, 0, startPositi
     on, resourceMode); | 
| 372 | 372 | 
| 373     // Draw text using selection style from the start to the end position of the
      selection | 373     // Draw text using selection style from the start to the end position of the
      selection | 
| 374     if (style != selectionStyle) { | 374     if (style != selectionStyle) { | 
| 375         StyleDifference diff; | 375         StyleDifference diff; | 
| 376         diff.setNeedsPaintInvalidationObject(); | 376         diff.setNeedsPaintInvalidationObject(); | 
| 377         SVGResourcesCache::clientStyleChanged(&m_svgInlineTextBox.parent()->rend
     erer(), diff, selectionStyle); | 377         SVGResourcesCache::clientStyleChanged(&m_svgInlineTextBox.parent()->layo
     utObject(), diff, selectionStyle); | 
| 378     } | 378     } | 
| 379 | 379 | 
| 380     paintTextWithShadows(paintInfo, selectionStyle, textRun, fragment, startPosi
     tion, endPosition, resourceMode); | 380     paintTextWithShadows(paintInfo, selectionStyle, textRun, fragment, startPosi
     tion, endPosition, resourceMode); | 
| 381 | 381 | 
| 382     if (style != selectionStyle) { | 382     if (style != selectionStyle) { | 
| 383         StyleDifference diff; | 383         StyleDifference diff; | 
| 384         diff.setNeedsPaintInvalidationObject(); | 384         diff.setNeedsPaintInvalidationObject(); | 
| 385         SVGResourcesCache::clientStyleChanged(&m_svgInlineTextBox.parent()->rend
     erer(), diff, style); | 385         SVGResourcesCache::clientStyleChanged(&m_svgInlineTextBox.parent()->layo
     utObject(), diff, style); | 
| 386     } | 386     } | 
| 387 | 387 | 
| 388     // Eventually draw text using regular style from the end position of the sel
     ection to the end of the current chunk part | 388     // Eventually draw text using regular style from the end position of the sel
     ection to the end of the current chunk part | 
| 389     if (endPosition < static_cast<int>(fragment.length) && !paintSelectedTextOnl
     y) | 389     if (endPosition < static_cast<int>(fragment.length) && !paintSelectedTextOnl
     y) | 
| 390         paintTextWithShadows(paintInfo, style, textRun, fragment, endPosition, f
     ragment.length, resourceMode); | 390         paintTextWithShadows(paintInfo, style, textRun, fragment, endPosition, f
     ragment.length, resourceMode); | 
| 391 } | 391 } | 
| 392 | 392 | 
| 393 void SVGInlineTextBoxPainter::paintTextMatchMarker(GraphicsContext* context, con
     st FloatPoint&, DocumentMarker* marker, const LayoutStyle& style, const Font& fo
     nt) | 393 void SVGInlineTextBoxPainter::paintTextMatchMarker(GraphicsContext* context, con
     st FloatPoint&, DocumentMarker* marker, const LayoutStyle& style, const Font& fo
     nt) | 
| 394 { | 394 { | 
| 395     // SVG is only interested in the TextMatch markers. | 395     // SVG is only interested in the TextMatch markers. | 
| 396     if (marker->type() != DocumentMarker::TextMatch) | 396     if (marker->type() != DocumentMarker::TextMatch) | 
| 397         return; | 397         return; | 
| 398 | 398 | 
| 399     LayoutSVGInlineText& textRenderer = toLayoutSVGInlineText(m_svgInlineTextBox
     .renderer()); | 399     LayoutSVGInlineText& textRenderer = toLayoutSVGInlineText(m_svgInlineTextBox
     .layoutObject()); | 
| 400 | 400 | 
| 401     FloatRect markerRect; | 401     FloatRect markerRect; | 
| 402     AffineTransform fragmentTransform; | 402     AffineTransform fragmentTransform; | 
| 403     for (InlineTextBox* box = textRenderer.firstTextBox(); box; box = box->nextT
     extBox()) { | 403     for (InlineTextBox* box = textRenderer.firstTextBox(); box; box = box->nextT
     extBox()) { | 
| 404         if (!box->isSVGInlineTextBox()) | 404         if (!box->isSVGInlineTextBox()) | 
| 405             continue; | 405             continue; | 
| 406 | 406 | 
| 407         SVGInlineTextBox* textBox = toSVGInlineTextBox(box); | 407         SVGInlineTextBox* textBox = toSVGInlineTextBox(box); | 
| 408 | 408 | 
| 409         int markerStartPosition = std::max<int>(marker->startOffset() - textBox-
     >start(), 0); | 409         int markerStartPosition = std::max<int>(marker->startOffset() - textBox-
     >start(), 0); | 
| 410         int markerEndPosition = std::min<int>(marker->endOffset() - textBox->sta
     rt(), textBox->len()); | 410         int markerEndPosition = std::min<int>(marker->endOffset() - textBox->sta
     rt(), textBox->len()); | 
| 411 | 411 | 
| 412         if (markerStartPosition >= markerEndPosition) | 412         if (markerStartPosition >= markerEndPosition) | 
| 413             continue; | 413             continue; | 
| 414 | 414 | 
| 415         const Vector<SVGTextFragment>& fragments = textBox->textFragments(); | 415         const Vector<SVGTextFragment>& fragments = textBox->textFragments(); | 
| 416         unsigned textFragmentsSize = fragments.size(); | 416         unsigned textFragmentsSize = fragments.size(); | 
| 417         for (unsigned i = 0; i < textFragmentsSize; ++i) { | 417         for (unsigned i = 0; i < textFragmentsSize; ++i) { | 
| 418             const SVGTextFragment& fragment = fragments.at(i); | 418             const SVGTextFragment& fragment = fragments.at(i); | 
| 419 | 419 | 
| 420             int fragmentStartPosition = markerStartPosition; | 420             int fragmentStartPosition = markerStartPosition; | 
| 421             int fragmentEndPosition = markerEndPosition; | 421             int fragmentEndPosition = markerEndPosition; | 
| 422             if (!textBox->mapStartEndPositionsIntoFragmentCoordinates(fragment, 
     fragmentStartPosition, fragmentEndPosition)) | 422             if (!textBox->mapStartEndPositionsIntoFragmentCoordinates(fragment, 
     fragmentStartPosition, fragmentEndPosition)) | 
| 423                 continue; | 423                 continue; | 
| 424 | 424 | 
| 425             FloatRect fragmentRect = textBox->selectionRectForTextFragment(fragm
     ent, fragmentStartPosition, fragmentEndPosition, style).toFloatRect(); | 425             FloatRect fragmentRect = textBox->selectionRectForTextFragment(fragm
     ent, fragmentStartPosition, fragmentEndPosition, style).toFloatRect(); | 
| 426             fragment.buildFragmentTransform(fragmentTransform); | 426             fragment.buildFragmentTransform(fragmentTransform); | 
| 427 | 427 | 
| 428             // Draw the marker highlight. | 428             // Draw the marker highlight. | 
| 429             if (m_svgInlineTextBox.renderer().frame()->editor().markedTextMatche
     sAreHighlighted()) { | 429             if (m_svgInlineTextBox.layoutObject().frame()->editor().markedTextMa
     tchesAreHighlighted()) { | 
| 430                 Color color = marker->activeMatch() ? | 430                 Color color = marker->activeMatch() ? | 
| 431                     LayoutTheme::theme().platformActiveTextSearchHighlightColor(
     ) : | 431                     LayoutTheme::theme().platformActiveTextSearchHighlightColor(
     ) : | 
| 432                     LayoutTheme::theme().platformInactiveTextSearchHighlightColo
     r(); | 432                     LayoutTheme::theme().platformInactiveTextSearchHighlightColo
     r(); | 
| 433                 GraphicsContextStateSaver stateSaver(*context); | 433                 GraphicsContextStateSaver stateSaver(*context); | 
| 434                 if (!fragmentTransform.isIdentity()) | 434                 if (!fragmentTransform.isIdentity()) | 
| 435                     context->concatCTM(fragmentTransform); | 435                     context->concatCTM(fragmentTransform); | 
| 436                 context->setFillColor(color); | 436                 context->setFillColor(color); | 
| 437                 context->fillRect(fragmentRect, color); | 437                 context->fillRect(fragmentRect, color); | 
| 438             } | 438             } | 
| 439 | 439 | 
| 440             fragmentRect = fragmentTransform.mapRect(fragmentRect); | 440             fragmentRect = fragmentTransform.mapRect(fragmentRect); | 
| 441             markerRect.unite(fragmentRect); | 441             markerRect.unite(fragmentRect); | 
| 442         } | 442         } | 
| 443     } | 443     } | 
| 444 | 444 | 
| 445     toRenderedDocumentMarker(marker)->setRenderedRect(LayoutRect(textRenderer.lo
     calToAbsoluteQuad(markerRect).enclosingBoundingBox())); | 445     toRenderedDocumentMarker(marker)->setRenderedRect(LayoutRect(textRenderer.lo
     calToAbsoluteQuad(markerRect).enclosingBoundingBox())); | 
| 446 } | 446 } | 
| 447 | 447 | 
| 448 } // namespace blink | 448 } // namespace blink | 
| OLD | NEW | 
|---|