LCOV - code coverage report
Current view: directory - layout/xul/base/src - nsContainerBoxObject.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 34 0 0.0 %
Date: 2012-06-02 Functions: 8 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 Mozilla.org code.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is Mozilla.org.
      18                 :  * Portions created by the Initial Developer are Copyright (C) 2006
      19                 :  * the Initial Developer. All Rights Reserved.
      20                 :  *
      21                 :  * Contributor(s):
      22                 :  *     Olli Pettay <Olli.Pettay@helsinki.fi> (Original Author)
      23                 :  *
      24                 :  * Alternatively, the contents of this file may be used under the terms of
      25                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      26                 :  * or 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                 : #include "nsCOMPtr.h"
      39                 : #include "nsIContainerBoxObject.h"
      40                 : #include "nsIBrowserBoxObject.h"
      41                 : #include "nsIEditorBoxObject.h"
      42                 : #include "nsIIFrameBoxObject.h"
      43                 : #include "nsBoxObject.h"
      44                 : #include "nsIDocShell.h"
      45                 : #include "nsIContent.h"
      46                 : #include "nsIDocument.h"
      47                 : #include "nsIFrame.h"
      48                 : #include "nsSubDocumentFrame.h"
      49                 : 
      50                 : /**
      51                 :  * nsContainerBoxObject implements deprecated nsIBrowserBoxObject,
      52                 :  * nsIEditorBoxObject and nsIIFrameBoxObject interfaces only because of the
      53                 :  * backward compatibility.
      54                 :  */
      55                 : 
      56                 : class nsContainerBoxObject : public nsBoxObject,
      57                 :                              public nsIBrowserBoxObject,
      58                 :                              public nsIEditorBoxObject,
      59                 :                              public nsIIFrameBoxObject
      60               0 : {
      61                 : public:
      62                 :   NS_DECL_ISUPPORTS_INHERITED
      63                 :   NS_DECL_NSICONTAINERBOXOBJECT
      64                 :   NS_DECL_NSIBROWSERBOXOBJECT
      65                 :   NS_DECL_NSIEDITORBOXOBJECT
      66                 :   NS_DECL_NSIIFRAMEBOXOBJECT
      67                 : };
      68                 : 
      69               0 : NS_INTERFACE_MAP_BEGIN(nsContainerBoxObject)
      70               0 :   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIContainerBoxObject, nsIBrowserBoxObject)
      71               0 :   NS_INTERFACE_MAP_ENTRY(nsIBrowserBoxObject)
      72               0 :   NS_INTERFACE_MAP_ENTRY(nsIEditorBoxObject)
      73               0 :   NS_INTERFACE_MAP_ENTRY(nsIIFrameBoxObject)
      74               0 : NS_INTERFACE_MAP_END_INHERITING(nsBoxObject)
      75                 : 
      76               0 : NS_IMPL_ADDREF_INHERITED(nsContainerBoxObject, nsBoxObject)
      77               0 : NS_IMPL_RELEASE_INHERITED(nsContainerBoxObject, nsBoxObject)
      78                 : 
      79               0 : NS_IMETHODIMP nsContainerBoxObject::GetDocShell(nsIDocShell** aResult)
      80                 : {
      81               0 :   *aResult = nsnull;
      82                 : 
      83               0 :   nsIFrame *frame = GetFrame(false);
      84                 : 
      85               0 :   if (frame) {
      86               0 :     nsSubDocumentFrame *subDocFrame = do_QueryFrame(frame);
      87               0 :     if (subDocFrame) {
      88                 :       // Ok, the frame for mContent is an nsSubDocumentFrame, it knows how
      89                 :       // to reach the docshell, so ask it...
      90                 : 
      91               0 :       return subDocFrame->GetDocShell(aResult);
      92                 :     }
      93                 :   }
      94                 : 
      95               0 :   if (!mContent) {
      96               0 :     return NS_OK;
      97                 :   }
      98                 :   
      99                 :   // No nsSubDocumentFrame available for mContent, try if there's a mapping
     100                 :   // between mContent's document to mContent's subdocument.
     101                 : 
     102                 :   // XXXbz sXBL/XBL2 issue -- ownerDocument or currentDocument?
     103               0 :   nsIDocument *doc = mContent->GetDocument();
     104                 : 
     105               0 :   if (!doc) {
     106               0 :     return NS_OK;
     107                 :   }
     108                 :   
     109               0 :   nsIDocument *sub_doc = doc->GetSubDocumentFor(mContent);
     110                 : 
     111               0 :   if (!sub_doc) {
     112               0 :     return NS_OK;
     113                 :   }
     114                 : 
     115               0 :   nsCOMPtr<nsISupports> container = sub_doc->GetContainer();
     116                 : 
     117               0 :   if (!container) {
     118               0 :     return NS_OK;
     119                 :   }
     120                 : 
     121               0 :   return CallQueryInterface(container, aResult);
     122                 : }
     123                 : 
     124                 : nsresult
     125               0 : NS_NewContainerBoxObject(nsIBoxObject** aResult)
     126                 : {
     127               0 :   *aResult = new nsContainerBoxObject();
     128               0 :   if (!*aResult)
     129               0 :     return NS_ERROR_OUT_OF_MEMORY;
     130               0 :   NS_ADDREF(*aResult);
     131               0 :   return NS_OK;
     132                 : }
     133                 : 

Generated by: LCOV version 1.7