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 19 matching lines...) Expand all Loading... |
30 #include "core/rendering/HitTestResult.h" | 30 #include "core/rendering/HitTestResult.h" |
31 #include "core/rendering/InlineFlowBox.h" | 31 #include "core/rendering/InlineFlowBox.h" |
32 #include "core/rendering/PaintInfo.h" | 32 #include "core/rendering/PaintInfo.h" |
33 #include "core/rendering/PointerEventsHitRules.h" | 33 #include "core/rendering/PointerEventsHitRules.h" |
34 #include "core/rendering/RenderInline.h" | 34 #include "core/rendering/RenderInline.h" |
35 #include "core/rendering/RenderTheme.h" | 35 #include "core/rendering/RenderTheme.h" |
36 #include "core/rendering/style/ShadowList.h" | 36 #include "core/rendering/style/ShadowList.h" |
37 #include "core/rendering/svg/RenderSVGInlineText.h" | 37 #include "core/rendering/svg/RenderSVGInlineText.h" |
38 #include "core/rendering/svg/RenderSVGResource.h" | 38 #include "core/rendering/svg/RenderSVGResource.h" |
39 #include "core/rendering/svg/RenderSVGResourceSolidColor.h" | 39 #include "core/rendering/svg/RenderSVGResourceSolidColor.h" |
| 40 #include "core/rendering/svg/SVGRenderSupport.h" |
40 #include "core/rendering/svg/SVGResourcesCache.h" | 41 #include "core/rendering/svg/SVGResourcesCache.h" |
41 #include "core/rendering/svg/SVGTextRunRenderingContext.h" | 42 #include "core/rendering/svg/SVGTextRunRenderingContext.h" |
42 #include "platform/FloatConversion.h" | 43 #include "platform/FloatConversion.h" |
43 #include "platform/fonts/FontCache.h" | 44 #include "platform/fonts/FontCache.h" |
44 #include "platform/graphics/GraphicsContextStateSaver.h" | 45 #include "platform/graphics/GraphicsContextStateSaver.h" |
45 | 46 |
46 namespace blink { | 47 namespace blink { |
47 | 48 |
48 struct ExpectedSVGInlineTextBoxSize : public InlineTextBox { | 49 struct ExpectedSVGInlineTextBoxSize : public InlineTextBox { |
49 float float1; | 50 float float1; |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 public: | 347 public: |
347 PaintingResourceScope(RenderObject& renderer, TextRun::RenderingContext* ren
deringContext = 0) | 348 PaintingResourceScope(RenderObject& renderer, TextRun::RenderingContext* ren
deringContext = 0) |
348 : m_renderer(renderer) | 349 : m_renderer(renderer) |
349 , m_renderingContext(renderingContext) | 350 , m_renderingContext(renderingContext) |
350 , m_paintingResource(0) | 351 , m_paintingResource(0) |
351 { | 352 { |
352 } | 353 } |
353 ~PaintingResourceScope() { ASSERT(!m_paintingResource); } | 354 ~PaintingResourceScope() { ASSERT(!m_paintingResource); } |
354 | 355 |
355 bool acquirePaintingResource(GraphicsContext*&, float scalingFactor, RenderS
tyle*, RenderSVGResourceModeFlags); | 356 bool acquirePaintingResource(GraphicsContext*&, float scalingFactor, RenderS
tyle*, RenderSVGResourceModeFlags); |
356 void releasePaintingResource(GraphicsContext*&, const Path*, RenderSVGResour
ceModeFlags); | 357 void releasePaintingResource(GraphicsContext*&); |
357 | 358 |
358 private: | 359 private: |
359 RenderObject& m_renderer; | 360 RenderObject& m_renderer; |
360 TextRun::RenderingContext* m_renderingContext; | 361 TextRun::RenderingContext* m_renderingContext; |
361 RenderSVGResource* m_paintingResource; | 362 RenderSVGResource* m_paintingResource; |
362 }; | 363 }; |
363 | 364 |
364 bool PaintingResourceScope::acquirePaintingResource(GraphicsContext*& context, f
loat scalingFactor, | 365 bool PaintingResourceScope::acquirePaintingResource(GraphicsContext*& context, f
loat scalingFactor, |
365 RenderStyle* style, RenderSVGResourceModeFlags resourceMode) | 366 RenderStyle* style, RenderSVGResourceModeFlags resourceMode) |
366 { | 367 { |
(...skipping 27 matching lines...) Expand all Loading... |
394 | 395 |
395 #if ENABLE(SVG_FONTS) | 396 #if ENABLE(SVG_FONTS) |
396 // SVG Fonts need access to the painting resource used to draw the current t
ext chunk. | 397 // SVG Fonts need access to the painting resource used to draw the current t
ext chunk. |
397 if (m_renderingContext) | 398 if (m_renderingContext) |
398 static_cast<SVGTextRunRenderingContext*>(m_renderingContext)->setActiveP
aintingResource(m_paintingResource); | 399 static_cast<SVGTextRunRenderingContext*>(m_renderingContext)->setActiveP
aintingResource(m_paintingResource); |
399 #endif | 400 #endif |
400 | 401 |
401 return true; | 402 return true; |
402 } | 403 } |
403 | 404 |
404 void PaintingResourceScope::releasePaintingResource(GraphicsContext*& context, c
onst Path* path, | 405 void PaintingResourceScope::releasePaintingResource(GraphicsContext*& context) |
405 RenderSVGResourceModeFlags resourceMode) | |
406 { | 406 { |
407 ASSERT(m_paintingResource); | 407 ASSERT(m_paintingResource); |
408 | 408 |
409 m_paintingResource->postApplyResource(&m_renderer, context, resourceMode, pa
th, 0); | 409 m_paintingResource->postApplyResource(&m_renderer, context); |
410 m_paintingResource = 0; | 410 m_paintingResource = 0; |
411 | 411 |
412 #if ENABLE(SVG_FONTS) | 412 #if ENABLE(SVG_FONTS) |
413 if (m_renderingContext) | 413 if (m_renderingContext) |
414 static_cast<SVGTextRunRenderingContext*>(m_renderingContext)->setActiveP
aintingResource(0); | 414 static_cast<SVGTextRunRenderingContext*>(m_renderingContext)->setActiveP
aintingResource(0); |
415 #endif | 415 #endif |
416 } | 416 } |
417 | 417 |
418 TextRun SVGInlineTextBox::constructTextRun(RenderStyle* style, const SVGTextFrag
ment& fragment) const | 418 TextRun SVGInlineTextBox::constructTextRun(RenderStyle* style, const SVGTextFrag
ment& fragment) const |
419 { | 419 { |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 } | 583 } |
584 | 584 |
585 decorationOrigin.move(0, -scaledFontMetrics.floatAscent() + positionOffsetFo
rDecoration(decoration, scaledFontMetrics, thickness)); | 585 decorationOrigin.move(0, -scaledFontMetrics.floatAscent() + positionOffsetFo
rDecoration(decoration, scaledFontMetrics, thickness)); |
586 | 586 |
587 Path path; | 587 Path path; |
588 path.addRect(FloatRect(decorationOrigin, FloatSize(width, thickness))); | 588 path.addRect(FloatRect(decorationOrigin, FloatSize(width, thickness))); |
589 | 589 |
590 // acquirePaintingResource also modifies state if the scalingFactor is non-i
dentity. | 590 // acquirePaintingResource also modifies state if the scalingFactor is non-i
dentity. |
591 // Above we have saved the state for this case. | 591 // Above we have saved the state for this case. |
592 PaintingResourceScope resourceScope(*decorationRenderer); | 592 PaintingResourceScope resourceScope(*decorationRenderer); |
593 if (resourceScope.acquirePaintingResource(context, scalingFactor, decoration
Style, resourceMode)) | 593 if (resourceScope.acquirePaintingResource(context, scalingFactor, decoration
Style, resourceMode)) { |
594 resourceScope.releasePaintingResource(context, &path, resourceMode); | 594 SVGRenderSupport::fillOrStrokePath(context, resourceMode, path); |
| 595 resourceScope.releasePaintingResource(context); |
| 596 } |
595 } | 597 } |
596 | 598 |
597 void SVGInlineTextBox::paintTextWithShadows(GraphicsContext* context, RenderStyl
e* style, | 599 void SVGInlineTextBox::paintTextWithShadows(GraphicsContext* context, RenderStyl
e* style, |
598 TextRun& textRun, const SVGTextFragment& fragment, int startPosition, int en
dPosition, | 600 TextRun& textRun, const SVGTextFragment& fragment, int startPosition, int en
dPosition, |
599 RenderSVGResourceModeFlags resourceMode) | 601 RenderSVGResourceModeFlags resourceMode) |
600 { | 602 { |
601 RenderSVGInlineText& textRenderer = toRenderSVGInlineText(this->renderer()); | 603 RenderSVGInlineText& textRenderer = toRenderSVGInlineText(this->renderer()); |
602 | 604 |
603 float scalingFactor = textRenderer.scalingFactor(); | 605 float scalingFactor = textRenderer.scalingFactor(); |
604 ASSERT(scalingFactor); | 606 ASSERT(scalingFactor); |
(...skipping 21 matching lines...) Expand all Loading... |
626 if (resourceScope.acquirePaintingResource(context, scalingFactor, style, res
ourceMode)) { | 628 if (resourceScope.acquirePaintingResource(context, scalingFactor, style, res
ourceMode)) { |
627 TextRunPaintInfo textRunPaintInfo(textRun); | 629 TextRunPaintInfo textRunPaintInfo(textRun); |
628 textRunPaintInfo.from = startPosition; | 630 textRunPaintInfo.from = startPosition; |
629 textRunPaintInfo.to = endPosition; | 631 textRunPaintInfo.to = endPosition; |
630 | 632 |
631 float baseline = scaledFont.fontMetrics().floatAscent(); | 633 float baseline = scaledFont.fontMetrics().floatAscent(); |
632 textRunPaintInfo.bounds = FloatRect(textOrigin.x(), textOrigin.y() - bas
eline, | 634 textRunPaintInfo.bounds = FloatRect(textOrigin.x(), textOrigin.y() - bas
eline, |
633 textSize.width(), textSize.height()); | 635 textSize.width(), textSize.height()); |
634 | 636 |
635 scaledFont.drawText(context, textRunPaintInfo, textOrigin); | 637 scaledFont.drawText(context, textRunPaintInfo, textOrigin); |
636 resourceScope.releasePaintingResource(context, 0, resourceMode); | 638 resourceScope.releasePaintingResource(context); |
637 } | 639 } |
638 | 640 |
639 if (scalingFactor != 1) | 641 if (scalingFactor != 1) |
640 context->restore(); | 642 context->restore(); |
641 else if (hasShadow) | 643 else if (hasShadow) |
642 context->clearShadow(); | 644 context->clearShadow(); |
643 } | 645 } |
644 | 646 |
645 void SVGInlineTextBox::paintText(GraphicsContext* context, RenderStyle* style, | 647 void SVGInlineTextBox::paintText(GraphicsContext* context, RenderStyle* style, |
646 RenderStyle* selectionStyle, const SVGTextFragment& fragment, | 648 RenderStyle* selectionStyle, const SVGTextFragment& fragment, |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 renderer().updateHitTestResult(result, locationInContainer.point
() - toLayoutSize(accumulatedOffset)); | 792 renderer().updateHitTestResult(result, locationInContainer.point
() - toLayoutSize(accumulatedOffset)); |
791 if (!result.addNodeToRectBasedTestResult(renderer().node(), requ
est, locationInContainer, rect)) | 793 if (!result.addNodeToRectBasedTestResult(renderer().node(), requ
est, locationInContainer, rect)) |
792 return true; | 794 return true; |
793 } | 795 } |
794 } | 796 } |
795 } | 797 } |
796 return false; | 798 return false; |
797 } | 799 } |
798 | 800 |
799 } // namespace blink | 801 } // namespace blink |
OLD | NEW |