LCOV - code coverage report
Current view: directory - layout/inspector/src - inLayoutUtils.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 49 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
      18                 :  * Netscape Communications Corporation.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 1998
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      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                 : #include "inLayoutUtils.h"
      39                 : 
      40                 : #include "nsIDocument.h"
      41                 : #include "nsIContent.h"
      42                 : #include "nsIContentViewer.h"
      43                 : #include "nsPIDOMWindow.h"
      44                 : #include "nsIDocShell.h"
      45                 : #include "nsIPresShell.h"
      46                 : #include "nsPresContext.h"
      47                 : 
      48                 : ///////////////////////////////////////////////////////////////////////////////
      49                 : 
      50                 : nsIDOMWindow*
      51               0 : inLayoutUtils::GetWindowFor(nsIDOMNode* aNode)
      52                 : {
      53               0 :   nsCOMPtr<nsIDOMDocument> doc1;
      54               0 :   aNode->GetOwnerDocument(getter_AddRefs(doc1));
      55               0 :   return GetWindowFor(doc1.get());
      56                 : }
      57                 : 
      58                 : nsIDOMWindow*
      59               0 : inLayoutUtils::GetWindowFor(nsIDOMDocument* aDoc)
      60                 : {
      61               0 :   nsCOMPtr<nsIDOMWindow> window;
      62               0 :   aDoc->GetDefaultView(getter_AddRefs(window));
      63               0 :   return window;
      64                 : }
      65                 : 
      66                 : nsIPresShell* 
      67               0 : inLayoutUtils::GetPresShellFor(nsISupports* aThing)
      68                 : {
      69               0 :   nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aThing);
      70                 : 
      71               0 :   nsCOMPtr<nsIPresShell> presShell;
      72               0 :   window->GetDocShell()->GetPresShell(getter_AddRefs(presShell));
      73                 : 
      74               0 :   return presShell;
      75                 : }
      76                 : 
      77                 : /*static*/
      78                 : nsIFrame*
      79               0 : inLayoutUtils::GetFrameFor(nsIDOMElement* aElement)
      80                 : {
      81               0 :   nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
      82               0 :   return content->GetPrimaryFrame();
      83                 : }
      84                 : 
      85                 : nsEventStateManager*
      86               0 : inLayoutUtils::GetEventStateManagerFor(nsIDOMElement *aElement)
      87                 : {
      88               0 :   NS_PRECONDITION(aElement, "Passing in a null element is bad");
      89                 : 
      90               0 :   nsCOMPtr<nsIDOMDocument> domDoc;
      91               0 :   aElement->GetOwnerDocument(getter_AddRefs(domDoc));
      92               0 :   nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
      93                 : 
      94               0 :   if (!doc) {
      95               0 :     NS_WARNING("Could not get an nsIDocument!");
      96               0 :     return nsnull;
      97                 :   }
      98                 : 
      99               0 :   nsIPresShell *shell = doc->GetShell();
     100               0 :   if (!shell)
     101               0 :     return nsnull;
     102                 : 
     103               0 :   return shell->GetPresContext()->EventStateManager();
     104                 : }
     105                 : 
     106                 : nsBindingManager* 
     107               0 : inLayoutUtils::GetBindingManagerFor(nsIDOMNode* aNode)
     108                 : {
     109               0 :   nsCOMPtr<nsIDOMDocument> domdoc;
     110               0 :   aNode->GetOwnerDocument(getter_AddRefs(domdoc));
     111               0 :   if (domdoc) {
     112               0 :     nsCOMPtr<nsIDocument> doc = do_QueryInterface(domdoc);
     113               0 :     return doc->BindingManager();
     114                 :   }
     115                 :   
     116               0 :   return nsnull;
     117                 : }
     118                 : 
     119                 : nsIDOMDocument*
     120               0 : inLayoutUtils::GetSubDocumentFor(nsIDOMNode* aNode)
     121                 : {
     122               0 :   nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
     123               0 :   if (content) {
     124               0 :     nsCOMPtr<nsIDocument> doc = content->GetDocument();
     125               0 :     if (doc) {
     126               0 :       nsCOMPtr<nsIDOMDocument> domdoc(do_QueryInterface(doc->GetSubDocumentFor(content)));
     127                 : 
     128               0 :       return domdoc;
     129                 :     }
     130                 :   }
     131                 :   
     132               0 :   return nsnull;
     133                 : }
     134                 : 
     135                 : nsIDOMNode*
     136               0 : inLayoutUtils::GetContainerFor(nsIDOMDocument* aDoc)
     137                 : {
     138               0 :   nsCOMPtr<nsIDocument> doc = do_QueryInterface(aDoc);
     139               0 :   if (!doc) return nsnull;
     140                 : 
     141               0 :   nsPIDOMWindow *pwin = doc->GetWindow();
     142               0 :   if (!pwin) return nsnull;
     143                 : 
     144               0 :   return pwin->GetFrameElementInternal();
     145                 : }
     146                 : 

Generated by: LCOV version 1.7