| 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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 paintDecoration(paintInfo.context, TextDecorationLineThrough, fragme
nt); | 338 paintDecoration(paintInfo.context, TextDecorationLineThrough, fragme
nt); |
| 339 } | 339 } |
| 340 | 340 |
| 341 // finally, paint the outline if any | 341 // finally, paint the outline if any |
| 342 if (style->hasOutline() && parentRenderer.isRenderInline()) | 342 if (style->hasOutline() && parentRenderer.isRenderInline()) |
| 343 toRenderInline(parentRenderer).paintOutline(paintInfo, paintOffset); | 343 toRenderInline(parentRenderer).paintOutline(paintInfo, paintOffset); |
| 344 } | 344 } |
| 345 | 345 |
| 346 class PaintingResourceScope { | 346 class PaintingResourceScope { |
| 347 public: | 347 public: |
| 348 PaintingResourceScope(RenderObject& renderer, TextRun::RenderingContext* ren
deringContext = 0) | 348 PaintingResourceScope(RenderObject& renderer) |
| 349 : m_renderer(renderer) | 349 : m_renderer(renderer) |
| 350 , m_renderingContext(renderingContext) | |
| 351 , m_paintingResource(0) | 350 , m_paintingResource(0) |
| 352 { | 351 { |
| 353 } | 352 } |
| 354 ~PaintingResourceScope() { ASSERT(!m_paintingResource); } | 353 ~PaintingResourceScope() { ASSERT(!m_paintingResource); } |
| 355 | 354 |
| 356 bool acquirePaintingResource(GraphicsContext*&, float scalingFactor, RenderS
tyle*, RenderSVGResourceModeFlags); | 355 bool acquirePaintingResource(GraphicsContext*&, float scalingFactor, RenderS
tyle*, RenderSVGResourceModeFlags); |
| 357 void releasePaintingResource(GraphicsContext*&); | 356 void releasePaintingResource(GraphicsContext*&); |
| 358 | 357 |
| 359 private: | 358 private: |
| 360 RenderObject& m_renderer; | 359 RenderObject& m_renderer; |
| 361 TextRun::RenderingContext* m_renderingContext; | |
| 362 RenderSVGResource* m_paintingResource; | 360 RenderSVGResource* m_paintingResource; |
| 363 }; | 361 }; |
| 364 | 362 |
| 365 bool PaintingResourceScope::acquirePaintingResource(GraphicsContext*& context, f
loat scalingFactor, | 363 bool PaintingResourceScope::acquirePaintingResource(GraphicsContext*& context, f
loat scalingFactor, |
| 366 RenderStyle* style, RenderSVGResourceModeFlags resourceModeFlags) | 364 RenderStyle* style, RenderSVGResourceModeFlags resourceModeFlags) |
| 367 { | 365 { |
| 368 // Callers must save the context state before calling when scalingFactor is
not 1. | 366 // Callers must save the context state before calling when scalingFactor is
not 1. |
| 369 ASSERT(scalingFactor); | 367 ASSERT(scalingFactor); |
| 370 ASSERT(style); | 368 ASSERT(style); |
| 371 ASSERT(resourceModeFlags != ApplyToDefaultMode); | 369 ASSERT(resourceModeFlags != ApplyToDefaultMode); |
| 372 RenderSVGResourceMode resourceMode = static_cast<RenderSVGResourceMode>(reso
urceModeFlags & (ApplyToFillMode | ApplyToStrokeMode)); | 370 RenderSVGResourceMode resourceMode = static_cast<RenderSVGResourceMode>(reso
urceModeFlags & (ApplyToFillMode | ApplyToStrokeMode)); |
| 373 ASSERT(resourceMode == ApplyToFillMode || resourceMode == ApplyToStrokeMode)
; | 371 ASSERT(resourceMode == ApplyToFillMode || resourceMode == ApplyToStrokeMode)
; |
| 374 | 372 |
| 375 bool hasFallback = false; | 373 bool hasFallback = false; |
| 376 m_paintingResource = RenderSVGResource::requestPaintingResource(resourceMode
, &m_renderer, style, hasFallback); | 374 m_paintingResource = RenderSVGResource::requestPaintingResource(resourceMode
, &m_renderer, style, hasFallback); |
| 377 if (!m_paintingResource) | 375 if (!m_paintingResource) |
| 378 return false; | 376 return false; |
| 379 | 377 |
| 380 if (!m_paintingResource->applyResource(&m_renderer, style, context, resource
ModeFlags)) { | 378 if (!m_paintingResource->applyResource(&m_renderer, style, context, resource
ModeFlags)) { |
| 381 if (hasFallback) { | 379 if (hasFallback) { |
| 382 m_paintingResource = RenderSVGResource::sharedSolidPaintingResource(
); | 380 m_paintingResource = RenderSVGResource::sharedSolidPaintingResource(
); |
| 383 m_paintingResource->applyResource(&m_renderer, style, context, resou
rceModeFlags); | 381 m_paintingResource->applyResource(&m_renderer, style, context, resou
rceModeFlags); |
| 384 } | 382 } |
| 385 } | 383 } |
| 386 | 384 |
| 387 if (scalingFactor != 1 && resourceModeFlags & ApplyToStrokeMode) | 385 if (scalingFactor != 1 && resourceModeFlags & ApplyToStrokeMode) |
| 388 context->setStrokeThickness(context->strokeThickness() * scalingFactor); | 386 context->setStrokeThickness(context->strokeThickness() * scalingFactor); |
| 389 | 387 |
| 390 #if ENABLE(SVG_FONTS) | |
| 391 // SVG Fonts need access to the painting resource used to draw the current t
ext chunk. | |
| 392 if (m_renderingContext) | |
| 393 static_cast<SVGTextRunRenderingContext*>(m_renderingContext)->setActiveP
aintingResource(m_paintingResource); | |
| 394 #endif | |
| 395 | |
| 396 return true; | 388 return true; |
| 397 } | 389 } |
| 398 | 390 |
| 399 void PaintingResourceScope::releasePaintingResource(GraphicsContext*& context) | 391 void PaintingResourceScope::releasePaintingResource(GraphicsContext*& context) |
| 400 { | 392 { |
| 401 ASSERT(m_paintingResource); | 393 ASSERT(m_paintingResource); |
| 402 | 394 |
| 403 m_paintingResource->postApplyResource(&m_renderer, context); | 395 m_paintingResource->postApplyResource(&m_renderer, context); |
| 404 m_paintingResource = 0; | 396 m_paintingResource = 0; |
| 405 | |
| 406 #if ENABLE(SVG_FONTS) | |
| 407 if (m_renderingContext) | |
| 408 static_cast<SVGTextRunRenderingContext*>(m_renderingContext)->setActiveP
aintingResource(0); | |
| 409 #endif | |
| 410 } | 397 } |
| 411 | 398 |
| 412 TextRun SVGInlineTextBox::constructTextRun(RenderStyle* style, const SVGTextFrag
ment& fragment) const | 399 TextRun SVGInlineTextBox::constructTextRun(RenderStyle* style, const SVGTextFrag
ment& fragment) const |
| 413 { | 400 { |
| 414 ASSERT(style); | 401 ASSERT(style); |
| 415 | 402 |
| 416 RenderText* text = &renderer(); | 403 RenderText* text = &renderer(); |
| 417 | 404 |
| 418 // FIXME(crbug.com/264211): This should not be necessary but can occur if we | 405 // FIXME(crbug.com/264211): This should not be necessary but can occur if we |
| 419 // layout during layout. Remove this when 264211 is
fixed. | 406 // layout during layout. Remove this when 264211 is
fixed. |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 if (scalingFactor != 1) { | 598 if (scalingFactor != 1) { |
| 612 textOrigin.scale(scalingFactor, scalingFactor); | 599 textOrigin.scale(scalingFactor, scalingFactor); |
| 613 textSize.scale(scalingFactor); | 600 textSize.scale(scalingFactor); |
| 614 context->save(); | 601 context->save(); |
| 615 context->scale(1 / scalingFactor, 1 / scalingFactor); | 602 context->scale(1 / scalingFactor, 1 / scalingFactor); |
| 616 } | 603 } |
| 617 | 604 |
| 618 if (hasShadow) | 605 if (hasShadow) |
| 619 context->setDrawLooper(shadowList->createDrawLooper(DrawLooperBuilder::S
hadowRespectsAlpha)); | 606 context->setDrawLooper(shadowList->createDrawLooper(DrawLooperBuilder::S
hadowRespectsAlpha)); |
| 620 | 607 |
| 621 PaintingResourceScope resourceScope(parent()->renderer(), textRun.renderingC
ontext()); | 608 PaintingResourceScope resourceScope(parent()->renderer()); |
| 622 if (resourceScope.acquirePaintingResource(context, scalingFactor, style, res
ourceMode)) { | 609 if (resourceScope.acquirePaintingResource(context, scalingFactor, style, res
ourceMode)) { |
| 623 TextRunPaintInfo textRunPaintInfo(textRun); | 610 TextRunPaintInfo textRunPaintInfo(textRun); |
| 624 textRunPaintInfo.from = startPosition; | 611 textRunPaintInfo.from = startPosition; |
| 625 textRunPaintInfo.to = endPosition; | 612 textRunPaintInfo.to = endPosition; |
| 626 | 613 |
| 627 float baseline = scaledFont.fontMetrics().floatAscent(); | 614 float baseline = scaledFont.fontMetrics().floatAscent(); |
| 628 textRunPaintInfo.bounds = FloatRect(textOrigin.x(), textOrigin.y() - bas
eline, | 615 textRunPaintInfo.bounds = FloatRect(textOrigin.x(), textOrigin.y() - bas
eline, |
| 629 textSize.width(), textSize.height()); | 616 textSize.width(), textSize.height()); |
| 630 | 617 |
| 631 scaledFont.drawText(context, textRunPaintInfo, textOrigin); | 618 scaledFont.drawText(context, textRunPaintInfo, textOrigin); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 786 renderer().updateHitTestResult(result, locationInContainer.point
() - toLayoutSize(accumulatedOffset)); | 773 renderer().updateHitTestResult(result, locationInContainer.point
() - toLayoutSize(accumulatedOffset)); |
| 787 if (!result.addNodeToRectBasedTestResult(renderer().node(), requ
est, locationInContainer, rect)) | 774 if (!result.addNodeToRectBasedTestResult(renderer().node(), requ
est, locationInContainer, rect)) |
| 788 return true; | 775 return true; |
| 789 } | 776 } |
| 790 } | 777 } |
| 791 } | 778 } |
| 792 return false; | 779 return false; |
| 793 } | 780 } |
| 794 | 781 |
| 795 } // namespace blink | 782 } // namespace blink |
| OLD | NEW |