LCOV - code coverage report
Current view: top level - layout/svg - SVGImageContext.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 23 29 79.3 %
Date: 2017-07-14 16:53:18 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       5             : 
       6             : 
       7             : // Main header first:
       8             : #include "SVGImageContext.h"
       9             : 
      10             : // Keep others in (case-insensitive) order:
      11             : #include "gfxUtils.h"
      12             : #include "mozilla/Preferences.h"
      13             : #include "nsContentUtils.h"
      14             : #include "nsIFrame.h"
      15             : #include "nsPresContext.h"
      16             : #include "nsStyleStruct.h"
      17             : 
      18             : namespace mozilla {
      19             : 
      20             : /* static */ void
      21         108 : SVGImageContext::MaybeStoreContextPaint(Maybe<SVGImageContext>& aContext,
      22             :                                         nsIFrame* aFromFrame,
      23             :                                         imgIContainer* aImgContainer)
      24             : {
      25         108 :   return MaybeStoreContextPaint(aContext,
      26             :                                 aFromFrame->StyleContext(),
      27         108 :                                 aImgContainer);
      28             : }
      29             : 
      30             : /* static */ void
      31         108 : SVGImageContext::MaybeStoreContextPaint(Maybe<SVGImageContext>& aContext,
      32             :                                         nsStyleContext* aFromStyleContext,
      33             :                                         imgIContainer* aImgContainer)
      34             : {
      35         108 :   const nsStyleSVG* style = aFromStyleContext->StyleSVG();
      36             : 
      37         108 :   if (!style->ExposesContextProperties()) {
      38             :     // Content must have '-moz-context-properties' set to the names of the
      39             :     // properties it wants to expose to images it links to.
      40         110 :     return;
      41             :   }
      42             : 
      43          53 :   if (aImgContainer->GetType() != imgIContainer::TYPE_VECTOR) {
      44             :     // Avoid this overhead for raster images.
      45           0 :     return;
      46             :   }
      47             : 
      48          53 :   bool haveContextPaint = false;
      49             : 
      50         106 :   RefPtr<SVGEmbeddingContextPaint> contextPaint = new SVGEmbeddingContextPaint();
      51             : 
      52         106 :   if ((style->mContextPropsBits & NS_STYLE_CONTEXT_PROPERTY_FILL) &&
      53          53 :       style->mFill.Type() == eStyleSVGPaintType_Color) {
      54          53 :     haveContextPaint = true;
      55          53 :     contextPaint->SetFill(style->mFill.GetColor());
      56             :   }
      57          53 :   if ((style->mContextPropsBits & NS_STYLE_CONTEXT_PROPERTY_STROKE) &&
      58           0 :       style->mStroke.Type() == eStyleSVGPaintType_Color) {
      59           0 :     haveContextPaint = true;
      60           0 :     contextPaint->SetStroke(style->mStroke.GetColor());
      61             :   }
      62          53 :   if (style->mContextPropsBits & NS_STYLE_CONTEXT_PROPERTY_FILL_OPACITY) {
      63           7 :     haveContextPaint = true;
      64           7 :     contextPaint->SetFillOpacity(style->mFillOpacity);
      65             :   }
      66          53 :   if (style->mContextPropsBits & NS_STYLE_CONTEXT_PROPERTY_STROKE_OPACITY) {
      67           0 :     haveContextPaint = true;
      68           0 :     contextPaint->SetStrokeOpacity(style->mStrokeOpacity);
      69             :   }
      70             : 
      71          53 :   if (haveContextPaint) {
      72          53 :     if (!aContext) {
      73          53 :       aContext.emplace();
      74             :     }
      75          53 :     aContext->mContextPaint = contextPaint.forget();
      76             :   }
      77             : }
      78             : 
      79             : } // namespace mozilla

Generated by: LCOV version 1.13