LCOV - code coverage report
Current view: directory - layout/svg/base/src - SVGFEImageFrame.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 40 0 0.0 %
Date: 2012-06-02 Functions: 13 0 0.0 %

       1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2                 : /* ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       5                 :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :  * the License. You may obtain a copy of the License at
       8                 :  * http://www.mozilla.org/MPL/
       9                 :  *
      10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :  * for the specific language governing rights and limitations under the
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is the Mozilla SVG project.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is Robert Longson.
      18                 :  * Portions created by the Initial Developer are Copyright (C) 2011
      19                 :  * the Initial Developer. All Rights Reserved.
      20                 :  *
      21                 :  * Contributor(s):
      22                 :  *
      23                 :  * Alternatively, the contents of this file may be used under the terms of
      24                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      25                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      26                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      27                 :  * of those above. If you wish to allow use of your version of this file only
      28                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      29                 :  * use your version of this file under the terms of the MPL, indicate your
      30                 :  * decision by deleting the provisions above and replace them with the notice
      31                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      32                 :  * the provisions above, a recipient may use your version of this file under
      33                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      34                 :  *
      35                 :  * ***** END LICENSE BLOCK ***** */
      36                 : 
      37                 : #include "nsFrame.h"
      38                 : #include "nsSVGEffects.h"
      39                 : #include "nsSVGFilters.h"
      40                 : #include "nsContentUtils.h"
      41                 : #include "nsImageLoadingContent.h"
      42                 : 
      43                 : using namespace mozilla;
      44                 : 
      45                 : typedef nsFrame SVGFEImageFrameBase;
      46                 : 
      47                 : class SVGFEImageFrame : public SVGFEImageFrameBase
      48               0 : {
      49                 :   friend nsIFrame*
      50                 :   NS_NewSVGFEImageFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
      51                 : protected:
      52               0 :   SVGFEImageFrame(nsStyleContext* aContext) : SVGFEImageFrameBase(aContext) {}
      53                 : 
      54                 : public:
      55                 :   NS_DECL_FRAMEARENA_HELPERS
      56                 : 
      57                 :   NS_IMETHOD Init(nsIContent* aContent,
      58                 :                   nsIFrame*   aParent,
      59                 :                   nsIFrame*   aPrevInFlow);
      60                 :   virtual void DestroyFrom(nsIFrame* aDestructRoot);
      61                 : 
      62               0 :   virtual bool IsFrameOfType(PRUint32 aFlags) const
      63                 :   {
      64               0 :     return SVGFEImageFrameBase::IsFrameOfType(aFlags & ~(nsIFrame::eSVG));
      65                 :   }
      66                 : 
      67                 : #ifdef DEBUG
      68               0 :   NS_IMETHOD GetFrameName(nsAString& aResult) const
      69                 :   {
      70               0 :     return MakeFrameName(NS_LITERAL_STRING("SVGFEImage"), aResult);
      71                 :   }
      72                 : #endif
      73                 : 
      74                 :   virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext);
      75                 : 
      76                 :   /**
      77                 :    * Get the "type" of the frame
      78                 :    *
      79                 :    * @see nsGkAtoms::svgFEImageFrame
      80                 :    */
      81                 :   virtual nsIAtom* GetType() const;
      82                 : 
      83                 :   NS_IMETHOD AttributeChanged(PRInt32  aNameSpaceID,
      84                 :                               nsIAtom* aAttribute,
      85                 :                               PRInt32  aModType);
      86                 : };
      87                 : 
      88                 : nsIFrame*
      89               0 : NS_NewSVGFEImageFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
      90                 : {
      91               0 :   return new (aPresShell) SVGFEImageFrame(aContext);
      92                 : }
      93                 : 
      94               0 : NS_IMPL_FRAMEARENA_HELPERS(SVGFEImageFrame)
      95                 : 
      96                 : /* virtual */ void
      97               0 : SVGFEImageFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
      98                 : {
      99               0 :   SVGFEImageFrameBase::DidSetStyleContext(aOldStyleContext);
     100               0 :   nsSVGEffects::InvalidateRenderingObservers(this);
     101               0 : }
     102                 : 
     103                 : /* virtual */ void
     104               0 : SVGFEImageFrame::DestroyFrom(nsIFrame* aDestructRoot)
     105                 : {
     106                 :   nsCOMPtr<nsIImageLoadingContent> imageLoader =
     107               0 :     do_QueryInterface(SVGFEImageFrameBase::mContent);
     108                 : 
     109               0 :   if (imageLoader) {
     110               0 :     imageLoader->FrameDestroyed(this);
     111                 :   }
     112                 : 
     113               0 :   SVGFEImageFrameBase::DestroyFrom(aDestructRoot);
     114               0 : }
     115                 : 
     116                 : NS_IMETHODIMP
     117               0 : SVGFEImageFrame::Init(nsIContent* aContent,
     118                 :                         nsIFrame* aParent,
     119                 :                         nsIFrame* aPrevInFlow)
     120                 : {
     121                 : #ifdef DEBUG
     122               0 :   nsCOMPtr<nsIDOMSVGFEImageElement> elem = do_QueryInterface(aContent);
     123               0 :   NS_ASSERTION(elem,
     124                 :                "Trying to construct an SVGFEImageFrame for a "
     125                 :                "content element that doesn't support the right interfaces");
     126                 : #endif /* DEBUG */
     127                 : 
     128               0 :   SVGFEImageFrameBase::Init(aContent, aParent, aPrevInFlow);
     129                 :   nsCOMPtr<nsIImageLoadingContent> imageLoader =
     130               0 :     do_QueryInterface(SVGFEImageFrameBase::mContent);
     131                 : 
     132               0 :   if (imageLoader) {
     133               0 :     imageLoader->FrameCreated(this);
     134                 :   }
     135                 : 
     136               0 :   return NS_OK;
     137                 : }
     138                 : 
     139                 : nsIAtom *
     140               0 : SVGFEImageFrame::GetType() const
     141                 : {
     142               0 :   return nsGkAtoms::svgFEImageFrame;
     143                 : }
     144                 : 
     145                 : NS_IMETHODIMP
     146               0 : SVGFEImageFrame::AttributeChanged(PRInt32  aNameSpaceID,
     147                 :                                   nsIAtom* aAttribute,
     148                 :                                   PRInt32  aModType)
     149                 : {
     150               0 :   nsSVGFEImageElement *element = static_cast<nsSVGFEImageElement*>(mContent);
     151               0 :   if (element->AttributeAffectsRendering(aNameSpaceID, aAttribute)) {
     152               0 :     nsSVGEffects::InvalidateRenderingObservers(this);
     153                 :   }
     154               0 :   if (aNameSpaceID == kNameSpaceID_XLink &&
     155                 :       aAttribute == nsGkAtoms::href) {
     156                 : 
     157                 :     // Prevent setting image.src by exiting early
     158               0 :     if (nsContentUtils::IsImageSrcSetDisabled()) {
     159               0 :       return NS_OK;
     160                 :     }
     161                 : 
     162               0 :     if (element->mStringAttributes[nsSVGFEImageElement::HREF].IsExplicitlySet()) {
     163               0 :       element->LoadSVGImage(true, true);
     164                 :     } else {
     165               0 :       element->CancelImageRequests(true);
     166                 :     }
     167                 :   }
     168                 : 
     169                 :   return SVGFEImageFrameBase::AttributeChanged(aNameSpaceID,
     170               0 :                                                  aAttribute, aModType);
     171                 : }

Generated by: LCOV version 1.7