LCOV - code coverage report
Current view: directory - content/base/src - nsGenConImageContent.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 28 0 0.0 %
Date: 2012-06-02 Functions: 9 0 0.0 %

       1                 : 
       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 nsGenConImageContent.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is the Mozilla Foundation.
      18                 :  * Portions created by the Initial Developer are Copyright (C) 2004
      19                 :  * the Initial Developer. All Rights Reserved.
      20                 :  *
      21                 :  * Contributor(s):
      22                 :  *   L. David Baron <dbaron@dbaron.org> (original author)
      23                 :  *
      24                 :  * Alternatively, the contents of this file may be used under the terms of
      25                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      26                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      27                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      28                 :  * of those above. If you wish to allow use of your version of this file only
      29                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      30                 :  * use your version of this file under the terms of the MPL, indicate your
      31                 :  * decision by deleting the provisions above and replace them with the notice
      32                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      33                 :  * the provisions above, a recipient may use your version of this file under
      34                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      35                 :  *
      36                 :  * ***** END LICENSE BLOCK ***** */
      37                 : 
      38                 : /**
      39                 :  * A fake content node class so that the image frame for
      40                 :  *   content: url(foo);
      41                 :  * in CSS can have an nsIImageLoadingContent but use an
      42                 :  * imgIRequest that's already been loaded from the style system.
      43                 :  */
      44                 : 
      45                 : #include "nsContentCreatorFunctions.h"
      46                 : #include "nsXMLElement.h"
      47                 : #include "nsImageLoadingContent.h"
      48                 : #include "imgIRequest.h"
      49                 : #include "nsEventStates.h"
      50                 : 
      51                 : class nsGenConImageContent : public nsXMLElement,
      52                 :                              public nsImageLoadingContent
      53                 : {
      54                 : public:
      55               0 :   nsGenConImageContent(already_AddRefed<nsINodeInfo> aNodeInfo)
      56               0 :     : nsXMLElement(aNodeInfo)
      57                 :   {
      58                 :     // nsImageLoadingContent starts out broken, so we start out
      59                 :     // suppressed to match it.
      60               0 :     AddStatesSilently(NS_EVENT_STATE_SUPPRESSED);
      61               0 :   }
      62                 : 
      63               0 :   nsresult Init(imgIRequest* aImageRequest)
      64                 :   {
      65                 :     // No need to notify, since we have no frame.
      66               0 :     return UseAsPrimaryRequest(aImageRequest, false);
      67                 :   }
      68                 : 
      69                 :   // nsIContent overrides
      70                 :   virtual nsEventStates IntrinsicState() const;
      71                 :   
      72                 : private:
      73                 :   virtual ~nsGenConImageContent();
      74                 : 
      75                 : public:
      76                 :   NS_DECL_ISUPPORTS_INHERITED
      77                 : };
      78                 : 
      79               0 : NS_IMPL_ISUPPORTS_INHERITED3(nsGenConImageContent, nsXMLElement,
      80                 :                              nsIImageLoadingContent, imgIContainerObserver, imgIDecoderObserver)
      81                 : 
      82                 : nsresult
      83               0 : NS_NewGenConImageContent(nsIContent** aResult, already_AddRefed<nsINodeInfo> aNodeInfo,
      84                 :                          imgIRequest* aImageRequest)
      85                 : {
      86               0 :   NS_PRECONDITION(aImageRequest, "Must have request!");
      87               0 :   nsGenConImageContent *it = new nsGenConImageContent(aNodeInfo);
      88               0 :   if (!it)
      89               0 :     return NS_ERROR_OUT_OF_MEMORY;
      90               0 :   NS_ADDREF(*aResult = it);
      91               0 :   nsresult rv = it->Init(aImageRequest);
      92               0 :   if (NS_FAILED(rv))
      93               0 :     NS_RELEASE(*aResult);
      94               0 :   return rv;
      95                 : }
      96                 : 
      97               0 : nsGenConImageContent::~nsGenConImageContent()
      98                 : {
      99               0 :   DestroyImageLoadingContent();
     100               0 : }
     101                 : 
     102                 : nsEventStates
     103               0 : nsGenConImageContent::IntrinsicState() const
     104                 : {
     105               0 :   nsEventStates state = nsXMLElement::IntrinsicState();
     106                 : 
     107               0 :   nsEventStates imageState = nsImageLoadingContent::ImageState();
     108               0 :   if (imageState.HasAtLeastOneOfStates(NS_EVENT_STATE_BROKEN | NS_EVENT_STATE_USERDISABLED)) {
     109                 :     // We should never be in an error state; if the image fails to load, we
     110                 :     // just go to the suppressed state.
     111               0 :     imageState |= NS_EVENT_STATE_SUPPRESSED;
     112               0 :     imageState &= ~NS_EVENT_STATE_BROKEN;
     113                 :   }
     114               0 :   imageState &= ~NS_EVENT_STATE_LOADING;
     115               0 :   return state | imageState;
     116                 : }

Generated by: LCOV version 1.7