Chromium Code Reviews| 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 30 matching lines...) Expand all Loading... | |
| 41 #include "core/rendering/svg/SVGTextRunRenderingContext.h" | 41 #include "core/rendering/svg/SVGTextRunRenderingContext.h" |
| 42 #include "platform/FloatConversion.h" | 42 #include "platform/FloatConversion.h" |
| 43 #include "platform/fonts/FontCache.h" | 43 #include "platform/fonts/FontCache.h" |
| 44 #include "platform/graphics/GraphicsContextStateSaver.h" | 44 #include "platform/graphics/GraphicsContextStateSaver.h" |
| 45 | 45 |
| 46 namespace blink { | 46 namespace blink { |
| 47 | 47 |
| 48 struct ExpectedSVGInlineTextBoxSize : public InlineTextBox { | 48 struct ExpectedSVGInlineTextBoxSize : public InlineTextBox { |
| 49 float float1; | 49 float float1; |
| 50 uint32_t bitfields : 1; | 50 uint32_t bitfields : 1; |
| 51 void* pointer; | |
| 52 Vector<SVGTextFragment> vector; | 51 Vector<SVGTextFragment> vector; |
| 53 }; | 52 }; |
| 54 | 53 |
| 55 COMPILE_ASSERT(sizeof(SVGInlineTextBox) == sizeof(ExpectedSVGInlineTextBoxSize), SVGInlineTextBox_is_not_of_expected_size); | 54 COMPILE_ASSERT(sizeof(SVGInlineTextBox) == sizeof(ExpectedSVGInlineTextBoxSize), SVGInlineTextBox_is_not_of_expected_size); |
| 56 | 55 |
| 57 SVGInlineTextBox::SVGInlineTextBox(RenderObject& object) | 56 SVGInlineTextBox::SVGInlineTextBox(RenderObject& object) |
| 58 : InlineTextBox(object) | 57 : InlineTextBox(object) |
| 59 , m_logicalHeight(0) | 58 , m_logicalHeight(0) |
| 60 , m_startsNewTextChunk(false) | 59 , m_startsNewTextChunk(false) |
| 61 , m_paintingResource(0) | |
| 62 { | 60 { |
| 63 } | 61 } |
| 64 | 62 |
| 65 void SVGInlineTextBox::dirtyLineBoxes() | 63 void SVGInlineTextBox::dirtyLineBoxes() |
| 66 { | 64 { |
| 67 InlineTextBox::dirtyLineBoxes(); | 65 InlineTextBox::dirtyLineBoxes(); |
| 68 | 66 |
| 69 // Clear the now stale text fragments | 67 // Clear the now stale text fragments |
| 70 clearTextFragments(); | 68 clearTextFragments(); |
| 71 | 69 |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 214 | 212 |
| 215 int startPosition, endPosition; | 213 int startPosition, endPosition; |
| 216 selectionStartEnd(startPosition, endPosition); | 214 selectionStartEnd(startPosition, endPosition); |
| 217 | 215 |
| 218 int fragmentStartPosition = 0; | 216 int fragmentStartPosition = 0; |
| 219 int fragmentEndPosition = 0; | 217 int fragmentEndPosition = 0; |
| 220 AffineTransform fragmentTransform; | 218 AffineTransform fragmentTransform; |
| 221 unsigned textFragmentsSize = m_textFragments.size(); | 219 unsigned textFragmentsSize = m_textFragments.size(); |
| 222 for (unsigned i = 0; i < textFragmentsSize; ++i) { | 220 for (unsigned i = 0; i < textFragmentsSize; ++i) { |
| 223 SVGTextFragment& fragment = m_textFragments.at(i); | 221 SVGTextFragment& fragment = m_textFragments.at(i); |
| 224 ASSERT(!m_paintingResource); | |
| 225 | 222 |
| 226 fragmentStartPosition = startPosition; | 223 fragmentStartPosition = startPosition; |
| 227 fragmentEndPosition = endPosition; | 224 fragmentEndPosition = endPosition; |
| 228 if (!mapStartEndPositionsIntoFragmentCoordinates(fragment, fragmentStart Position, fragmentEndPosition)) | 225 if (!mapStartEndPositionsIntoFragmentCoordinates(fragment, fragmentStart Position, fragmentEndPosition)) |
| 229 continue; | 226 continue; |
| 230 | 227 |
| 231 GraphicsContextStateSaver stateSaver(*paintInfo.context); | 228 GraphicsContextStateSaver stateSaver(*paintInfo.context); |
| 232 fragment.buildFragmentTransform(fragmentTransform); | 229 fragment.buildFragmentTransform(fragmentTransform); |
| 233 if (!fragmentTransform.isIdentity()) | 230 if (!fragmentTransform.isIdentity()) |
| 234 paintInfo.context->concatCTM(fragmentTransform); | 231 paintInfo.context->concatCTM(fragmentTransform); |
| 235 | 232 |
| 236 paintInfo.context->setFillColor(backgroundColor); | 233 paintInfo.context->setFillColor(backgroundColor); |
| 237 paintInfo.context->fillRect(selectionRectForTextFragment(fragment, fragm entStartPosition, fragmentEndPosition, style), backgroundColor); | 234 paintInfo.context->fillRect(selectionRectForTextFragment(fragment, fragm entStartPosition, fragmentEndPosition, style), backgroundColor); |
| 238 } | 235 } |
| 239 | |
| 240 ASSERT(!m_paintingResource); | |
| 241 } | 236 } |
| 242 | 237 |
| 243 void SVGInlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffse t, LayoutUnit, LayoutUnit) | 238 void SVGInlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffse t, LayoutUnit, LayoutUnit) |
| 244 { | 239 { |
| 245 ASSERT(paintInfo.shouldPaintWithinRoot(&renderer())); | 240 ASSERT(paintInfo.shouldPaintWithinRoot(&renderer())); |
| 246 ASSERT(paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPh aseSelection); | 241 ASSERT(paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPh aseSelection); |
| 247 ASSERT(truncation() == cNoTruncation); | 242 ASSERT(truncation() == cNoTruncation); |
| 248 | 243 |
| 249 if (renderer().style()->visibility() != VISIBLE) | 244 if (renderer().style()->visibility() != VISIBLE) |
| 250 return; | 245 return; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 290 | 285 |
| 291 if (textRenderer.frame() && textRenderer.frame()->view() && textRenderer.fra me()->view()->paintBehavior() & PaintBehaviorRenderingSVGMask) { | 286 if (textRenderer.frame() && textRenderer.frame()->view() && textRenderer.fra me()->view()->paintBehavior() & PaintBehaviorRenderingSVGMask) { |
| 292 hasFill = true; | 287 hasFill = true; |
| 293 hasVisibleStroke = false; | 288 hasVisibleStroke = false; |
| 294 } | 289 } |
| 295 | 290 |
| 296 AffineTransform fragmentTransform; | 291 AffineTransform fragmentTransform; |
| 297 unsigned textFragmentsSize = m_textFragments.size(); | 292 unsigned textFragmentsSize = m_textFragments.size(); |
| 298 for (unsigned i = 0; i < textFragmentsSize; ++i) { | 293 for (unsigned i = 0; i < textFragmentsSize; ++i) { |
| 299 SVGTextFragment& fragment = m_textFragments.at(i); | 294 SVGTextFragment& fragment = m_textFragments.at(i); |
| 300 ASSERT(!m_paintingResource); | |
| 301 | 295 |
| 302 GraphicsContextStateSaver stateSaver(*paintInfo.context, false); | 296 GraphicsContextStateSaver stateSaver(*paintInfo.context, false); |
| 303 fragment.buildFragmentTransform(fragmentTransform); | 297 fragment.buildFragmentTransform(fragmentTransform); |
| 304 if (!fragmentTransform.isIdentity()) { | 298 if (!fragmentTransform.isIdentity()) { |
| 305 stateSaver.save(); | 299 stateSaver.save(); |
| 306 paintInfo.context->concatCTM(fragmentTransform); | 300 paintInfo.context->concatCTM(fragmentTransform); |
| 307 } | 301 } |
| 308 | 302 |
| 309 // Spec: All text decorations except line-through should be drawn before the text is filled and stroked; thus, the text is rendered on top of these deco rations. | 303 // Spec: All text decorations except line-through should be drawn before the text is filled and stroked; thus, the text is rendered on top of these deco rations. |
| 310 unsigned decorations = style->textDecorationsInEffect(); | 304 unsigned decorations = style->textDecorationsInEffect(); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 339 } | 333 } |
| 340 | 334 |
| 341 // 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. | 335 // 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. |
| 342 if (decorations & TextDecorationLineThrough) | 336 if (decorations & TextDecorationLineThrough) |
| 343 paintDecoration(paintInfo.context, TextDecorationLineThrough, fragme nt); | 337 paintDecoration(paintInfo.context, TextDecorationLineThrough, fragme nt); |
| 344 } | 338 } |
| 345 | 339 |
| 346 // finally, paint the outline if any | 340 // finally, paint the outline if any |
| 347 if (style->hasOutline() && parentRenderer.isRenderInline()) | 341 if (style->hasOutline() && parentRenderer.isRenderInline()) |
| 348 toRenderInline(parentRenderer).paintOutline(paintInfo, paintOffset); | 342 toRenderInline(parentRenderer).paintOutline(paintInfo, paintOffset); |
| 349 | |
| 350 ASSERT(!m_paintingResource); | |
| 351 } | 343 } |
| 352 | 344 |
| 353 bool SVGInlineTextBox::acquirePaintingResource(GraphicsContext*& context, float scalingFactor, | 345 class PaintingResourceScope { |
| 354 RenderObject* renderer, RenderStyle* style, RenderSVGResourceModeFlags resou rceMode) | 346 public: |
| 347 PaintingResourceScope(RenderObject& renderer, TextRun::RenderingContext* ren deringContext = 0) | |
|
f(malita)
2014/09/12 13:40:56
We could try to go full RAII with this class: acqu
| |
| 348 : m_renderer(renderer) | |
| 349 , m_renderingContext(renderingContext) | |
| 350 , m_paintingResource(0) | |
| 351 { | |
| 352 } | |
| 353 ~PaintingResourceScope() { ASSERT(!m_paintingResource); } | |
| 354 | |
| 355 bool acquirePaintingResource(GraphicsContext*&, float scalingFactor, RenderS tyle*, RenderSVGResourceModeFlags); | |
| 356 void releasePaintingResource(GraphicsContext*&, const Path*, RenderSVGResour ceModeFlags); | |
| 357 | |
| 358 private: | |
| 359 RenderObject& m_renderer; | |
| 360 TextRun::RenderingContext* m_renderingContext; | |
| 361 RenderSVGResource* m_paintingResource; | |
| 362 }; | |
| 363 | |
| 364 bool PaintingResourceScope::acquirePaintingResource(GraphicsContext*& context, f loat scalingFactor, | |
| 365 RenderStyle* style, RenderSVGResourceModeFlags resourceMode) | |
| 355 { | 366 { |
| 356 // Callers must save the context state before calling when scalingFactor is not 1. | 367 // Callers must save the context state before calling when scalingFactor is not 1. |
| 357 ASSERT(scalingFactor); | 368 ASSERT(scalingFactor); |
| 358 ASSERT(renderer); | |
| 359 ASSERT(style); | 369 ASSERT(style); |
| 360 ASSERT(resourceMode != ApplyToDefaultMode); | 370 ASSERT(resourceMode != ApplyToDefaultMode); |
| 361 | 371 |
| 362 bool hasFallback = false; | 372 bool hasFallback = false; |
| 363 if (resourceMode & ApplyToFillMode) | 373 if (resourceMode & ApplyToFillMode) |
| 364 m_paintingResource = RenderSVGResource::fillPaintingResource(renderer, s tyle, hasFallback); | 374 m_paintingResource = RenderSVGResource::fillPaintingResource(&m_renderer , style, hasFallback); |
| 365 else if (resourceMode & ApplyToStrokeMode) | 375 else if (resourceMode & ApplyToStrokeMode) |
| 366 m_paintingResource = RenderSVGResource::strokePaintingResource(renderer, style, hasFallback); | 376 m_paintingResource = RenderSVGResource::strokePaintingResource(&m_render er, style, hasFallback); |
| 367 else { | 377 else { |
| 368 // We're either called for stroking or filling. | 378 // We're either called for stroking or filling. |
| 369 ASSERT_NOT_REACHED(); | 379 ASSERT_NOT_REACHED(); |
| 370 } | 380 } |
| 371 | 381 |
| 372 if (!m_paintingResource) | 382 if (!m_paintingResource) |
| 373 return false; | 383 return false; |
| 374 | 384 |
| 375 if (!m_paintingResource->applyResource(renderer, style, context, resourceMod e)) { | 385 if (!m_paintingResource->applyResource(&m_renderer, style, context, resource Mode)) { |
| 376 if (hasFallback) { | 386 if (hasFallback) { |
| 377 m_paintingResource = RenderSVGResource::sharedSolidPaintingResource( ); | 387 m_paintingResource = RenderSVGResource::sharedSolidPaintingResource( ); |
| 378 m_paintingResource->applyResource(renderer, style, context, resource Mode); | 388 m_paintingResource->applyResource(&m_renderer, style, context, resou rceMode); |
| 379 } | 389 } |
| 380 } | 390 } |
| 381 | 391 |
| 382 if (scalingFactor != 1 && resourceMode & ApplyToStrokeMode) | 392 if (scalingFactor != 1 && resourceMode & ApplyToStrokeMode) |
| 383 context->setStrokeThickness(context->strokeThickness() * scalingFactor); | 393 context->setStrokeThickness(context->strokeThickness() * scalingFactor); |
| 384 | 394 |
| 385 return true; | |
| 386 } | |
| 387 | |
| 388 void SVGInlineTextBox::releasePaintingResource(GraphicsContext*& context, const Path* path, | |
| 389 RenderSVGResourceModeFlags resourceMode) | |
| 390 { | |
| 391 ASSERT(m_paintingResource); | |
| 392 | |
| 393 m_paintingResource->postApplyResource(&parent()->renderer(), context, resour ceMode, path, 0); | |
| 394 m_paintingResource = 0; | |
| 395 } | |
| 396 | |
| 397 bool SVGInlineTextBox::prepareGraphicsContextForTextPainting(GraphicsContext*& c ontext, | |
| 398 float scalingFactor, TextRun& textRun, RenderStyle* style, RenderSVGResource ModeFlags resourceMode) | |
| 399 { | |
| 400 bool acquiredResource = acquirePaintingResource(context, scalingFactor, &par ent()->renderer(), style, resourceMode); | |
| 401 if (!acquiredResource) | |
| 402 return false; | |
| 403 | |
| 404 #if ENABLE(SVG_FONTS) | 395 #if ENABLE(SVG_FONTS) |
| 405 // SVG Fonts need access to the painting resource used to draw the current t ext chunk. | 396 // SVG Fonts need access to the painting resource used to draw the current t ext chunk. |
| 406 TextRun::RenderingContext* renderingContext = textRun.renderingContext(); | 397 if (m_renderingContext) |
| 407 if (renderingContext) | 398 static_cast<SVGTextRunRenderingContext*>(m_renderingContext)->setActiveP aintingResource(m_paintingResource); |
| 408 static_cast<SVGTextRunRenderingContext*>(renderingContext)->setActivePai ntingResource(m_paintingResource); | |
| 409 #endif | 399 #endif |
| 410 | 400 |
| 411 return true; | 401 return true; |
| 412 } | 402 } |
| 413 | 403 |
| 414 void SVGInlineTextBox::restoreGraphicsContextAfterTextPainting(GraphicsContext*& context, | 404 void PaintingResourceScope::releasePaintingResource(GraphicsContext*& context, c onst Path* path, |
| 415 TextRun& textRun, RenderSVGResourceModeFlags resourceMode) | 405 RenderSVGResourceModeFlags resourceMode) |
| 416 { | 406 { |
| 417 releasePaintingResource(context, 0, resourceMode); | 407 ASSERT(m_paintingResource); |
| 408 | |
| 409 m_paintingResource->postApplyResource(&m_renderer, context, resourceMode, pa th, 0); | |
| 410 m_paintingResource = 0; | |
| 418 | 411 |
| 419 #if ENABLE(SVG_FONTS) | 412 #if ENABLE(SVG_FONTS) |
| 420 TextRun::RenderingContext* renderingContext = textRun.renderingContext(); | 413 if (m_renderingContext) |
| 421 if (renderingContext) | 414 static_cast<SVGTextRunRenderingContext*>(m_renderingContext)->setActiveP aintingResource(0); |
| 422 static_cast<SVGTextRunRenderingContext*>(renderingContext)->setActivePai ntingResource(0); | |
| 423 #endif | 415 #endif |
| 424 } | 416 } |
| 425 | 417 |
| 426 TextRun SVGInlineTextBox::constructTextRun(RenderStyle* style, const SVGTextFrag ment& fragment) const | 418 TextRun SVGInlineTextBox::constructTextRun(RenderStyle* style, const SVGTextFrag ment& fragment) const |
| 427 { | 419 { |
| 428 ASSERT(style); | 420 ASSERT(style); |
| 429 | 421 |
| 430 RenderText* text = &renderer(); | 422 RenderText* text = &renderer(); |
| 431 | 423 |
| 432 // FIXME(crbug.com/264211): This should not be necessary but can occur if we | 424 // FIXME(crbug.com/264211): This should not be necessary but can occur if we |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 555 break; | 547 break; |
| 556 default: | 548 default: |
| 557 ASSERT_NOT_REACHED(); | 549 ASSERT_NOT_REACHED(); |
| 558 } | 550 } |
| 559 } | 551 } |
| 560 } | 552 } |
| 561 | 553 |
| 562 void SVGInlineTextBox::paintDecorationWithStyle(GraphicsContext* context, TextDe coration decoration, | 554 void SVGInlineTextBox::paintDecorationWithStyle(GraphicsContext* context, TextDe coration decoration, |
| 563 const SVGTextFragment& fragment, RenderObject* decorationRenderer, RenderSVG ResourceModeFlags resourceMode) | 555 const SVGTextFragment& fragment, RenderObject* decorationRenderer, RenderSVG ResourceModeFlags resourceMode) |
| 564 { | 556 { |
| 565 ASSERT(!m_paintingResource); | |
| 566 ASSERT(resourceMode != ApplyToDefaultMode); | 557 ASSERT(resourceMode != ApplyToDefaultMode); |
| 567 | 558 |
| 568 RenderStyle* decorationStyle = decorationRenderer->style(); | 559 RenderStyle* decorationStyle = decorationRenderer->style(); |
| 569 ASSERT(decorationStyle); | 560 ASSERT(decorationStyle); |
| 570 | 561 |
| 571 float scalingFactor = 1; | 562 float scalingFactor = 1; |
| 572 Font scaledFont; | 563 Font scaledFont; |
| 573 RenderSVGInlineText::computeNewScaledFontForStyle(decorationRenderer, decora tionStyle, scalingFactor, scaledFont); | 564 RenderSVGInlineText::computeNewScaledFontForStyle(decorationRenderer, decora tionStyle, scalingFactor, scaledFont); |
| 574 ASSERT(scalingFactor); | 565 ASSERT(scalingFactor); |
| 575 | 566 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 591 context->scale(1 / scalingFactor, 1 / scalingFactor); | 582 context->scale(1 / scalingFactor, 1 / scalingFactor); |
| 592 } | 583 } |
| 593 | 584 |
| 594 decorationOrigin.move(0, -scaledFontMetrics.floatAscent() + positionOffsetFo rDecoration(decoration, scaledFontMetrics, thickness)); | 585 decorationOrigin.move(0, -scaledFontMetrics.floatAscent() + positionOffsetFo rDecoration(decoration, scaledFontMetrics, thickness)); |
| 595 | 586 |
| 596 Path path; | 587 Path path; |
| 597 path.addRect(FloatRect(decorationOrigin, FloatSize(width, thickness))); | 588 path.addRect(FloatRect(decorationOrigin, FloatSize(width, thickness))); |
| 598 | 589 |
| 599 // acquirePaintingResource also modifies state if the scalingFactor is non-i dentity. | 590 // acquirePaintingResource also modifies state if the scalingFactor is non-i dentity. |
| 600 // Above we have saved the state for this case. | 591 // Above we have saved the state for this case. |
| 601 if (acquirePaintingResource(context, scalingFactor, decorationRenderer, deco rationStyle, resourceMode)) | 592 PaintingResourceScope resourceScope(*decorationRenderer); |
| 602 releasePaintingResource(context, &path, resourceMode); | 593 if (resourceScope.acquirePaintingResource(context, scalingFactor, decoration Style, resourceMode)) |
| 594 resourceScope.releasePaintingResource(context, &path, resourceMode); | |
| 603 } | 595 } |
| 604 | 596 |
| 605 void SVGInlineTextBox::paintTextWithShadows(GraphicsContext* context, RenderStyl e* style, | 597 void SVGInlineTextBox::paintTextWithShadows(GraphicsContext* context, RenderStyl e* style, |
| 606 TextRun& textRun, const SVGTextFragment& fragment, int startPosition, int en dPosition, | 598 TextRun& textRun, const SVGTextFragment& fragment, int startPosition, int en dPosition, |
| 607 RenderSVGResourceModeFlags resourceMode) | 599 RenderSVGResourceModeFlags resourceMode) |
| 608 { | 600 { |
| 609 RenderSVGInlineText& textRenderer = toRenderSVGInlineText(this->renderer()); | 601 RenderSVGInlineText& textRenderer = toRenderSVGInlineText(this->renderer()); |
| 610 | 602 |
| 611 float scalingFactor = textRenderer.scalingFactor(); | 603 float scalingFactor = textRenderer.scalingFactor(); |
| 612 ASSERT(scalingFactor); | 604 ASSERT(scalingFactor); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 623 if (scalingFactor != 1) { | 615 if (scalingFactor != 1) { |
| 624 textOrigin.scale(scalingFactor, scalingFactor); | 616 textOrigin.scale(scalingFactor, scalingFactor); |
| 625 textSize.scale(scalingFactor); | 617 textSize.scale(scalingFactor); |
| 626 context->save(); | 618 context->save(); |
| 627 context->scale(1 / scalingFactor, 1 / scalingFactor); | 619 context->scale(1 / scalingFactor, 1 / scalingFactor); |
| 628 } | 620 } |
| 629 | 621 |
| 630 if (hasShadow) | 622 if (hasShadow) |
| 631 context->setDrawLooper(shadowList->createDrawLooper(DrawLooperBuilder::S hadowRespectsAlpha)); | 623 context->setDrawLooper(shadowList->createDrawLooper(DrawLooperBuilder::S hadowRespectsAlpha)); |
| 632 | 624 |
| 633 if (prepareGraphicsContextForTextPainting(context, scalingFactor, textRun, s tyle, resourceMode)) { | 625 PaintingResourceScope resourceScope(parent()->renderer(), textRun.renderingC ontext()); |
| 626 if (resourceScope.acquirePaintingResource(context, scalingFactor, style, res ourceMode)) { | |
| 634 TextRunPaintInfo textRunPaintInfo(textRun); | 627 TextRunPaintInfo textRunPaintInfo(textRun); |
| 635 textRunPaintInfo.from = startPosition; | 628 textRunPaintInfo.from = startPosition; |
| 636 textRunPaintInfo.to = endPosition; | 629 textRunPaintInfo.to = endPosition; |
| 637 | 630 |
| 638 float baseline = scaledFont.fontMetrics().floatAscent(); | 631 float baseline = scaledFont.fontMetrics().floatAscent(); |
| 639 textRunPaintInfo.bounds = FloatRect(textOrigin.x(), textOrigin.y() - bas eline, | 632 textRunPaintInfo.bounds = FloatRect(textOrigin.x(), textOrigin.y() - bas eline, |
| 640 textSize.width(), textSize.height()); | 633 textSize.width(), textSize.height()); |
| 641 | 634 |
| 642 scaledFont.drawText(context, textRunPaintInfo, textOrigin); | 635 scaledFont.drawText(context, textRunPaintInfo, textOrigin); |
| 643 restoreGraphicsContextAfterTextPainting(context, textRun, resourceMode); | 636 resourceScope.releasePaintingResource(context, 0, resourceMode); |
| 644 } | 637 } |
| 645 | 638 |
| 646 if (scalingFactor != 1) | 639 if (scalingFactor != 1) |
| 647 context->restore(); | 640 context->restore(); |
| 648 else if (hasShadow) | 641 else if (hasShadow) |
| 649 context->clearShadow(); | 642 context->clearShadow(); |
| 650 } | 643 } |
| 651 | 644 |
| 652 void SVGInlineTextBox::paintText(GraphicsContext* context, RenderStyle* style, | 645 void SVGInlineTextBox::paintText(GraphicsContext* context, RenderStyle* style, |
| 653 RenderStyle* selectionStyle, const SVGTextFragment& fragment, | 646 RenderStyle* selectionStyle, const SVGTextFragment& fragment, |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 797 renderer().updateHitTestResult(result, locationInContainer.point () - toLayoutSize(accumulatedOffset)); | 790 renderer().updateHitTestResult(result, locationInContainer.point () - toLayoutSize(accumulatedOffset)); |
| 798 if (!result.addNodeToRectBasedTestResult(renderer().node(), requ est, locationInContainer, rect)) | 791 if (!result.addNodeToRectBasedTestResult(renderer().node(), requ est, locationInContainer, rect)) |
| 799 return true; | 792 return true; |
| 800 } | 793 } |
| 801 } | 794 } |
| 802 } | 795 } |
| 803 return false; | 796 return false; |
| 804 } | 797 } |
| 805 | 798 |
| 806 } // namespace blink | 799 } // namespace blink |
| OLD | NEW |